From 20fd6cc98aa3497674d1285d5460f1e4ea85cdd4 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 1 Jan 2017 11:53:18 -0800 Subject: [PATCH 01/37] Add 'platform-specific' section to `sleep_ms` to match `sleep`. --- src/libstd/thread/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 81979fd41a6bf..b3522ac35f2e5 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -491,9 +491,12 @@ pub fn panicking() -> bool { /// Puts the current thread to sleep for the specified amount of time. /// /// The thread may sleep longer than the duration specified due to scheduling -/// specifics or platform-dependent functionality. Note that on unix platforms -/// this function will not return early due to a signal being received or a -/// spurious wakeup. +/// specifics or platform-dependent functionality. +/// +/// # Platform behavior +/// +/// On Unix platforms this function will not return early due to a +/// signal being received or a spurious wakeup. /// /// # Examples /// From c02d577c53dc29fcef0c589af8d95d037777a09b Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sun, 15 Jan 2017 03:09:48 +0000 Subject: [PATCH 02/37] Improve the warning cycle for `use $crate;`. --- src/librustc_resolve/build_reduced_graph.rs | 5 ++++- src/test/compile-fail/auxiliary/import_crate_var.rs | 7 ++++++- src/test/compile-fail/import-crate-var.rs | 6 ++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 5be21bc62c56c..5e9856878865a 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -143,7 +143,7 @@ impl<'a> Resolver<'a> { let is_prelude = attr::contains_name(&item.attrs, "prelude_import"); match view_path.node { - ViewPathSimple(binding, ref full_path) => { + ViewPathSimple(mut binding, ref full_path) => { let mut source = full_path.segments.last().unwrap().identifier; let source_name = source.name; if source_name == "mod" || source_name == "self" { @@ -157,6 +157,9 @@ impl<'a> Resolver<'a> { ModuleKind::Block(..) => unreachable!(), }; source.name = crate_name; + if binding.name == "$crate" { + binding.name = crate_name; + } self.session.struct_span_warn(item.span, "`$crate` may not be imported") .note("`use $crate;` was erroneously allowed and \ diff --git a/src/test/compile-fail/auxiliary/import_crate_var.rs b/src/test/compile-fail/auxiliary/import_crate_var.rs index 1dfc7a128aa1c..a8a55afa41a0e 100644 --- a/src/test/compile-fail/auxiliary/import_crate_var.rs +++ b/src/test/compile-fail/auxiliary/import_crate_var.rs @@ -8,5 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +pub fn f() {} + #[macro_export] -macro_rules! m { () => { use $crate; } } +macro_rules! m { () => { + use $crate; + import_crate_var::f(); +} } diff --git a/src/test/compile-fail/import-crate-var.rs b/src/test/compile-fail/import-crate-var.rs index 9f573945483de..e58ba2c88917f 100644 --- a/src/test/compile-fail/import-crate-var.rs +++ b/src/test/compile-fail/import-crate-var.rs @@ -11,11 +11,13 @@ // aux-build:import_crate_var.rs // error-pattern: `$crate` may not be imported // error-pattern: `use $crate;` was erroneously allowed and will become a hard error +// error-pattern: compilation successful #![feature(rustc_attrs)] #[macro_use] extern crate import_crate_var; -m!(); #[rustc_error] -fn main() {} +fn main() { + m!(); +} From 6162637762d12760ba5b6c1e20f01298111ae8fe Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 13 Jan 2017 16:22:47 -0800 Subject: [PATCH 03/37] travis: Add i586 linux and i686 musl This commit expands the existing x86_64-musl entry in the Travis matrix to also build/test i586-unknown-linux-gnu and i686-unknown-linux-musl. cc #38531 Closes #39053 --- .travis.yml | 2 +- .../Dockerfile | 25 ++++--- .../docker/linux-tested-targets/build-musl.sh | 64 +++++++++++++++++ .../musl-libunwind-patch.patch | 15 ++++ src/ci/docker/x86_64-musl/build-musl.sh | 33 --------- src/test/run-pass/issue-21634.rs | 6 +- src/test/run-pass/sse2.rs | 11 ++- src/tools/compiletest/src/main.rs | 4 ++ src/tools/compiletest/src/util.rs | 69 ++++++++++--------- 9 files changed, 152 insertions(+), 77 deletions(-) rename src/ci/docker/{x86_64-musl => linux-tested-targets}/Dockerfile (56%) create mode 100644 src/ci/docker/linux-tested-targets/build-musl.sh create mode 100644 src/ci/docker/linux-tested-targets/musl-libunwind-patch.patch delete mode 100644 src/ci/docker/x86_64-musl/build-musl.sh diff --git a/.travis.yml b/.travis.yml index abd0a8fe346f0..6cdc4d99f201e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ matrix: # Linux builders, all docker images - env: IMAGE=arm-android DEPLOY=1 - env: IMAGE=cross DEPLOY=1 + - env: IMAGE=linux-tested-targets DEPLOY=1 - env: IMAGE=dist-arm-linux DEPLOY=1 - env: IMAGE=dist-armv7-aarch64-linux DEPLOY=1 - env: IMAGE=dist-freebsd DEPLOY=1 @@ -32,7 +33,6 @@ matrix: - env: IMAGE=x86_64-gnu-nopt - env: IMAGE=x86_64-gnu-make - env: IMAGE=x86_64-gnu-llvm-3.7 ALLOW_PR=1 RUST_BACKTRACE=1 - - env: IMAGE=x86_64-musl DEPLOY=1 - env: IMAGE=x86_64-gnu-distcheck # OSX builders diff --git a/src/ci/docker/x86_64-musl/Dockerfile b/src/ci/docker/linux-tested-targets/Dockerfile similarity index 56% rename from src/ci/docker/x86_64-musl/Dockerfile rename to src/ci/docker/linux-tested-targets/Dockerfile index 11b85a6c8fdfb..2a43201ed0aeb 100644 --- a/src/ci/docker/x86_64-musl/Dockerfile +++ b/src/ci/docker/linux-tested-targets/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:16.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - g++ \ + g++-multilib \ make \ file \ curl \ @@ -11,10 +11,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ cmake \ xz-utils \ sudo \ - gdb + gdb \ + patch WORKDIR /build/ -COPY build-musl.sh /build/ +COPY musl-libunwind-patch.patch build-musl.sh /build/ RUN sh /build/build-musl.sh && rm -rf /build RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ @@ -27,9 +28,17 @@ RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | tar xJf - -C /usr/local/bin --strip-components=1 ENV RUST_CONFIGURE_ARGS \ - --target=x86_64-unknown-linux-musl \ - --musl-root-x86_64=/musl-x86_64 -ENV PATH=$PATH:/musl-x86_64/bin + --target=x86_64-unknown-linux-musl,i686-unknown-linux-musl,i586-unknown-linux-gnu \ + --musl-root-x86_64=/musl-x86_64 \ + --musl-root-i686=/musl-i686 + ENV SCRIPT \ - python2.7 ../x.py test --target x86_64-unknown-linux-musl && \ - python2.7 ../x.py dist --target x86_64-unknown-linux-musl + python2.7 ../x.py test \ + --target x86_64-unknown-linux-musl \ + --target i686-unknown-linux-musl \ + --target i586-unknown-linux-gnu \ + && \ + python2.7 ../x.py dist \ + --target x86_64-unknown-linux-musl \ + --target i686-unknown-linux-musl \ + --target i586-unknown-linux-gnu diff --git a/src/ci/docker/linux-tested-targets/build-musl.sh b/src/ci/docker/linux-tested-targets/build-musl.sh new file mode 100644 index 0000000000000..2382605f9bd36 --- /dev/null +++ b/src/ci/docker/linux-tested-targets/build-musl.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +export CFLAGS="-fPIC" +MUSL=musl-1.1.14 +curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf - +cd $MUSL +./configure --prefix=/musl-x86_64 --disable-shared +make -j10 +make install +make clean +# for i686 +CFLAGS="$CFLAGS -m32" ./configure --prefix=/musl-i686 --disable-shared --target=i686 +make -j10 +make install +cd .. + +# To build MUSL we're going to need a libunwind lying around, so acquire that +# here and build it. +curl -L https://github.com/llvm-mirror/llvm/archive/release_37.tar.gz | tar xzf - +curl -L https://github.com/llvm-mirror/libunwind/archive/release_37.tar.gz | tar xzf - + +# Whoa what's this mysterious patch we're applying to libunwind! Why are we +# swapping the values of ESP/EBP in libunwind?! +# +# Discovered in #35599 it turns out that the vanilla build of libunwind is not +# suitable for unwinding 32-bit musl. After some investigation it ended up +# looking like the register values for ESP/EBP were indeed incorrect (swapped) +# in the source. Similar commits in libunwind (r280099 and r282589) have noticed +# this for other platforms, and we just need to realize it for musl linux as +# well. +# +# More technical info can be found at #35599 +cd libunwind-release_37 +patch -Np1 < /build/musl-libunwind-patch.patch +cd .. + +mkdir libunwind-build +cd libunwind-build +cmake ../libunwind-release_37 -DLLVM_PATH=/build/llvm-release_37 \ + -DLIBUNWIND_ENABLE_SHARED=0 +make -j10 +cp lib/libunwind.a /musl-x86_64/lib + +# (Note: the next cmake call doesn't fully override the previous cached one, so remove the cached +# configuration manually. IOW, if don't do this or call make clean we'll end up building libunwind +# for x86_64 again) +rm -rf * +# for i686 +CFLAGS="$CFLAGS -m32 -g" CXXFLAGS="$CXXFLAGS -m32 -g" cmake ../libunwind-release_37 \ + -DLLVM_PATH=/build/llvm-release_37 \ + -DLIBUNWIND_ENABLE_SHARED=0 +make -j10 +cp lib/libunwind.a /musl-i686/lib diff --git a/src/ci/docker/linux-tested-targets/musl-libunwind-patch.patch b/src/ci/docker/linux-tested-targets/musl-libunwind-patch.patch new file mode 100644 index 0000000000000..99cd685b72d17 --- /dev/null +++ b/src/ci/docker/linux-tested-targets/musl-libunwind-patch.patch @@ -0,0 +1,15 @@ +diff --git a/include/libunwind.h b/include/libunwind.h +index c5b9633..1360eb2 100644 +--- a/include/libunwind.h ++++ b/include/libunwind.h +@@ -151,8 +151,8 @@ enum { + UNW_X86_ECX = 1, + UNW_X86_EDX = 2, + UNW_X86_EBX = 3, +- UNW_X86_EBP = 4, +- UNW_X86_ESP = 5, ++ UNW_X86_ESP = 4, ++ UNW_X86_EBP = 5, + UNW_X86_ESI = 6, + UNW_X86_EDI = 7 + }; diff --git a/src/ci/docker/x86_64-musl/build-musl.sh b/src/ci/docker/x86_64-musl/build-musl.sh deleted file mode 100644 index 2bfbd646b75c8..0000000000000 --- a/src/ci/docker/x86_64-musl/build-musl.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Copyright 2016 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -set -ex - -export CFLAGS="-fPIC" -MUSL=musl-1.1.14 -curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf - -cd $MUSL -./configure --prefix=/musl-x86_64 --disable-shared -make -j10 -make install -make clean -cd .. - -# To build MUSL we're going to need a libunwind lying around, so acquire that -# here and build it. -curl -L https://github.com/llvm-mirror/llvm/archive/release_37.tar.gz | tar xzf - -curl -L https://github.com/llvm-mirror/libunwind/archive/release_37.tar.gz | tar xzf - -mkdir libunwind-build -cd libunwind-build -cmake ../libunwind-release_37 -DLLVM_PATH=/build/llvm-release_37 \ - -DLIBUNWIND_ENABLE_SHARED=0 -make -j10 -cp lib/libunwind.a /musl-x86_64/lib diff --git a/src/test/run-pass/issue-21634.rs b/src/test/run-pass/issue-21634.rs index 2a146ae8fcf7b..08cc993ce4fb2 100644 --- a/src/test/run-pass/issue-21634.rs +++ b/src/test/run-pass/issue-21634.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(cfg_target_feature)] - +#[cfg(any(not(target_arch = "x86"), target_feature = "sse2"))] fn main() { if let Ok(x) = "3.1415".parse::() { assert_eq!(false, x <= 0.0); @@ -21,3 +22,6 @@ fn main() { assert_eq!(8.1415, { x += 5.0; x }); } } + +#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))] +fn main() {} diff --git a/src/test/run-pass/sse2.rs b/src/test/run-pass/sse2.rs index 78d91b2f3120e..7e42698d49676 100644 --- a/src/test/run-pass/sse2.rs +++ b/src/test/run-pass/sse2.rs @@ -10,9 +10,16 @@ #![feature(cfg_target_feature)] -pub fn main() { +use std::env; + +fn main() { + // Skip this tests on i586-unknown-linux-gnu where sse2 is disabled + let real_target = env::var("TARGET").unwrap(); + if real_target.contains("i586") { + return + } if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { assert!(cfg!(target_feature = "sse2"), - "SSE2 was not detected as available on an x86 platform"); + "SSE2 was not detected as available on an x86 platform"); } } diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index f6c8393ac2154..53abe71eed451 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -319,6 +319,10 @@ pub fn run_tests(config: &Config) { // Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows // If #11207 is resolved (adding manifest to .exe) this becomes unnecessary env::set_var("__COMPAT_LAYER", "RunAsInvoker"); + + // Let tests know which target they're running as + env::set_var("TARGET", &config.target); + let res = test::run_tests_console(&opts, tests.into_iter().collect()); match res { Ok(true) => {} diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index cad71c59f0a4a..4202356bd97a0 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -12,39 +12,44 @@ use std::env; use common::Config; /// Conversion table from triple OS name to Rust SYSNAME -const OS_TABLE: &'static [(&'static str, &'static str)] = &[("android", "android"), - ("bitrig", "bitrig"), - ("darwin", "macos"), - ("dragonfly", "dragonfly"), - ("freebsd", "freebsd"), - ("haiku", "haiku"), - ("ios", "ios"), - ("linux", "linux"), - ("mingw32", "windows"), - ("netbsd", "netbsd"), - ("openbsd", "openbsd"), - ("win32", "windows"), - ("windows", "windows"), - ("solaris", "solaris"), - ("emscripten", "emscripten")]; +const OS_TABLE: &'static [(&'static str, &'static str)] = &[ + ("android", "android"), + ("bitrig", "bitrig"), + ("darwin", "macos"), + ("dragonfly", "dragonfly"), + ("freebsd", "freebsd"), + ("haiku", "haiku"), + ("ios", "ios"), + ("linux", "linux"), + ("mingw32", "windows"), + ("netbsd", "netbsd"), + ("openbsd", "openbsd"), + ("win32", "windows"), + ("windows", "windows"), + ("solaris", "solaris"), + ("emscripten", "emscripten"), +]; -const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[("aarch64", "aarch64"), - ("amd64", "x86_64"), - ("arm", "arm"), - ("arm64", "aarch64"), - ("hexagon", "hexagon"), - ("i386", "x86"), - ("i686", "x86"), - ("mips", "mips"), - ("msp430", "msp430"), - ("powerpc", "powerpc"), - ("powerpc64", "powerpc64"), - ("s390x", "s390x"), - ("sparc", "sparc"), - ("x86_64", "x86_64"), - ("xcore", "xcore"), - ("asmjs", "asmjs"), - ("wasm32", "wasm32")]; +const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[ + ("aarch64", "aarch64"), + ("amd64", "x86_64"), + ("arm", "arm"), + ("arm64", "aarch64"), + ("hexagon", "hexagon"), + ("i386", "x86"), + ("i586", "x86"), + ("i686", "x86"), + ("mips", "mips"), + ("msp430", "msp430"), + ("powerpc", "powerpc"), + ("powerpc64", "powerpc64"), + ("s390x", "s390x"), + ("sparc", "sparc"), + ("x86_64", "x86_64"), + ("xcore", "xcore"), + ("asmjs", "asmjs"), + ("wasm32", "wasm32"), +]; pub fn get_os(triple: &str) -> &'static str { for &(triple_os, os) in OS_TABLE { From f6c0c4837c303e327a8b37649dd72f115b48f309 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Sat, 7 Jan 2017 21:04:49 -0800 Subject: [PATCH 04/37] Refactor `proc_macro::TokenStream` to use `syntax::tokenstream::TokenStream`; fix tests for changed semantics --- src/libproc_macro/lib.rs | 73 ++++++++++++------- src/libsyntax_ext/deriving/custom.rs | 17 ++++- .../proc-macro/derive-bad.rs | 3 +- .../proc-macro/auxiliary/derive-atob.rs | 2 +- .../proc-macro/auxiliary/derive-ctod.rs | 2 +- .../auxiliary/derive-same-struct.rs | 4 +- 6 files changed, 67 insertions(+), 34 deletions(-) diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 93bc867462568..ab5962779feeb 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -39,9 +39,9 @@ extern crate syntax; use std::fmt; use std::str::FromStr; -use syntax::ast; +use syntax::errors::DiagnosticBuilder; use syntax::parse; -use syntax::ptr::P; +use syntax::tokenstream::TokenStream as TokenStream_; /// The main type provided by this crate, representing an abstract stream of /// tokens. @@ -54,7 +54,7 @@ use syntax::ptr::P; /// time! #[stable(feature = "proc_macro_lib", since = "1.15.0")] pub struct TokenStream { - inner: Vec>, + inner: TokenStream_, } /// Error returned from `TokenStream::from_str`. @@ -77,17 +77,41 @@ pub struct LexError { #[doc(hidden)] pub mod __internal { use std::cell::Cell; + use std::rc::Rc; use syntax::ast; use syntax::ptr::P; - use syntax::parse::ParseSess; - use super::TokenStream; + use syntax::parse::{self, token, ParseSess}; + use syntax::tokenstream::TokenStream as TokenStream_; + + use super::{TokenStream, LexError}; pub fn new_token_stream(item: P) -> TokenStream { - TokenStream { inner: vec![item] } + TokenStream { inner: TokenStream_::from_tokens(vec![ + token::Interpolated(Rc::new(token::NtItem(item))) + ])} + } + + pub fn token_stream_wrap(inner: TokenStream_) -> TokenStream { + TokenStream { + inner: inner + } + } + + pub fn token_stream_parse_items(stream: TokenStream) -> Result>, LexError> { + with_parse_sess(move |sess| { + let mut parser = parse::new_parser_from_ts(sess, stream.inner); + let mut items = Vec::new(); + + while let Some(item) = try!(parser.parse_item().map_err(super::parse_to_lex_err)) { + items.push(item) + } + + Ok(items) + }) } - pub fn token_stream_items(stream: TokenStream) -> Vec> { + pub fn token_stream_inner(stream: TokenStream) -> TokenStream_ { stream.inner } @@ -96,6 +120,10 @@ pub mod __internal { trait_name: &str, expand: fn(TokenStream) -> TokenStream, attributes: &[&'static str]); + + fn register_attr_proc_macro(&mut self, + name: &str, + expand: fn(TokenStream, TokenStream) -> TokenStream); } // Emulate scoped_thread_local!() here essentially @@ -125,11 +153,17 @@ pub mod __internal { where F: FnOnce(&ParseSess) -> R { let p = CURRENT_SESS.with(|p| p.get()); - assert!(!p.is_null()); + assert!(!p.is_null(), "proc_macro::__internal::with_parse_sess() called \ + before set_parse_sess()!"); f(unsafe { &*p }) } } +fn parse_to_lex_err(mut err: DiagnosticBuilder) -> LexError { + err.cancel(); + LexError { _inner: () } +} + #[stable(feature = "proc_macro_lib", since = "1.15.0")] impl FromStr for TokenStream { type Err = LexError; @@ -138,18 +172,10 @@ impl FromStr for TokenStream { __internal::with_parse_sess(|sess| { let src = src.to_string(); let name = "".to_string(); - let mut parser = parse::new_parser_from_source_str(sess, name, src); - let mut ret = TokenStream { inner: Vec::new() }; - loop { - match parser.parse_item() { - Ok(Some(item)) => ret.inner.push(item), - Ok(None) => return Ok(ret), - Err(mut err) => { - err.cancel(); - return Err(LexError { _inner: () }) - } - } - } + let tts = try!(parse::parse_tts_from_source_str(name, src, sess) + .map_err(parse_to_lex_err)); + + Ok(__internal::token_stream_wrap(TokenStream_::from_tts(tts))) }) } } @@ -157,11 +183,6 @@ impl FromStr for TokenStream { #[stable(feature = "proc_macro_lib", since = "1.15.0")] impl fmt::Display for TokenStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - for item in self.inner.iter() { - let item = syntax::print::pprust::item_to_string(item); - try!(f.write_str(&item)); - try!(f.write_str("\n")); - } - Ok(()) + self.inner.fmt(f) } } diff --git a/src/libsyntax_ext/deriving/custom.rs b/src/libsyntax_ext/deriving/custom.rs index 64ec460a52460..2ce6fc03f7731 100644 --- a/src/libsyntax_ext/deriving/custom.rs +++ b/src/libsyntax_ext/deriving/custom.rs @@ -77,8 +77,9 @@ impl MultiItemModifier for CustomDerive { let inner = self.inner; panic::catch_unwind(panic::AssertUnwindSafe(|| inner(input))) }); - let new_items = match res { - Ok(stream) => __internal::token_stream_items(stream), + + let stream = match res { + Ok(stream) => stream, Err(e) => { let msg = "custom derive attribute panicked"; let mut err = ecx.struct_span_fatal(span, msg); @@ -94,6 +95,18 @@ impl MultiItemModifier for CustomDerive { } }; + let new_items = __internal::set_parse_sess(&ecx.parse_sess, || { + match __internal::token_stream_parse_items(stream) { + Ok(new_items) => new_items, + Err(_) => { + // FIXME: handle this better + let msg = "custom derive produced unparseable tokens"; + ecx.struct_span_fatal(span, msg).emit(); + panic!(FatalError); + } + } + }); + let mut res = vec![Annotatable::Item(item)]; // Reassign spans of all expanded items to the input `item` // for better errors here. diff --git a/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs b/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs index 0e4ac9fe1eaf5..a5359946c09c2 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs @@ -16,8 +16,7 @@ extern crate derive_bad; #[derive( A )] -//~^^ ERROR: custom derive attribute panicked -//~| HELP: called `Result::unwrap()` on an `Err` value: LexError +//~^^ ERROR: custom derive produced unparseable tokens struct A; fn main() {} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs index 713fb7d10f2fd..4624891c1a32d 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs @@ -19,6 +19,6 @@ use proc_macro::TokenStream; #[proc_macro_derive(AToB)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); - assert_eq!(input, "#[derive(Copy, Clone)]\nstruct A;\n"); + assert_eq!(input, "#[derive(Copy, Clone)]\nstruct A;"); "struct B;".parse().unwrap() } diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs index 19caafd17b5f3..550ffe9400db8 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs @@ -19,6 +19,6 @@ use proc_macro::TokenStream; #[proc_macro_derive(CToD)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); - assert_eq!(input, "struct C;\n"); + assert_eq!(input, "struct C;"); "struct D;".parse().unwrap() } diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs index a2c25ae50e8ec..cf96f52823f0f 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs @@ -18,12 +18,12 @@ use proc_macro::TokenStream; #[proc_macro_derive(AToB)] pub fn derive1(input: TokenStream) -> TokenStream { println!("input1: {:?}", input.to_string()); - assert_eq!(input.to_string(), "struct A;\n"); + assert_eq!(input.to_string(), "struct A;"); "#[derive(BToC)] struct B;".parse().unwrap() } #[proc_macro_derive(BToC)] pub fn derive2(input: TokenStream) -> TokenStream { - assert_eq!(input.to_string(), "struct B;\n"); + assert_eq!(input.to_string(), "struct B;"); "struct C;".parse().unwrap() } From 2d52cb93497063a723381f0a688cbae738c28521 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 16 Jan 2017 16:49:49 -0800 Subject: [PATCH 05/37] appveyor: Test/Dist i586 MSVC This is a target that we're shipping today, so this commit adds this matrix entry to AppVeyor. This reuses the existing i686 MSVC matrix entry as it's currently finishing about a half hour under two hours, which should hopefully give it enough extra time to run this test suite. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 346ef0d8faad7..5fbeff0e51f8e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,7 @@ environment: SCRIPT: python x.py test && python x.py dist DEPLOY: 1 - MSYS_BITS: 32 - RUST_CONFIGURE_ARGS: --build=i686-pc-windows-msvc + RUST_CONFIGURE_ARGS: --build=i686-pc-windows-msvc --target=i586-pc-windows-msvc SCRIPT: python x.py test && python x.py dist DEPLOY: 1 From baff51c0402c2f80cf48ab677ed00894683dde14 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 16 Jan 2017 18:43:38 -0800 Subject: [PATCH 06/37] travis: Tweak OSX image configuration Somewhere between https://travis-ci.org/rust-lang/rust/jobs/192352185 and https://travis-ci.org/rust-lang/rust/jobs/192440181 it looks like our configuration for a newer OSX image was lost as LLDB has reverted itself back to 350. This fix appeared to work for the libc crate so let's see if we can configure it to work for the rust repo as well. --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index abd0a8fe346f0..ae7c7e06f782e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,6 @@ git: depth: 1 submodules: false -osx_image: xcode8.2 - matrix: include: # Linux builders, all docker images @@ -41,6 +39,7 @@ matrix: RUST_CONFIGURE_ARGS=--build=x86_64-apple-darwin SRC=. os: osx + osx_image: xcode8.2 before_script: &osx_before_script > ulimit -c unlimited install: &osx_install_sccache > @@ -59,6 +58,7 @@ matrix: SRC=. DEPLOY=1 os: osx + osx_image: xcode8.2 before_script: *osx_before_script install: *osx_install_sccache after_failure: *osx_after_failure @@ -67,6 +67,7 @@ matrix: RUST_CONFIGURE_ARGS=--build=x86_64-apple-darwin --disable-rustbuild SRC=. os: osx + osx_image: xcode8.2 before_script: *osx_before_script install: *osx_install_sccache after_failure: *osx_after_failure @@ -76,6 +77,7 @@ matrix: SRC=. DEPLOY=1 os: osx + osx_image: xcode8.2 before_script: *osx_before_script install: *osx_install_sccache after_failure: *osx_after_failure From 6b23cc48dbe7d1035acd912051c271392036a0bd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 16 Jan 2017 14:15:12 -0800 Subject: [PATCH 07/37] travis: Expand the `cross` linux image This expands the `cross` travis matrix entry with a few more targets that our nightlies are building: * x86_64-rumprun-netbsd * arm-unknown-linux-musleabi * arm-unknown-linux-musleabihf * armv7-unknown-linux-musleabihf * mips-unknown-linux-musl * mipsel-unknown-linux-musl This commit doesn't compile custom toolchains like our current cross-image does, but instead compiles musl manually and then compiles libunwind manually (like x86_64) for use for the ARM targets and just uses openwrt toolchains for the mips targets. --- .travis.yml | 2 +- src/bootstrap/cc.rs | 8 +- src/bootstrap/flags.rs | 8 +- .../{arm-android => android}/Dockerfile | 6 +- .../accept-licenses.sh | 0 .../{arm-android => android}/install-ndk.sh | 0 .../{arm-android => android}/install-sdk.sh | 0 .../start-emulator.sh | 0 src/ci/docker/cross/Dockerfile | 60 +++++++--- src/ci/docker/cross/build-arm-musl.sh | 104 ++++++++++++++++++ src/ci/docker/cross/build-rumprun.sh | 39 +++++++ src/ci/docker/dist-arm-linux/Dockerfile | 13 +-- .../dist-armv7-aarch64-linux/Dockerfile | 13 +-- src/ci/docker/dist-freebsd/Dockerfile | 13 +-- src/ci/docker/dist-mips-linux/Dockerfile | 13 +-- src/ci/docker/dist-mips64-linux/Dockerfile | 13 +-- src/ci/docker/dist-powerpc-linux/Dockerfile | 10 +- src/ci/docker/dist-powerpc64-linux/Dockerfile | 13 +-- .../docker/dist-s390x-linux-netbsd/Dockerfile | 13 +-- src/libcompiler_builtins/build.rs | 1 - 20 files changed, 243 insertions(+), 86 deletions(-) rename src/ci/docker/{arm-android => android}/Dockerfile (90%) rename src/ci/docker/{arm-android => android}/accept-licenses.sh (100%) rename src/ci/docker/{arm-android => android}/install-ndk.sh (100%) rename src/ci/docker/{arm-android => android}/install-sdk.sh (100%) rename src/ci/docker/{arm-android => android}/start-emulator.sh (100%) create mode 100755 src/ci/docker/cross/build-arm-musl.sh create mode 100755 src/ci/docker/cross/build-rumprun.sh diff --git a/.travis.yml b/.travis.yml index abd0a8fe346f0..6732a94e313db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ osx_image: xcode8.2 matrix: include: # Linux builders, all docker images - - env: IMAGE=arm-android DEPLOY=1 + - env: IMAGE=android DEPLOY=1 - env: IMAGE=cross DEPLOY=1 - env: IMAGE=dist-arm-linux DEPLOY=1 - env: IMAGE=dist-armv7-aarch64-linux DEPLOY=1 diff --git a/src/bootstrap/cc.rs b/src/bootstrap/cc.rs index aa70e24d95222..54c8194678e61 100644 --- a/src/bootstrap/cc.rs +++ b/src/bootstrap/cc.rs @@ -121,10 +121,14 @@ fn set_compiler(cfg: &mut gcc::Config, } "mips-unknown-linux-musl" => { - cfg.compiler("mips-linux-musl-gcc"); + if cfg.get_compiler().path().to_str() == Some("gcc") { + cfg.compiler("mips-linux-musl-gcc"); + } } "mipsel-unknown-linux-musl" => { - cfg.compiler("mipsel-linux-musl-gcc"); + if cfg.get_compiler().path().to_str() == Some("gcc") { + cfg.compiler("mipsel-linux-musl-gcc"); + } } t if t.contains("musl") => { diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 1be823417d765..c5bbfd89b2787 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -287,8 +287,8 @@ To learn more about a subcommand, run `./x.py -h` build: m.opt_str("build").unwrap_or_else(|| { env::var("BUILD").unwrap() }), - host: m.opt_strs("host"), - target: m.opt_strs("target"), + host: split(m.opt_strs("host")), + target: split(m.opt_strs("target")), config: cfg_file, src: m.opt_str("src").map(PathBuf::from), jobs: m.opt_str("jobs").map(|j| j.parse().unwrap()), @@ -309,3 +309,7 @@ impl Subcommand { } } } + +fn split(s: Vec) -> Vec { + s.iter().flat_map(|s| s.split(',')).map(|s| s.to_string()).collect() +} diff --git a/src/ci/docker/arm-android/Dockerfile b/src/ci/docker/android/Dockerfile similarity index 90% rename from src/ci/docker/arm-android/Dockerfile rename to src/ci/docker/android/Dockerfile index d81666e84262f..e3748af501fb8 100644 --- a/src/ci/docker/arm-android/Dockerfile +++ b/src/ci/docker/android/Dockerfile @@ -53,8 +53,4 @@ ENV RUST_CONFIGURE_ARGS \ # to all the targets above eventually. ENV SCRIPT \ python2.7 ../x.py test --target arm-linux-androideabi && \ - python2.7 ../x.py dist \ - --target arm-linux-androideabi \ - --target armv7-linux-androideabi \ - --target i686-linux-android \ - --target aarch64-linux-android + python2.7 ../x.py dist --target $TARGETS diff --git a/src/ci/docker/arm-android/accept-licenses.sh b/src/ci/docker/android/accept-licenses.sh similarity index 100% rename from src/ci/docker/arm-android/accept-licenses.sh rename to src/ci/docker/android/accept-licenses.sh diff --git a/src/ci/docker/arm-android/install-ndk.sh b/src/ci/docker/android/install-ndk.sh similarity index 100% rename from src/ci/docker/arm-android/install-ndk.sh rename to src/ci/docker/android/install-ndk.sh diff --git a/src/ci/docker/arm-android/install-sdk.sh b/src/ci/docker/android/install-sdk.sh similarity index 100% rename from src/ci/docker/arm-android/install-sdk.sh rename to src/ci/docker/android/install-sdk.sh diff --git a/src/ci/docker/arm-android/start-emulator.sh b/src/ci/docker/android/start-emulator.sh similarity index 100% rename from src/ci/docker/arm-android/start-emulator.sh rename to src/ci/docker/android/start-emulator.sh diff --git a/src/ci/docker/cross/Dockerfile b/src/ci/docker/cross/Dockerfile index 7872397645136..8f947caf2cbf5 100644 --- a/src/ci/docker/cross/Dockerfile +++ b/src/ci/docker/cross/Dockerfile @@ -10,7 +10,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ git \ cmake \ sudo \ - xz-utils + xz-utils \ + zlib1g-dev \ + g++-arm-linux-gnueabi \ + g++-arm-linux-gnueabihf \ + bzip2 \ + patch ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ @@ -21,21 +26,50 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] +WORKDIR /tmp + +COPY build-rumprun.sh /tmp/ +RUN ./build-rumprun.sh + +COPY build-arm-musl.sh /tmp/ +RUN ./build-arm-musl.sh + +# originally from +# https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz2 +RUN mkdir /usr/local/mips-linux-musl +RUN curl -L https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz2 | \ + tar xjf - -C /usr/local/mips-linux-musl --strip-components=2 +RUN for file in /usr/local/mips-linux-musl/bin/mips-openwrt-linux-*; do \ + ln -s $file /usr/local/bin/`basename $file`; \ + done + +# Note that this originally came from: +# https://downloads.openwrt.org/snapshots/trunk/malta/generic/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 +RUN mkdir /usr/local/mipsel-linux-musl +RUN curl -L https://s3.amazonaws.com/rust-lang-ci/libc/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ + tar xjf - -C /usr/local/mipsel-linux-musl --strip-components=2 +RUN for file in /usr/local/mipsel-linux-musl/bin/mipsel-openwrt-linux-*; do \ + ln -s $file /usr/local/bin/`basename $file`; \ + done + ENV TARGETS=asmjs-unknown-emscripten ENV TARGETS=$TARGETS,wasm32-unknown-emscripten +ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd +ENV TARGETS=$TARGETS,mips-unknown-linux-musl +ENV TARGETS=$TARGETS,mipsel-unknown-linux-musl +ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi +ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf +ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf + +ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ + CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc -#ENV TARGETS=$TARGETS,mips-unknown-linux-musl -#ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi -#ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf -#ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf -#ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd +# Suppress some warnings in the openwrt toolchains we downloaded +ENV STAGING_DIR=/tmp ENV RUST_CONFIGURE_ARGS \ --target=$TARGETS \ - --enable-rustbuild - -# Just a smoke test in dist to see if this works for now, we should expand this -# to all the targets above eventually. -ENV SCRIPT \ - python2.7 ../x.py build && \ - python2.7 ../x.py dist --target wasm32-unknown-emscripten + --musl-root-arm=/usr/local/arm-linux-musleabi \ + --musl-root-armhf=/usr/local/arm-linux-musleabihf \ + --musl-root-armv7=/usr/local/armv7-linux-musleabihf +ENV SCRIPT python2.7 ../x.py dist --target $TARGETS diff --git a/src/ci/docker/cross/build-arm-musl.sh b/src/ci/docker/cross/build-arm-musl.sh new file mode 100755 index 0000000000000..989862b1b73b9 --- /dev/null +++ b/src/ci/docker/cross/build-arm-musl.sh @@ -0,0 +1,104 @@ +#!/bin/sh +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +MUSL=1.1.16 + +curl -O https://www.musl-libc.org/releases/musl-$MUSL.tar.gz +tar xf musl-$MUSL.tar.gz +cd musl-$MUSL +CC=arm-linux-gnueabi-gcc \ +CFLAGS="-march=armv6 -marm" \ + ./configure \ + --prefix=/usr/local/arm-linux-musleabi \ + --enable-wrapper=gcc +make -j$(nproc) +make install +cd .. +rm -rf musl-$MUSL + +tar xf musl-$MUSL.tar.gz +cd musl-$MUSL +CC=arm-linux-gnueabihf-gcc \ +CFLAGS="-march=armv6 -marm" \ + ./configure \ + --prefix=/usr/local/arm-linux-musleabihf \ + --enable-wrapper=gcc +make -j$(nproc) +make install +cd .. +rm -rf musl-$MUSL + +tar xf musl-$MUSL.tar.gz +cd musl-$MUSL +CC=arm-linux-gnueabihf-gcc \ +CFLAGS="-march=armv7-a" \ + ./configure \ + --prefix=/usr/local/armv7-linux-musleabihf \ + --enable-wrapper=gcc +make -j$(nproc) +make install +cd .. +rm -rf musl-$MUSL* + +ln -nsf ../arm-linux-musleabi/bin/musl-gcc /usr/local/bin/arm-linux-musleabi-gcc +ln -nsf ../arm-linux-musleabihf/bin/musl-gcc /usr/local/bin/arm-linux-musleabihf-gcc +ln -nsf ../armv7-linux-musleabihf/bin/musl-gcc /usr/local/bin/armv7-linux-musleabihf-gcc + + +curl -L https://github.com/llvm-mirror/llvm/archive/release_39.tar.gz | tar xzf - +curl -L https://github.com/llvm-mirror/libunwind/archive/release_39.tar.gz | tar xzf - + +mkdir libunwind-build +cd libunwind-build +cmake ../libunwind-release_39 \ + -DLLVM_PATH=/tmp/llvm-release_39 \ + -DLIBUNWIND_ENABLE_SHARED=0 \ + -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc \ + -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++ \ + -DCMAKE_C_FLAGS="-march=armv6 -marm" \ + -DCMAKE_CXX_FLAGS="-march=armv6 -marm" +make -j$(nproc) +cp lib/libunwind.a /usr/local/arm-linux-musleabi/lib +cd .. +rm -rf libunwind-build + +mkdir libunwind-build +cd libunwind-build +cmake ../libunwind-release_39 \ + -DLLVM_PATH=/tmp/llvm-release_39 \ + -DLIBUNWIND_ENABLE_SHARED=0 \ + -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \ + -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \ + -DCMAKE_C_FLAGS="-march=armv6 -marm" \ + -DCMAKE_CXX_FLAGS="-march=armv6 -marm" +make -j$(nproc) +cp lib/libunwind.a /usr/local/arm-linux-musleabihf/lib +cd .. +rm -rf libunwind-build + +mkdir libunwind-build +cd libunwind-build +cmake ../libunwind-release_39 \ + -DLLVM_PATH=/tmp/llvm-release_39 \ + -DLIBUNWIND_ENABLE_SHARED=0 \ + -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \ + -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \ + -DCMAKE_C_FLAGS="-march=armv7-a" \ + -DCMAKE_CXX_FLAGS="-march=armv7-a" +make -j$(nproc) +cp lib/libunwind.a /usr/local/armv7-linux-musleabihf/lib +cd .. +rm -rf libunwind-build + +rm -rf libunwind-release_39 +rm -rf llvm-release_39 diff --git a/src/ci/docker/cross/build-rumprun.sh b/src/ci/docker/cross/build-rumprun.sh new file mode 100755 index 0000000000000..d0ef0e55db158 --- /dev/null +++ b/src/ci/docker/cross/build-rumprun.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +hide_output() { + set +x + on_err=" +echo ERROR: An error was encountered with the build. +cat /tmp/build.log +exit 1 +" + trap "$on_err" ERR + bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & + PING_LOOP_PID=$! + $@ &> /tmp/build.log + trap - ERR + kill $PING_LOOP_PID + rm /tmp/build.log + set -x +} + + +git clone https://github.com/rumpkernel/rumprun +cd rumprun +git reset --hard 39a97f37a85e44c69b662f6b97b688fbe892603b +git submodule update --init + +CC=cc hide_output ./build-rr.sh -d /usr/local hw +cd .. +rm -rf rumprun diff --git a/src/ci/docker/dist-arm-linux/Dockerfile b/src/ci/docker/dist-arm-linux/Dockerfile index 1aafc669d1023..072cd2051958b 100644 --- a/src/ci/docker/dist-arm-linux/Dockerfile +++ b/src/ci/docker/dist-arm-linux/Dockerfile @@ -24,11 +24,8 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -ENV RUST_CONFIGURE_ARGS \ - --host=arm-unknown-linux-gnueabi,arm-unknown-linux-gnueabihf -ENV SCRIPT \ - python2.7 ../x.py dist \ - --host arm-unknown-linux-gnueabi \ - --target arm-unknown-linux-gnueabi \ - --host arm-unknown-linux-gnueabihf \ - --target arm-unknown-linux-gnueabihf +ENV HOSTS=arm-unknown-linux-gnueabi +ENV HOSTS=$HOSTS,arm-unknown-linux-gnueabihf + +ENV RUST_CONFIGURE_ARGS --host=$HOSTS +ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile b/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile index 134e2b062ef0b..2ae4725a4bb58 100644 --- a/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile +++ b/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile @@ -24,11 +24,8 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -ENV RUST_CONFIGURE_ARGS \ - --host=armv7-unknown-linux-gnueabihf,aarch64-unknown-linux-gnu -ENV SCRIPT \ - python2.7 ../x.py dist \ - --host armv7-unknown-linux-gnueabihf \ - --target armv7-unknown-linux-gnueabihf \ - --host aarch64-unknown-linux-gnu \ - --target aarch64-unknown-linux-gnu +ENV HOSTS=armv7-unknown-linux-gnueabihf +ENV HOSTS=$HOSTS,aarch64-unknown-linux-gnu + +ENV RUST_CONFIGURE_ARGS --host=$HOSTS +ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/ci/docker/dist-freebsd/Dockerfile b/src/ci/docker/dist-freebsd/Dockerfile index b49396c935c00..4b6db62d38971 100644 --- a/src/ci/docker/dist-freebsd/Dockerfile +++ b/src/ci/docker/dist-freebsd/Dockerfile @@ -35,11 +35,8 @@ ENV \ CC_i686_unknown_freebsd=i686-unknown-freebsd10-gcc \ CXX_i686_unknown_freebsd=i686-unknown-freebsd10-g++ -ENV RUST_CONFIGURE_ARGS \ - --host=x86_64-unknown-freebsd,i686-unknown-freebsd -ENV SCRIPT \ - python2.7 ../x.py dist \ - --host x86_64-unknown-freebsd \ - --target x86_64-unknown-freebsd \ - --host i686-unknown-freebsd \ - --target i686-unknown-freebsd +ENV HOSTS=x86_64-unknown-freebsd +ENV HOSTS=$HOSTS,i686-unknown-freebsd + +ENV RUST_CONFIGURE_ARGS --host=$HOSTS +ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/ci/docker/dist-mips-linux/Dockerfile b/src/ci/docker/dist-mips-linux/Dockerfile index a495cf57dc51c..df189c2580977 100644 --- a/src/ci/docker/dist-mips-linux/Dockerfile +++ b/src/ci/docker/dist-mips-linux/Dockerfile @@ -24,11 +24,8 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -ENV RUST_CONFIGURE_ARGS \ - --host=mips-unknown-linux-gnu,mipsel-unknown-linux-gnu -ENV SCRIPT \ - python2.7 ../x.py dist \ - --host mips-unknown-linux-gnu \ - --target mips-unknown-linux-gnu \ - --host mipsel-unknown-linux-gnu \ - --target mipsel-unknown-linux-gnu +ENV HOSTS=mips-unknown-linux-gnu +ENV HOSTS=$HOSTS,mipsel-unknown-linux-gnu + +ENV RUST_CONFIGURE_ARGS --host=$HOSTS +ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/ci/docker/dist-mips64-linux/Dockerfile b/src/ci/docker/dist-mips64-linux/Dockerfile index bdb634f530392..9152965caee54 100644 --- a/src/ci/docker/dist-mips64-linux/Dockerfile +++ b/src/ci/docker/dist-mips64-linux/Dockerfile @@ -24,11 +24,8 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -ENV RUST_CONFIGURE_ARGS \ - --host=mips64-unknown-linux-gnuabi64,mips64el-unknown-linux-gnuabi64 -ENV SCRIPT \ - python2.7 ../x.py dist \ - --host mips64-unknown-linux-gnuabi64 \ - --target mips64-unknown-linux-gnuabi64 \ - --host mips64el-unknown-linux-gnuabi64 \ - --target mips64el-unknown-linux-gnuabi64 +ENV HOSTS=mips64-unknown-linux-gnuabi64 +ENV HOSTS=$HOSTS,mips64el-unknown-linux-gnuabi64 + +ENV RUST_CONFIGURE_ARGS --host=$HOSTS +ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/ci/docker/dist-powerpc-linux/Dockerfile b/src/ci/docker/dist-powerpc-linux/Dockerfile index 579824dfdb41a..d5f9e5269f13d 100644 --- a/src/ci/docker/dist-powerpc-linux/Dockerfile +++ b/src/ci/docker/dist-powerpc-linux/Dockerfile @@ -23,12 +23,10 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -ENV RUST_CONFIGURE_ARGS \ - --host=powerpc-unknown-linux-gnu -ENV SCRIPT \ - python2.7 ../x.py dist \ - --host powerpc-unknown-linux-gnu \ - --target powerpc-unknown-linux-gnu +ENV HOSTS=powerpc-unknown-linux-gnu + +ENV RUST_CONFIGURE_ARGS --host=$HOSTS +ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS # FIXME(#36150) this will fail the bootstrap. Probably means something bad is # happening! diff --git a/src/ci/docker/dist-powerpc64-linux/Dockerfile b/src/ci/docker/dist-powerpc64-linux/Dockerfile index 33877d4b3e9f1..3b222581bd407 100644 --- a/src/ci/docker/dist-powerpc64-linux/Dockerfile +++ b/src/ci/docker/dist-powerpc64-linux/Dockerfile @@ -29,11 +29,8 @@ ENV \ CC_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-gcc \ CXX_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-g++ -ENV RUST_CONFIGURE_ARGS \ - --host=powerpc64-unknown-linux-gnu,powerpc64le-unknown-linux-gnu -ENV SCRIPT \ - python2.7 ../x.py dist \ - --host powerpc64-unknown-linux-gnu \ - --target powerpc64-unknown-linux-gnu \ - --host powerpc64le-unknown-linux-gnu \ - --target powerpc64le-unknown-linux-gnu +ENV HOSTS=powerpc64-unknown-linux-gnu +ENV HOSTS=$HOSTS,powerpc64le-unknown-linux-gnu + +ENV RUST_CONFIGURE_ARGS --host=$HOSTS +ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/ci/docker/dist-s390x-linux-netbsd/Dockerfile b/src/ci/docker/dist-s390x-linux-netbsd/Dockerfile index a59bc7012cacd..7350b11a69fc0 100644 --- a/src/ci/docker/dist-s390x-linux-netbsd/Dockerfile +++ b/src/ci/docker/dist-s390x-linux-netbsd/Dockerfile @@ -33,11 +33,8 @@ ENV \ CC_x86_64_unknown_netbsd=x86_64-unknown-netbsd-gcc \ CXX_x86_64_unknown_netbsd=x86_64-unknown-netbsd-g++ -ENV RUST_CONFIGURE_ARGS \ - --host=x86_64-unknown-netbsd,s390x-unknown-linux-gnu -ENV SCRIPT \ - python2.7 ../x.py dist \ - --host x86_64-unknown-netbsd \ - --target x86_64-unknown-netbsd \ - --host s390x-unknown-linux-gnu \ - --target s390x-unknown-linux-gnu +ENV HOSTS=x86_64-unknown-netbsd +ENV HOSTS=$HOSTS,s390x-unknown-linux-gnu + +ENV RUST_CONFIGURE_ARGS --host=$HOSTS +ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/libcompiler_builtins/build.rs b/src/libcompiler_builtins/build.rs index ab9a71e1ec6a6..b9421d779b590 100644 --- a/src/libcompiler_builtins/build.rs +++ b/src/libcompiler_builtins/build.rs @@ -107,7 +107,6 @@ fn main() { "apple_versioning.c", "ashldi3.c", "ashrdi3.c", - "clear_cache.c", "clzdi2.c", "clzsi2.c", "cmpdi2.c", From f2d14077439a3037941781b7b53ea4e9ef19f52c Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Tue, 17 Jan 2017 03:14:42 +0000 Subject: [PATCH 08/37] Remove field `tokens_consumed` of `Parser`. --- src/libsyntax/parse/parser.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 167fa78d7e075..9ba6d4d17f794 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -185,7 +185,6 @@ pub struct Parser<'a> { /// the previous token kind prev_token_kind: PrevTokenKind, lookahead_buffer: LookaheadBuffer, - pub tokens_consumed: usize, pub restrictions: Restrictions, pub quote_depth: usize, // not (yet) related to the quasiquoter parsing_token_tree: bool, @@ -282,7 +281,6 @@ impl<'a> Parser<'a> { prev_span: syntax_pos::DUMMY_SP, prev_token_kind: PrevTokenKind::Other, lookahead_buffer: Default::default(), - tokens_consumed: 0, restrictions: Restrictions::empty(), quote_depth: 0, parsing_token_tree: false, @@ -902,7 +900,6 @@ impl<'a> Parser<'a> { }; self.span = next.sp; self.token = next.tok; - self.tokens_consumed += 1; self.expected_tokens.clear(); // check after each token self.check_unknown_macro_variable(); From 375cbd20cfcc9dbf15682bcfc0081ce5ce95567b Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Mon, 9 Jan 2017 01:31:14 -0800 Subject: [PATCH 09/37] Implement `#[proc_macro_attribute]` * Add support for `#[proc_macro]` * Reactivate `proc_macro` feature and gate `#[proc_macro_attribute]` under it * Have `#![feature(proc_macro)]` imply `#![feature(use_extern_macros)]`, error on legacy import of proc macros via `#[macro_use]` --- src/librustc_driver/driver.rs | 1 + src/librustc_metadata/creader.rs | 10 + src/librustc_resolve/lib.rs | 46 +++- src/librustc_resolve/macros.rs | 43 +++- src/libsyntax/ext/expand.rs | 30 ++- src/libsyntax/feature_gate.rs | 60 +++++- src/libsyntax_ext/lib.rs | 2 + src/libsyntax_ext/proc_macro_impl.rs | 58 +++++ src/libsyntax_ext/proc_macro_registrar.rs | 204 ++++++++++++------ .../proc-macro/auxiliary/attr_proc_macro.rs | 23 ++ .../proc-macro/feature-gate-proc_macro.rs | 24 +++ .../proc-macro/macro-use-attr.rs | 22 ++ .../proc-macro-custom-attr-mutex.rs | 24 +++ .../run-pass-fulldeps/proc-macro/attr-args.rs | 24 +++ .../proc-macro/auxiliary/attr-args.rs | 32 +++ src/tools/tidy/src/features.rs | 2 +- 16 files changed, 526 insertions(+), 79 deletions(-) create mode 100644 src/libsyntax_ext/proc_macro_impl.rs create mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs create mode 100644 src/test/compile-fail-fulldeps/proc-macro/feature-gate-proc_macro.rs create mode 100644 src/test/compile-fail-fulldeps/proc-macro/macro-use-attr.rs create mode 100644 src/test/compile-fail-fulldeps/proc-macro/proc-macro-custom-attr-mutex.rs create mode 100644 src/test/run-pass-fulldeps/proc-macro/attr-args.rs create mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 442c139f14c06..f34d1203a3d20 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -677,6 +677,7 @@ pub fn phase_2_configure_and_expand(sess: &Session, should_test: sess.opts.test, ..syntax::ext::expand::ExpansionConfig::default(crate_name.to_string()) }; + let mut ecx = ExtCtxt::new(&sess.parse_sess, cfg, &mut resolver); let err_count = ecx.parse_sess.span_diagnostic.err_count(); diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 8f7b9c24cbf8a..161331b1728bc 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -578,6 +578,7 @@ impl<'a> CrateLoader<'a> { use proc_macro::__internal::Registry; use rustc_back::dynamic_lib::DynamicLibrary; use syntax_ext::deriving::custom::CustomDerive; + use syntax_ext::proc_macro_impl::AttrProcMacro; let path = match dylib { Some(dylib) => dylib, @@ -613,6 +614,15 @@ impl<'a> CrateLoader<'a> { ); self.0.push((Symbol::intern(trait_name), Rc::new(derive))); } + + fn register_attr_proc_macro(&mut self, + name: &str, + expand: fn(TokenStream, TokenStream) -> TokenStream) { + let expand = SyntaxExtension::AttrProcMacro( + Box::new(AttrProcMacro { inner: expand }) + ); + self.0.push((Symbol::intern(name), Rc::new(expand))); + } } let mut my_registrar = MyRegistrar(Vec::new()); diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 56e8c75b859a1..2c5e338563816 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -61,7 +61,7 @@ use syntax::ast::{FnDecl, ForeignItem, ForeignItemKind, Generics}; use syntax::ast::{Item, ItemKind, ImplItem, ImplItemKind}; use syntax::ast::{Local, Mutability, Pat, PatKind, Path}; use syntax::ast::{QSelf, TraitItemKind, TraitRef, Ty, TyKind}; -use syntax::feature_gate::{emit_feature_err, GateIssue}; +use syntax::feature_gate::{feature_err, emit_feature_err, GateIssue}; use syntax_pos::{Span, DUMMY_SP, MultiSpan}; use errors::DiagnosticBuilder; @@ -1123,6 +1123,12 @@ pub struct Resolver<'a> { // Avoid duplicated errors for "name already defined". name_already_seen: FxHashMap, + + // If `#![feature(proc_macro)]` is set + proc_macro_enabled: bool, + + // A set of procedural macros imported by `#[macro_use]` that have already been warned about + warned_proc_macros: FxHashSet, } pub struct ResolverArenas<'a> { @@ -1227,6 +1233,8 @@ impl<'a> Resolver<'a> { invocations.insert(Mark::root(), arenas.alloc_invocation_data(InvocationData::root(graph_root))); + let features = session.features.borrow(); + Resolver { session: session, @@ -1284,7 +1292,9 @@ impl<'a> Resolver<'a> { span: DUMMY_SP, vis: ty::Visibility::Public, }), - use_extern_macros: session.features.borrow().use_extern_macros, + + // `#![feature(proc_macro)]` implies `#[feature(extern_macros)]` + use_extern_macros: features.use_extern_macros || features.proc_macro, exported_macros: Vec::new(), crate_loader: crate_loader, @@ -1296,6 +1306,8 @@ impl<'a> Resolver<'a> { invocations: invocations, name_already_seen: FxHashMap(), whitelisted_legacy_custom_derives: Vec::new(), + proc_macro_enabled: features.proc_macro, + warned_proc_macros: FxHashSet(), } } @@ -1525,6 +1537,8 @@ impl<'a> Resolver<'a> { debug!("(resolving item) resolving {}", name); + self.check_proc_macro_attrs(&item.attrs); + match item.node { ItemKind::Enum(_, ref generics) | ItemKind::Ty(_, ref generics) | @@ -1554,6 +1568,8 @@ impl<'a> Resolver<'a> { walk_list!(this, visit_ty_param_bound, bounds); for trait_item in trait_items { + this.check_proc_macro_attrs(&trait_item.attrs); + match trait_item.node { TraitItemKind::Const(_, ref default) => { // Only impose the restrictions of @@ -1738,6 +1754,7 @@ impl<'a> Resolver<'a> { this.with_self_rib(Def::SelfTy(trait_id, Some(item_def_id)), |this| { this.with_current_self_type(self_type, |this| { for impl_item in impl_items { + this.check_proc_macro_attrs(&impl_item.attrs); this.resolve_visibility(&impl_item.vis); match impl_item.node { ImplItemKind::Const(..) => { @@ -3184,6 +3201,31 @@ impl<'a> Resolver<'a> { let msg = "`self` no longer imports values".to_string(); self.session.add_lint(lint::builtin::LEGACY_IMPORTS, id, span, msg); } + + fn check_proc_macro_attrs(&mut self, attrs: &[ast::Attribute]) { + if self.proc_macro_enabled { return; } + + for attr in attrs { + let maybe_binding = self.builtin_macros.get(&attr.name()).cloned().or_else(|| { + let ident = Ident::with_empty_ctxt(attr.name()); + self.resolve_lexical_macro_path_segment(ident, MacroNS, None).ok() + }); + + if let Some(binding) = maybe_binding { + if let SyntaxExtension::AttrProcMacro(..) = *binding.get_macro(self) { + attr::mark_known(attr); + + let msg = "attribute procedural macros are experimental"; + let feature = "proc_macro"; + + feature_err(&self.session.parse_sess, feature, + attr.span, GateIssue::Language, msg) + .span_note(binding.span, "procedural macro imported here") + .emit(); + } + } + } + } } fn is_struct_like(def: Def) -> bool { diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 403797b6d318e..9b7d6f33a7f3b 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -27,7 +27,7 @@ use syntax::ext::base::{NormalTT, Resolver as SyntaxResolver, SyntaxExtension}; use syntax::ext::expand::{Expansion, mark_tts}; use syntax::ext::hygiene::Mark; use syntax::ext::tt::macro_rules; -use syntax::feature_gate::{emit_feature_err, GateIssue}; +use syntax::feature_gate::{emit_feature_err, GateIssue, is_builtin_attr}; use syntax::fold::{self, Folder}; use syntax::ptr::P; use syntax::symbol::keywords; @@ -183,6 +183,10 @@ impl<'a> base::Resolver for Resolver<'a> { }, None => {} } + + if self.proc_macro_enabled && !is_builtin_attr(&attrs[i]) { + return Some(attrs.remove(i)); + } } None } @@ -373,6 +377,10 @@ impl<'a> Resolver<'a> { let resolution = self.resolve_lexical_macro_path_segment(ident, MacroNS, Some(span)); let (legacy_resolution, resolution) = match (legacy_resolution, resolution) { (Some(legacy_resolution), Ok(resolution)) => (legacy_resolution, resolution), + (Some(MacroBinding::Modern(binding)), Err(_)) => { + self.err_if_macro_use_proc_macro(ident.name, span, binding); + continue + }, _ => continue, }; let (legacy_span, participle) = match legacy_resolution { @@ -469,4 +477,37 @@ impl<'a> Resolver<'a> { self.exported_macros.push(def); } } + + /// Error if `ext` is a Macros 1.1 procedural macro being imported by `#[macro_use]` + fn err_if_macro_use_proc_macro(&mut self, name: Name, use_span: Span, + binding: &NameBinding<'a>) { + use self::SyntaxExtension::*; + + let krate = binding.def().def_id().krate; + + // Plugin-based syntax extensions are exempt from this check + if krate == BUILTIN_MACROS_CRATE { return; } + + let ext = binding.get_macro(self); + + match *ext { + // If `ext` is a procedural macro, check if we've already warned about it + AttrProcMacro(_) | ProcMacro(_) => if !self.warned_proc_macros.insert(name) { return; }, + _ => return, + } + + let warn_msg = match *ext { + AttrProcMacro(_) => "attribute procedural macros cannot be \ + imported with `#[macro_use]`", + ProcMacro(_) => "procedural macros cannot be imported with `#[macro_use]`", + _ => return, + }; + + let crate_name = self.session.cstore.crate_name(krate); + + self.session.struct_span_err(use_span, warn_msg) + .help(&format!("instead, import the procedural macro like any other item: \ + `use {}::{};`", crate_name, name)) + .emit(); + } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 201e8d69494ac..1f7874274f789 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -364,7 +364,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> { kind.expect_from_annotatables(items) } SyntaxExtension::AttrProcMacro(ref mac) => { - let attr_toks = TokenStream::from_tts(tts_for_attr(&attr, &self.cx.parse_sess)); + let attr_toks = TokenStream::from_tts(tts_for_attr_args(&attr, + &self.cx.parse_sess)); + let item_toks = TokenStream::from_tts(tts_for_item(&item, &self.cx.parse_sess)); let tok_result = mac.expand(self.cx, attr.span, attr_toks, item_toks); @@ -640,8 +642,30 @@ fn tts_for_item(item: &Annotatable, parse_sess: &ParseSess) -> Vec { string_to_tts(text, parse_sess) } -fn tts_for_attr(attr: &ast::Attribute, parse_sess: &ParseSess) -> Vec { - string_to_tts(pprust::attr_to_string(attr), parse_sess) +fn tts_for_attr_args(attr: &ast::Attribute, parse_sess: &ParseSess) -> Vec { + use ast::MetaItemKind::*; + use print::pp::Breaks; + use print::pprust::PrintState; + + let token_string = match attr.value.node { + // For `#[foo]`, an empty token + Word => return vec![], + // For `#[foo(bar, baz)]`, returns `(bar, baz)` + List(ref items) => pprust::to_string(|s| { + s.popen()?; + s.commasep(Breaks::Consistent, + &items[..], + |s, i| s.print_meta_list_item(&i))?; + s.pclose() + }), + // For `#[foo = "bar"]`, returns `= "bar"` + NameValue(ref lit) => pprust::to_string(|s| { + s.word_space("=")?; + s.print_literal(lit) + }), + }; + + string_to_tts(token_string, parse_sess) } fn string_to_tts(text: String, parse_sess: &ParseSess) -> Vec { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 90cca3129dcf2..2478ed169cd5e 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -30,7 +30,7 @@ use ast::{self, NodeId, PatKind}; use attr; use codemap::{CodeMap, Spanned}; use syntax_pos::Span; -use errors::{DiagnosticBuilder, Handler}; +use errors::{DiagnosticBuilder, Handler, FatalError}; use visit::{self, FnKind, Visitor}; use parse::ParseSess; use symbol::Symbol; @@ -325,6 +325,9 @@ declare_features! ( // The `unadjusted` ABI. Perma unstable. (active, abi_unadjusted, "1.16.0", None), + // Macros 1.1 + (active, proc_macro, "1.16.0", Some(35900)), + // Allows attributes on struct literal fields. (active, struct_field_attributes, "1.16.0", Some(38814)), ); @@ -377,8 +380,6 @@ declare_features! ( // Allows `..` in tuple (struct) patterns (accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627)), (accepted, item_like_imports, "1.14.0", Some(35120)), - // Macros 1.1 - (accepted, proc_macro, "1.15.0", Some(35900)), ); // (changing above list without updating src/doc/reference.md makes @cmr sad) @@ -446,6 +447,10 @@ pub fn deprecated_attributes() -> Vec<&'static (&'static str, AttributeType, Att BUILTIN_ATTRIBUTES.iter().filter(|a| a.2.is_deprecated()).collect() } +pub fn is_builtin_attr(attr: &ast::Attribute) -> bool { + BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.check_name(builtin_name)) +} + // Attributes that have a special meaning to rustc or rustdoc pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGate)] = &[ // Normal attributes @@ -739,6 +744,16 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG is currently unstable", cfg_fn!(windows_subsystem))), + ("proc_macro_attribute", Normal, Gated(Stability::Unstable, + "proc_macro", + "attribute proc macros are currently unstable", + cfg_fn!(proc_macro))), + + ("rustc_derive_registrar", Normal, Gated(Stability::Unstable, + "rustc_derive_registrar", + "used internally by rustc", + cfg_fn!(rustc_attrs))), + // Crate level attributes ("crate_name", CrateLevel, Ungated), ("crate_type", CrateLevel, Ungated), @@ -1380,6 +1395,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute]) -> Features { let mut features = Features::new(); + let mut feature_checker = MutexFeatureChecker::default(); + for attr in krate_attrs { if !attr.check_name("feature") { continue @@ -1403,6 +1420,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute]) -> F if let Some(&(_, _, _, setter)) = ACTIVE_FEATURES.iter() .find(|& &(n, _, _, _)| name == n) { *(setter(&mut features)) = true; + feature_checker.collect(&features, mi.span); } else if let Some(&(_, _, _)) = REMOVED_FEATURES.iter() .find(|& &(n, _, _)| name == n) { @@ -1419,9 +1437,45 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute]) -> F } } + feature_checker.check(span_handler); + features } +// A collector for mutually-exclusive features and their flag spans +#[derive(Default)] +struct MutexFeatureChecker { + proc_macro: Option, + custom_attribute: Option, +} + +impl MutexFeatureChecker { + // If this method turns out to be a hotspot due to branching, + // the branching can be eliminated by modifying `setter!()` to set these spans + // only for the features that need to be checked for mutual exclusion. + fn collect(&mut self, features: &Features, span: Span) { + if features.proc_macro { + // If self.proc_macro is None, set to Some(span) + self.proc_macro = self.proc_macro.or(Some(span)); + } + + if features.custom_attribute { + self.custom_attribute = self.custom_attribute.or(Some(span)); + } + } + + fn check(self, handler: &Handler) { + if let (Some(pm_span), Some(ca_span)) = (self.proc_macro, self.custom_attribute) { + handler.struct_span_err(pm_span, "Cannot use `#![feature(proc_macro)]` and \ + `#![feature(custom_attribute)] at the same time") + .span_note(ca_span, "`#![feature(custom_attribute)]` declared here") + .emit(); + + panic!(FatalError); + } + } +} + pub fn check_crate(krate: &ast::Crate, sess: &ParseSess, features: &Features, diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index bdec86158a4ec..ebec23d0901a0 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -47,6 +47,8 @@ pub mod proc_macro_registrar; // for custom_derive pub mod deriving; +pub mod proc_macro_impl; + use std::rc::Rc; use syntax::ast; use syntax::ext::base::{MacroExpanderFn, NormalTT, MultiModifier, NamedSyntaxExtension}; diff --git a/src/libsyntax_ext/proc_macro_impl.rs b/src/libsyntax_ext/proc_macro_impl.rs new file mode 100644 index 0000000000000..b454628acb1c0 --- /dev/null +++ b/src/libsyntax_ext/proc_macro_impl.rs @@ -0,0 +1,58 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::panic; + +use errors::FatalError; + +use syntax::codemap::Span; +use syntax::ext::base::*; +use syntax::tokenstream::TokenStream; +use syntax::ext::base; + +use proc_macro::TokenStream as TsShim; +use proc_macro::__internal; + +pub struct AttrProcMacro { + pub inner: fn(TsShim, TsShim) -> TsShim, +} + +impl base::AttrProcMacro for AttrProcMacro { + fn expand<'cx>(&self, + ecx: &'cx mut ExtCtxt, + span: Span, + annotation: TokenStream, + annotated: TokenStream) + -> TokenStream { + let annotation = __internal::token_stream_wrap(annotation); + let annotated = __internal::token_stream_wrap(annotated); + + let res = __internal::set_parse_sess(&ecx.parse_sess, || { + panic::catch_unwind(panic::AssertUnwindSafe(|| (self.inner)(annotation, annotated))) + }); + + match res { + Ok(stream) => __internal::token_stream_inner(stream), + Err(e) => { + let msg = "custom attribute panicked"; + let mut err = ecx.struct_span_fatal(span, msg); + if let Some(s) = e.downcast_ref::() { + err.help(&format!("message: {}", s)); + } + if let Some(s) = e.downcast_ref::<&'static str>() { + err.help(&format!("message: {}", s)); + } + + err.emit(); + panic!(FatalError); + } + } + } +} diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index c93e2c054d240..c8af16e9242f0 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -11,18 +11,20 @@ use std::mem; use errors; + use syntax::ast::{self, Ident, NodeId}; use syntax::codemap::{ExpnInfo, NameAndSpan, MacroAttribute}; use syntax::ext::base::ExtCtxt; use syntax::ext::build::AstBuilder; use syntax::ext::expand::ExpansionConfig; -use syntax::parse::ParseSess; use syntax::fold::Folder; +use syntax::parse::ParseSess; use syntax::ptr::P; use syntax::symbol::Symbol; -use syntax_pos::{Span, DUMMY_SP}; use syntax::visit::{self, Visitor}; +use syntax_pos::{Span, DUMMY_SP}; + use deriving; struct CustomDerive { @@ -32,8 +34,14 @@ struct CustomDerive { attrs: Vec, } -struct CollectCustomDerives<'a> { +struct AttrProcMacro { + function_name: Ident, + span: Span, +} + +struct CollectProcMacros<'a> { derives: Vec, + attr_macros: Vec, in_root: bool, handler: &'a errors::Handler, is_proc_macro_crate: bool, @@ -50,16 +58,17 @@ pub fn modify(sess: &ParseSess, let ecfg = ExpansionConfig::default("proc_macro".to_string()); let mut cx = ExtCtxt::new(sess, ecfg, resolver); - let derives = { - let mut collect = CollectCustomDerives { + let (derives, attr_macros) = { + let mut collect = CollectProcMacros { derives: Vec::new(), + attr_macros: Vec::new(), in_root: true, handler: handler, is_proc_macro_crate: is_proc_macro_crate, is_test_crate: is_test_crate, }; visit::walk_crate(&mut collect, &krate); - collect.derives + (collect.derives, collect.attr_macros) }; if !is_proc_macro_crate { @@ -74,7 +83,7 @@ pub fn modify(sess: &ParseSess, return krate; } - krate.module.items.push(mk_registrar(&mut cx, &derives)); + krate.module.items.push(mk_registrar(&mut cx, &derives, &attr_macros)); if krate.exported_macros.len() > 0 { handler.err("cannot export macro_rules! macros from a `proc-macro` \ @@ -84,7 +93,7 @@ pub fn modify(sess: &ParseSess, return krate } -impl<'a> CollectCustomDerives<'a> { +impl<'a> CollectProcMacros<'a> { fn check_not_pub_in_root(&self, vis: &ast::Visibility, sp: Span) { if self.is_proc_macro_crate && self.in_root && @@ -92,61 +101,11 @@ impl<'a> CollectCustomDerives<'a> { self.handler.span_err(sp, "`proc-macro` crate types cannot \ export any items other than functions \ - tagged with `#[proc_macro_derive]` \ - currently"); + tagged with `#[proc_macro_derive]` currently"); } } -} - -impl<'a> Visitor<'a> for CollectCustomDerives<'a> { - fn visit_item(&mut self, item: &'a ast::Item) { - let mut attrs = item.attrs.iter().filter(|a| a.check_name("proc_macro_derive")); - - // First up, make sure we're checking a bare function. If we're not then - // we're just not interested in this item. - // - // If we find one, try to locate a `#[proc_macro_derive]` attribute on - // it. - match item.node { - ast::ItemKind::Fn(..) => {} - _ => { - // Check for invalid use of proc_macro_derive - if let Some(attr) = attrs.next() { - self.handler.span_err(attr.span(), - "the `#[proc_macro_derive]` \ - attribute may only be used \ - on bare functions"); - return; - } - self.check_not_pub_in_root(&item.vis, item.span); - return visit::walk_item(self, item) - } - } - - let attr = match attrs.next() { - Some(attr) => attr, - None => { - self.check_not_pub_in_root(&item.vis, item.span); - return visit::walk_item(self, item) - } - }; - - if let Some(a) = attrs.next() { - self.handler.span_err(a.span(), "multiple `#[proc_macro_derive]` \ - attributes found"); - } - - if self.is_test_crate { - return; - } - - if !self.is_proc_macro_crate { - self.handler.span_err(attr.span(), - "the `#[proc_macro_derive]` attribute is \ - only usable with crates of the `proc-macro` \ - crate type"); - } + fn collect_custom_derive(&mut self, item: &'a ast::Item, attr: &'a ast::Attribute) { // Once we've located the `#[proc_macro_derive]` attribute, verify // that it's of the form `#[proc_macro_derive(Foo)]` or // `#[proc_macro_derive(Foo, attributes(A, ..))]` @@ -232,6 +191,101 @@ impl<'a> Visitor<'a> for CollectCustomDerives<'a> { }; self.handler.span_err(item.span, msg); } + } + + fn collect_attr_proc_macro(&mut self, item: &'a ast::Item, attr: &'a ast::Attribute) { + if let Some(_) = attr.meta_item_list() { + self.handler.span_err(attr.span, "`#[proc_macro_attribute]` attribute + cannot contain any meta items"); + return; + } + + if self.in_root && item.vis == ast::Visibility::Public { + self.attr_macros.push(AttrProcMacro { + span: item.span, + function_name: item.ident, + }); + } else { + let msg = if !self.in_root { + "functions tagged with `#[proc_macro_attribute]` must \ + currently reside in the root of the crate" + } else { + "functions tagged with `#[proc_macro_attribute]` must be `pub`" + }; + self.handler.span_err(item.span, msg); + } + } +} + +impl<'a> Visitor<'a> for CollectProcMacros<'a> { + fn visit_item(&mut self, item: &'a ast::Item) { + // First up, make sure we're checking a bare function. If we're not then + // we're just not interested in this item. + // + // If we find one, try to locate a `#[proc_macro_derive]` attribute on + // it. + let is_fn = match item.node { + ast::ItemKind::Fn(..) => true, + _ => false, + }; + + let mut found_attr: Option<&'a ast::Attribute> = None; + + for attr in &item.attrs { + if attr.check_name("proc_macro_derive") || attr.check_name("proc_macro_attribute") { + if let Some(prev_attr) = found_attr { + let msg = if attr.name() == prev_attr.name() { + format!("Only one `#[{}]` attribute is allowed on any given function", + attr.name()) + } else { + format!("`#[{}]` and `#[{}]` attributes cannot both be applied \ + to the same function", attr.name(), prev_attr.name()) + }; + + self.handler.struct_span_err(attr.span(), &msg) + .span_note(prev_attr.span(), "Previous attribute here") + .emit(); + + return; + } + + found_attr = Some(attr); + } + } + + let attr = match found_attr { + None => { + self.check_not_pub_in_root(&item.vis, item.span); + return visit::walk_item(self, item); + }, + Some(attr) => attr, + }; + + if !is_fn { + let msg = format!("the `#[{}]` attribute may only be used on bare functions", + attr.name()); + + self.handler.span_err(attr.span(), &msg); + return; + } + + if self.is_test_crate { + return; + } + + if !self.is_proc_macro_crate { + let msg = format!("the `#[{}]` attribute is only usable with crates of the \ + `proc-macro` crate type", attr.name()); + + self.handler.span_err(attr.span(), &msg); + return; + } + + if attr.check_name("proc_macro_derive") { + self.collect_custom_derive(item, attr); + } else if attr.check_name("proc_macro_attribute") { + self.collect_attr_proc_macro(item, attr); + }; visit::walk_item(self, item); } @@ -265,7 +319,8 @@ impl<'a> Visitor<'a> for CollectCustomDerives<'a> { // } // } fn mk_registrar(cx: &mut ExtCtxt, - custom_derives: &[CustomDerive]) -> P { + custom_derives: &[CustomDerive], + custom_attrs: &[AttrProcMacro]) -> P { let eid = cx.codemap().record_expansion(ExpnInfo { call_site: DUMMY_SP, callee: NameAndSpan { @@ -286,25 +341,36 @@ fn mk_registrar(cx: &mut ExtCtxt, let registry = Ident::from_str("Registry"); let registrar = Ident::from_str("registrar"); let register_custom_derive = Ident::from_str("register_custom_derive"); - let stmts = custom_derives.iter().map(|cd| { + let register_attr_proc_macro = Ident::from_str("register_attr_proc_macro"); + + let mut stmts = custom_derives.iter().map(|cd| { let path = cx.path_global(cd.span, vec![cd.function_name]); let trait_name = cx.expr_str(cd.span, cd.trait_name); let attrs = cx.expr_vec_slice( span, cd.attrs.iter().map(|&s| cx.expr_str(cd.span, s)).collect::>() ); - (path, trait_name, attrs) - }).map(|(path, trait_name, attrs)| { let registrar = cx.expr_ident(span, registrar); let ufcs_path = cx.path(span, vec![proc_macro, __internal, registry, register_custom_derive]); - cx.expr_call(span, - cx.expr_path(ufcs_path), - vec![registrar, trait_name, cx.expr_path(path), attrs]) - }).map(|expr| { - cx.stmt_expr(expr) + + cx.stmt_expr(cx.expr_call(span, cx.expr_path(ufcs_path), + vec![registrar, trait_name, cx.expr_path(path), attrs])) + }).collect::>(); + stmts.extend(custom_attrs.iter().map(|ca| { + let name = cx.expr_str(ca.span, ca.function_name.name); + let path = cx.path_global(ca.span, vec![ca.function_name]); + let registrar = cx.expr_ident(ca.span, registrar); + + let ufcs_path = cx.path(span, + vec![proc_macro, __internal, registry, register_attr_proc_macro]); + + cx.stmt_expr(cx.expr_call(span, cx.expr_path(ufcs_path), + vec![registrar, name, cx.expr_path(path)])) + })); + let path = cx.path(span, vec![proc_macro, __internal, registry]); let registrar_path = cx.ty_path(path); let arg_ty = cx.ty_rptr(span, registrar_path, None, ast::Mutability::Mutable); diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs new file mode 100644 index 0000000000000..db0c19e96f821 --- /dev/null +++ b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic +#![feature(proc_macro)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn attr_proc_macro(_: TokenStream, input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/compile-fail-fulldeps/proc-macro/feature-gate-proc_macro.rs b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-proc_macro.rs new file mode 100644 index 0000000000000..7e32800e0f9b8 --- /dev/null +++ b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-proc_macro.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attr_proc_macro.rs +// gate-test-proc_macro +#![feature(use_extern_macros)] + +extern crate attr_proc_macro; +use attr_proc_macro::attr_proc_macro; + +#[attr_proc_macro] +//~^ ERROR: attribute procedural macros are experimental +struct Foo; + +fn main() { + let _ = Foo; +} \ No newline at end of file diff --git a/src/test/compile-fail-fulldeps/proc-macro/macro-use-attr.rs b/src/test/compile-fail-fulldeps/proc-macro/macro-use-attr.rs new file mode 100644 index 0000000000000..76253487b51fc --- /dev/null +++ b/src/test/compile-fail-fulldeps/proc-macro/macro-use-attr.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attr_proc_macro.rs +#![feature(proc_macro)] + +#[macro_use] extern crate attr_proc_macro; + +#[attr_proc_macro] +//~^ ERROR: attribute procedural macros cannot be imported with `#[macro_use]` +struct Foo; + +fn main() { + let _ = Foo; +} diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-custom-attr-mutex.rs b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-custom-attr-mutex.rs new file mode 100644 index 0000000000000..288cab71ff49c --- /dev/null +++ b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-custom-attr-mutex.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attr_proc_macro.rs + +#![feature(proc_macro, custom_attribute)] +//~^ ERROR Cannot use `#![feature(proc_macro)]` and `#![feature(custom_attribute)] at the same time + +extern crate attr_proc_macro; +use attr_proc_macro::attr_proc_macro; + +#[attr_proc_macro] +fn foo() {} + +fn main() { + foo(); +} diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-args.rs b/src/test/run-pass-fulldeps/proc-macro/attr-args.rs new file mode 100644 index 0000000000000..d28d75d81a2fb --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/attr-args.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attr-args.rs + +#![allow(warnings)] +#![feature(proc_macro)] + +extern crate attr_args; +use attr_args::attr_with_args; + +#[attr_with_args(text = "Hello, world!")] +fn foo() {} + +fn main() { + assert_eq!(foo(), "Hello, world!"); +} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs new file mode 100644 index 0000000000000..6e1eb395a0a19 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +#![feature(proc_macro)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn attr_with_args(args: TokenStream, input: TokenStream) -> TokenStream { + let args = args.to_string(); + + assert_eq!(args, r#"( text = "Hello, world!" )"#); + + let input = input.to_string(); + + assert_eq!(input, "fn foo ( ) { }"); + + r#" + fn foo() -> &'static str { "Hello, world!" } + "#.parse().unwrap() +} diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index b0da6647eb900..9df3e25494342 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -172,7 +172,7 @@ pub fn check(path: &Path, bad: &mut bool) { "use_extern_macros", "staged_api", "const_indexing", "unboxed_closures", "stmt_expr_attributes", "cfg_target_thread_local", "unwind_attributes", - "inclusive_range_syntax" + "inclusive_range_syntax", "proc_macro" ]; // Only check the number of lang features. From 68439614bad206570f0958fc672a3e11cccebf53 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Mon, 16 Jan 2017 17:59:11 -0800 Subject: [PATCH 10/37] Fix `feature_gate::find_lang_feature_issue()` to not use `unwrap()` --- src/libsyntax/feature_gate.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 2478ed169cd5e..66c66ad8940db 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -896,9 +896,10 @@ fn find_lang_feature_issue(feature: &str) -> Option { issue } else { // search in Accepted or Removed features - ACCEPTED_FEATURES.iter().chain(REMOVED_FEATURES.iter()) - .find(|t| t.0 == feature) - .unwrap().2 + match ACCEPTED_FEATURES.iter().chain(REMOVED_FEATURES).find(|t| t.0 == feature) { + Some(&(_, _, issue)) => issue, + None => panic!("Feature `{}` is not declared anywhere", feature), + } } } From 04ecee158c2c56f4a6d81ad17ac3547848ec1e4c Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Sun, 15 Jan 2017 22:58:17 -0800 Subject: [PATCH 11/37] Move "completed feature gate checking" pass to after "name resolution" pass so proc-macro-attribute feature gate check can use resolve --- src/librustc_driver/driver.rs | 22 +++++++++---------- src/test/compile-fail/const-fn-stability.rs | 3 +++ .../compile-fail/feature-gate-no-debug.rs | 2 ++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index f34d1203a3d20..d8c68c340b68f 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -737,17 +737,6 @@ pub fn phase_2_configure_and_expand(sess: &Session, "checking for inline asm in case the target doesn't support it", || no_asm::check_crate(sess, &krate)); - // Needs to go *after* expansion to be able to check the results of macro expansion. - time(time_passes, "complete gated feature checking", || { - sess.track_errors(|| { - syntax::feature_gate::check_crate(&krate, - &sess.parse_sess, - &sess.features.borrow(), - &attributes, - sess.opts.unstable_features); - }) - })?; - time(sess.time_passes(), "early lint checks", || lint::check_ast_crate(sess, &krate)); @@ -765,6 +754,17 @@ pub fn phase_2_configure_and_expand(sess: &Session, Ok(()) })?; + // Needs to go *after* expansion to be able to check the results of macro expansion. + time(time_passes, "complete gated feature checking", || { + sess.track_errors(|| { + syntax::feature_gate::check_crate(&krate, + &sess.parse_sess, + &sess.features.borrow(), + &attributes, + sess.opts.unstable_features); + }) + })?; + // Lower ast -> hir. let hir_forest = time(sess.time_passes(), "lowering ast -> hir", || { let hir_crate = lower_crate(sess, &krate, &mut resolver); diff --git a/src/test/compile-fail/const-fn-stability.rs b/src/test/compile-fail/const-fn-stability.rs index 436244525e1c2..d093364497a92 100644 --- a/src/test/compile-fail/const-fn-stability.rs +++ b/src/test/compile-fail/const-fn-stability.rs @@ -16,7 +16,9 @@ const fn foo() -> usize { 0 } //~ ERROR const fn is unstable trait Foo { const fn foo() -> u32; //~ ERROR const fn is unstable + //~| ERROR trait fns cannot be declared const const fn bar() -> u32 { 0 } //~ ERROR const fn is unstable + //~| ERROR trait fns cannot be declared const } impl Foo { @@ -25,6 +27,7 @@ impl Foo { impl Foo for u32 { const fn foo() -> u32 { 0 } //~ ERROR const fn is unstable + //~| ERROR trait fns cannot be declared const } static FOO: usize = foo(); diff --git a/src/test/compile-fail/feature-gate-no-debug.rs b/src/test/compile-fail/feature-gate-no-debug.rs index e185056026c3c..9815db6550d66 100644 --- a/src/test/compile-fail/feature-gate-no-debug.rs +++ b/src/test/compile-fail/feature-gate-no-debug.rs @@ -8,5 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(deprecated)] + #[no_debug] //~ ERROR the `#[no_debug]` attribute is fn main() {} From 6466f55ebca18e3795800d8d606622d36f6ee763 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Tue, 17 Jan 2017 01:14:53 +0000 Subject: [PATCH 12/37] Give the `StringReader` a `sess: &ParseSess`. --- src/librustc/hir/print.rs | 13 ++- src/librustc_driver/pretty.rs | 8 +- src/librustc_save_analysis/span_utils.rs | 3 +- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/parse/lexer/comments.rs | 9 +-- src/libsyntax/parse/lexer/mod.rs | 92 +++++++++++----------- src/libsyntax/parse/lexer/unicode_chars.rs | 6 +- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/print/pprust.rs | 21 ++--- 9 files changed, 68 insertions(+), 88 deletions(-) diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index c06c53810d753..c0818f052866e 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -13,6 +13,7 @@ pub use self::AnnNode::*; use syntax::abi::Abi; use syntax::ast; use syntax::codemap::{CodeMap, Spanned}; +use syntax::parse::ParseSess; use syntax::parse::lexer::comments; use syntax::print::pp::{self, break_offset, word, space, hardbreak}; use syntax::print::pp::{Breaks, eof}; @@ -21,7 +22,6 @@ use syntax::print::pprust::{self as ast_pp, PrintState}; use syntax::ptr::P; use syntax::symbol::keywords; use syntax_pos::{self, BytePos}; -use errors; use hir; use hir::{PatKind, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; @@ -116,7 +116,7 @@ pub const default_columns: usize = 78; /// it can scan the input text for comments and literals to /// copy forward. pub fn print_crate<'a>(cm: &'a CodeMap, - span_diagnostic: &errors::Handler, + sess: &ParseSess, krate: &hir::Crate, filename: String, input: &mut Read, @@ -124,8 +124,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap, ann: &'a PpAnn, is_expanded: bool) -> io::Result<()> { - let mut s = State::new_from_input(cm, span_diagnostic, filename, input, - out, ann, is_expanded); + let mut s = State::new_from_input(cm, sess, filename, input, out, ann, is_expanded); // When printing the AST, we sometimes need to inject `#[no_std]` here. // Since you can't compile the HIR, it's not necessary. @@ -137,16 +136,14 @@ pub fn print_crate<'a>(cm: &'a CodeMap, impl<'a> State<'a> { pub fn new_from_input(cm: &'a CodeMap, - span_diagnostic: &errors::Handler, + sess: &ParseSess, filename: String, input: &mut Read, out: Box, ann: &'a PpAnn, is_expanded: bool) -> State<'a> { - let (cmnts, lits) = comments::gather_comments_and_literals(span_diagnostic, - filename, - input); + let (cmnts, lits) = comments::gather_comments_and_literals(sess, filename, input); State::new(cm, out, diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index afacfb6e3f9fd..3c8a529bdaee8 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -838,7 +838,7 @@ pub fn print_after_parsing(sess: &Session, debug!("pretty printing source code {:?}", s); let sess = annotation.sess(); pprust::print_crate(sess.codemap(), - sess.diagnostic(), + &sess.parse_sess, krate, src_name.to_string(), &mut rdr, @@ -896,7 +896,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, debug!("pretty printing source code {:?}", s); let sess = annotation.sess(); pprust::print_crate(sess.codemap(), - sess.diagnostic(), + &sess.parse_sess, krate, src_name.to_string(), &mut rdr, @@ -920,7 +920,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, debug!("pretty printing source code {:?}", s); let sess = annotation.sess(); pprust_hir::print_crate(sess.codemap(), - sess.diagnostic(), + &sess.parse_sess, krate, src_name.to_string(), &mut rdr, @@ -945,7 +945,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, let sess = annotation.sess(); let ast_map = annotation.ast_map().expect("--unpretty missing HIR map"); let mut pp_state = pprust_hir::State::new_from_input(sess.codemap(), - sess.diagnostic(), + &sess.parse_sess, src_name.to_string(), &mut rdr, box out, diff --git a/src/librustc_save_analysis/span_utils.rs b/src/librustc_save_analysis/span_utils.rs index 448bb2e761749..ebfea90527cd0 100644 --- a/src/librustc_save_analysis/span_utils.rs +++ b/src/librustc_save_analysis/span_utils.rs @@ -85,8 +85,7 @@ impl<'a> SpanUtils<'a> { let filemap = self.sess .codemap() .new_filemap(String::from(""), None, self.snippet(span)); - let s = self.sess; - lexer::StringReader::new(s.diagnostic(), filemap) + lexer::StringReader::new(&self.sess.parse_sess, filemap) } fn span_to_tts(&self, span: Span) -> Vec { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 201e8d69494ac..4b9b6518b4800 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -648,7 +648,7 @@ fn string_to_tts(text: String, parse_sess: &ParseSess) -> Vec { let filemap = parse_sess.codemap() .new_filemap(String::from(""), None, text); - let lexer = lexer::StringReader::new(&parse_sess.span_diagnostic, filemap); + let lexer = lexer::StringReader::new(parse_sess, filemap); let mut parser = Parser::new(parse_sess, Box::new(lexer), None, false); panictry!(parser.parse_all_token_trees()) } diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index ba83a55ea7937..8c94cf67bf6e6 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -13,11 +13,10 @@ pub use self::CommentStyle::*; use ast; use codemap::CodeMap; use syntax_pos::{BytePos, CharPos, Pos}; -use errors; use parse::lexer::is_block_doc_comment; use parse::lexer::{StringReader, TokenAndSpan}; use parse::lexer::{is_pattern_whitespace, Reader}; -use parse::lexer; +use parse::{lexer, ParseSess}; use print::pprust; use str::char_at; @@ -346,16 +345,14 @@ pub struct Literal { // it appears this function is called only from pprust... that's // probably not a good thing. -pub fn gather_comments_and_literals(span_diagnostic: &errors::Handler, - path: String, - srdr: &mut Read) +pub fn gather_comments_and_literals(sess: &ParseSess, path: String, srdr: &mut Read) -> (Vec, Vec) { let mut src = Vec::new(); srdr.read_to_end(&mut src).unwrap(); let src = String::from_utf8(src).unwrap(); let cm = CodeMap::new(); let filemap = cm.new_filemap(path, None, src); - let mut rdr = lexer::StringReader::new_raw(span_diagnostic, filemap); + let mut rdr = lexer::StringReader::new_raw(sess, filemap); let mut comments: Vec = Vec::new(); let mut literals: Vec = Vec::new(); diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 818742e4492f2..f1cb81a4c7de5 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -11,9 +11,9 @@ use ast::{self, Ident}; use syntax_pos::{self, BytePos, CharPos, Pos, Span}; use codemap::CodeMap; -use errors::{FatalError, Handler, DiagnosticBuilder}; +use errors::{FatalError, DiagnosticBuilder}; use ext::tt::transcribe::tt_next_token; -use parse::token; +use parse::{token, ParseSess}; use str::char_at; use symbol::{Symbol, keywords}; use std_unicode::property::Pattern_White_Space; @@ -82,7 +82,7 @@ impl Default for TokenAndSpan { } pub struct StringReader<'a> { - pub span_diagnostic: &'a Handler, + pub sess: &'a ParseSess, /// The absolute offset within the codemap of the next character to read pub next_pos: BytePos, /// The absolute offset within the codemap of the current character @@ -181,27 +181,22 @@ impl<'a> Reader for TtReader<'a> { impl<'a> StringReader<'a> { /// For comments.rs, which hackily pokes into next_pos and ch - pub fn new_raw<'b>(span_diagnostic: &'b Handler, - filemap: Rc) - -> StringReader<'b> { - let mut sr = StringReader::new_raw_internal(span_diagnostic, filemap); + pub fn new_raw<'b>(sess: &'a ParseSess, filemap: Rc) -> Self { + let mut sr = StringReader::new_raw_internal(sess, filemap); sr.bump(); sr } - fn new_raw_internal<'b>(span_diagnostic: &'b Handler, - filemap: Rc) - -> StringReader<'b> { + fn new_raw_internal(sess: &'a ParseSess, filemap: Rc) -> Self { if filemap.src.is_none() { - span_diagnostic.bug(&format!("Cannot lex filemap \ - without source: {}", - filemap.name)[..]); + sess.span_diagnostic.bug(&format!("Cannot lex filemap without source: {}", + filemap.name)); } let source_text = (*filemap.src.as_ref().unwrap()).clone(); StringReader { - span_diagnostic: span_diagnostic, + sess: sess, next_pos: filemap.start_pos, pos: filemap.start_pos, col: CharPos(0), @@ -217,10 +212,8 @@ impl<'a> StringReader<'a> { } } - pub fn new<'b>(span_diagnostic: &'b Handler, - filemap: Rc) - -> StringReader<'b> { - let mut sr = StringReader::new_raw(span_diagnostic, filemap); + pub fn new(sess: &'a ParseSess, filemap: Rc) -> Self { + let mut sr = StringReader::new_raw(sess, filemap); if let Err(_) = sr.advance_token() { sr.emit_fatal_errors(); panic!(FatalError); @@ -234,12 +227,12 @@ impl<'a> StringReader<'a> { /// Report a fatal lexical error with a given span. pub fn fatal_span(&self, sp: Span, m: &str) -> FatalError { - self.span_diagnostic.span_fatal(sp, m) + self.sess.span_diagnostic.span_fatal(sp, m) } /// Report a lexical error with a given span. pub fn err_span(&self, sp: Span, m: &str) { - self.span_diagnostic.span_err(sp, m) + self.sess.span_diagnostic.span_err(sp, m) } @@ -274,7 +267,7 @@ impl<'a> StringReader<'a> { for c in c.escape_default() { m.push(c) } - self.span_diagnostic.struct_span_fatal(syntax_pos::mk_sp(from_pos, to_pos), &m[..]) + self.sess.span_diagnostic.struct_span_fatal(syntax_pos::mk_sp(from_pos, to_pos), &m[..]) } /// Report a lexical error spanning [`from_pos`, `to_pos`), appending an @@ -298,7 +291,7 @@ impl<'a> StringReader<'a> { for c in c.escape_default() { m.push(c) } - self.span_diagnostic.struct_span_err(syntax_pos::mk_sp(from_pos, to_pos), &m[..]) + self.sess.span_diagnostic.struct_span_err(syntax_pos::mk_sp(from_pos, to_pos), &m[..]) } /// Report a lexical error spanning [`from_pos`, `to_pos`), appending the @@ -503,9 +496,8 @@ impl<'a> StringReader<'a> { fn scan_comment(&mut self) -> Option { if let Some(c) = self.ch { if c.is_whitespace() { - self.span_diagnostic.span_err(syntax_pos::mk_sp(self.pos, self.pos), - "called consume_any_line_comment, but there \ - was whitespace"); + let msg = "called consume_any_line_comment, but there was whitespace"; + self.sess.span_diagnostic.span_err(syntax_pos::mk_sp(self.pos, self.pos), msg); } } @@ -875,7 +867,7 @@ impl<'a> StringReader<'a> { self.scan_unicode_escape(delim) && !ascii_only } else { let span = syntax_pos::mk_sp(start, self.pos); - self.span_diagnostic + self.sess.span_diagnostic .struct_span_err(span, "incorrect unicode escape sequence") .span_help(span, "format of unicode escape sequences is \ @@ -1701,35 +1693,41 @@ fn ident_continue(c: Option) -> bool { mod tests { use super::*; - use ast::Ident; + use ast::{Ident, CrateConfig}; use symbol::Symbol; use syntax_pos::{BytePos, Span, NO_EXPANSION}; use codemap::CodeMap; use errors; + use feature_gate::UnstableFeatures; use parse::token; + use std::cell::RefCell; use std::io; use std::rc::Rc; - fn mk_sh(cm: Rc) -> errors::Handler { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()), - Some(cm)); - errors::Handler::with_emitter(true, false, Box::new(emitter)) + fn mk_sess(cm: Rc) -> ParseSess { + let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()), Some(cm.clone())); + ParseSess { + span_diagnostic: errors::Handler::with_emitter(true, false, Box::new(emitter)), + unstable_features: UnstableFeatures::from_environment(), + config: CrateConfig::new(), + included_mod_stack: RefCell::new(Vec::new()), + code_map: cm, + } } // open a string reader for the given string fn setup<'a>(cm: &CodeMap, - span_handler: &'a errors::Handler, + sess: &'a ParseSess, teststr: String) -> StringReader<'a> { let fm = cm.new_filemap("zebra.rs".to_string(), None, teststr); - StringReader::new(span_handler, fm) + StringReader::new(sess, fm) } #[test] fn t1() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); let mut string_reader = setup(&cm, &sh, "/* my source file */ fn main() { println!(\"zebra\"); }\n" @@ -1781,7 +1779,7 @@ mod tests { #[test] fn doublecolonparsing() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); check_tokenization(setup(&cm, &sh, "a b".to_string()), vec![mk_ident("a"), token::Whitespace, mk_ident("b")]); } @@ -1789,7 +1787,7 @@ mod tests { #[test] fn dcparsing_2() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); check_tokenization(setup(&cm, &sh, "a::b".to_string()), vec![mk_ident("a"), token::ModSep, mk_ident("b")]); } @@ -1797,7 +1795,7 @@ mod tests { #[test] fn dcparsing_3() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); check_tokenization(setup(&cm, &sh, "a ::b".to_string()), vec![mk_ident("a"), token::Whitespace, token::ModSep, mk_ident("b")]); } @@ -1805,7 +1803,7 @@ mod tests { #[test] fn dcparsing_4() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); check_tokenization(setup(&cm, &sh, "a:: b".to_string()), vec![mk_ident("a"), token::ModSep, token::Whitespace, mk_ident("b")]); } @@ -1813,7 +1811,7 @@ mod tests { #[test] fn character_a() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); assert_eq!(setup(&cm, &sh, "'a'".to_string()).next_token().tok, token::Literal(token::Char(Symbol::intern("a")), None)); } @@ -1821,7 +1819,7 @@ mod tests { #[test] fn character_space() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); assert_eq!(setup(&cm, &sh, "' '".to_string()).next_token().tok, token::Literal(token::Char(Symbol::intern(" ")), None)); } @@ -1829,7 +1827,7 @@ mod tests { #[test] fn character_escaped() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); assert_eq!(setup(&cm, &sh, "'\\n'".to_string()).next_token().tok, token::Literal(token::Char(Symbol::intern("\\n")), None)); } @@ -1837,7 +1835,7 @@ mod tests { #[test] fn lifetime_name() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); assert_eq!(setup(&cm, &sh, "'abc".to_string()).next_token().tok, token::Lifetime(Ident::from_str("'abc"))); } @@ -1845,7 +1843,7 @@ mod tests { #[test] fn raw_string() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); assert_eq!(setup(&cm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string()) .next_token() .tok, @@ -1855,7 +1853,7 @@ mod tests { #[test] fn literal_suffixes() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); macro_rules! test { ($input: expr, $tok_type: ident, $tok_contents: expr) => {{ assert_eq!(setup(&cm, &sh, format!("{}suffix", $input)).next_token().tok, @@ -1899,7 +1897,7 @@ mod tests { #[test] fn nested_block_comments() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); let mut lexer = setup(&cm, &sh, "/* /* */ */'a'".to_string()); match lexer.next_token().tok { token::Comment => {} @@ -1912,7 +1910,7 @@ mod tests { #[test] fn crlf_comments() { let cm = Rc::new(CodeMap::new()); - let sh = mk_sh(cm.clone()); + let sh = mk_sess(cm.clone()); let mut lexer = setup(&cm, &sh, "// test\r\n/// test\r\n".to_string()); let comment = lexer.next_token(); assert_eq!(comment.tok, token::Comment); diff --git a/src/libsyntax/parse/lexer/unicode_chars.rs b/src/libsyntax/parse/lexer/unicode_chars.rs index 1e08b20b7e1f4..6da3e5de75cdc 100644 --- a/src/libsyntax/parse/lexer/unicode_chars.rs +++ b/src/libsyntax/parse/lexer/unicode_chars.rs @@ -243,10 +243,8 @@ pub fn check_for_substitution<'a>(reader: &StringReader<'a>, err.span_help(span, &msg); }, None => { - reader - .span_diagnostic - .span_bug_no_panic(span, - &format!("substitution character not found for '{}'", ch)); + let msg = format!("substitution character not found for '{}'", ch); + reader.sess.span_diagnostic.span_bug_no_panic(span, &msg); } } }); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 32b61a88ac17f..74b313ba395a3 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -223,7 +223,7 @@ pub fn filemap_to_tts(sess: &ParseSess, filemap: Rc) -> Vec { // it appears to me that the cfg doesn't matter here... indeed, // parsing tt's probably shouldn't require a parser at all. - let srdr = lexer::StringReader::new(&sess.span_diagnostic, filemap); + let srdr = lexer::StringReader::new(sess, filemap); let mut p1 = Parser::new(sess, Box::new(srdr), None, false); panictry!(p1.parse_all_token_trees()) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ff77732f5354c..33b4636ce0899 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -18,10 +18,9 @@ use util::parser::AssocOp; use attr; use codemap::{self, CodeMap}; use syntax_pos::{self, BytePos}; -use errors; use parse::token::{self, BinOpToken, Token}; use parse::lexer::comments; -use parse; +use parse::{self, ParseSess}; use print::pp::{self, break_offset, word, space, zerobreak, hardbreak}; use print::pp::{Breaks, eof}; use print::pp::Breaks::{Consistent, Inconsistent}; @@ -101,20 +100,15 @@ pub const DEFAULT_COLUMNS: usize = 78; /// it can scan the input text for comments and literals to /// copy forward. pub fn print_crate<'a>(cm: &'a CodeMap, - span_diagnostic: &errors::Handler, + sess: &ParseSess, krate: &ast::Crate, filename: String, input: &mut Read, out: Box, ann: &'a PpAnn, is_expanded: bool) -> io::Result<()> { - let mut s = State::new_from_input(cm, - span_diagnostic, - filename, - input, - out, - ann, - is_expanded); + let mut s = State::new_from_input(cm, sess, filename, input, out, ann, is_expanded); + if is_expanded && !std_inject::injected_crate_name(krate).is_none() { // We need to print `#![no_std]` (and its feature gate) so that // compiling pretty-printed source won't inject libstd again. @@ -140,16 +134,13 @@ pub fn print_crate<'a>(cm: &'a CodeMap, impl<'a> State<'a> { pub fn new_from_input(cm: &'a CodeMap, - span_diagnostic: &errors::Handler, + sess: &ParseSess, filename: String, input: &mut Read, out: Box, ann: &'a PpAnn, is_expanded: bool) -> State<'a> { - let (cmnts, lits) = comments::gather_comments_and_literals( - span_diagnostic, - filename, - input); + let (cmnts, lits) = comments::gather_comments_and_literals(sess, filename, input); State::new( cm, From de46b247585999ae70674f1fa0543d62f2889c7f Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Thu, 12 Jan 2017 23:32:00 +0000 Subject: [PATCH 13/37] Introduce `string_reader.parse_all_token_trees()`. --- src/librustc_save_analysis/span_utils.rs | 10 +- src/libsyntax/ext/expand.rs | 10 +- src/libsyntax/parse/lexer/comments.rs | 6 +- src/libsyntax/parse/lexer/mod.rs | 44 +++++++- src/libsyntax/parse/lexer/tokentrees.rs | 138 +++++++++++++++++++++++ src/libsyntax/parse/mod.rs | 11 +- 6 files changed, 192 insertions(+), 27 deletions(-) create mode 100644 src/libsyntax/parse/lexer/tokentrees.rs diff --git a/src/librustc_save_analysis/span_utils.rs b/src/librustc_save_analysis/span_utils.rs index ebfea90527cd0..89525b27ed36a 100644 --- a/src/librustc_save_analysis/span_utils.rs +++ b/src/librustc_save_analysis/span_utils.rs @@ -17,9 +17,9 @@ use std::env; use std::path::Path; use syntax::ast; -use syntax::parse::lexer::{self, Reader, StringReader}; +use syntax::parse::filemap_to_tts; +use syntax::parse::lexer::{self, StringReader}; use syntax::parse::token::{self, Token}; -use syntax::parse::parser::Parser; use syntax::symbol::keywords; use syntax::tokenstream::TokenTree; use syntax_pos::*; @@ -89,9 +89,9 @@ impl<'a> SpanUtils<'a> { } fn span_to_tts(&self, span: Span) -> Vec { - let srdr = self.retokenise_span(span); - let mut p = Parser::new(&self.sess.parse_sess, Box::new(srdr), None, false); - p.parse_all_token_trees().expect("Couldn't re-parse span") + let filename = String::from(""); + let filemap = self.sess.codemap().new_filemap(filename, None, self.snippet(span)); + filemap_to_tts(&self.sess.parse_sess, filemap) } // Re-parses a path and returns the span for the last identifier in the path diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 4b9b6518b4800..ca4b2caaf552e 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -21,7 +21,7 @@ use ext::base::*; use feature_gate::{self, Features}; use fold; use fold::*; -use parse::{ParseSess, DirectoryOwnership, PResult, lexer}; +use parse::{ParseSess, DirectoryOwnership, PResult, filemap_to_tts}; use parse::parser::Parser; use parse::token; use print::pprust; @@ -645,12 +645,8 @@ fn tts_for_attr(attr: &ast::Attribute, parse_sess: &ParseSess) -> Vec } fn string_to_tts(text: String, parse_sess: &ParseSess) -> Vec { - let filemap = parse_sess.codemap() - .new_filemap(String::from(""), None, text); - - let lexer = lexer::StringReader::new(parse_sess, filemap); - let mut parser = Parser::new(parse_sess, Box::new(lexer), None, false); - panictry!(parser.parse_all_token_trees()) + let filename = String::from(""); + filemap_to_tts(parse_sess, parse_sess.codemap().new_filemap(filename, None, text)) } impl<'a, 'b> Folder for InvocationCollector<'a, 'b> { diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 8c94cf67bf6e6..c97b8ddf91972 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -13,10 +13,8 @@ pub use self::CommentStyle::*; use ast; use codemap::CodeMap; use syntax_pos::{BytePos, CharPos, Pos}; -use parse::lexer::is_block_doc_comment; -use parse::lexer::{StringReader, TokenAndSpan}; -use parse::lexer::{is_pattern_whitespace, Reader}; -use parse::{lexer, ParseSess}; +use parse::lexer::{is_block_doc_comment, is_pattern_whitespace}; +use parse::lexer::{self, ParseSess, StringReader, TokenAndSpan}; use print::pprust; use str::char_at; diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index f1cb81a4c7de5..6c6161998d711 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -26,6 +26,7 @@ use std::rc::Rc; pub use ext::tt::transcribe::{TtReader, new_tt_reader}; pub mod comments; +mod tokentrees; mod unicode_chars; pub trait Reader { @@ -105,9 +106,44 @@ pub struct StringReader<'a> { // cache a direct reference to the source text, so that we don't have to // retrieve it via `self.filemap.src.as_ref().unwrap()` all the time. source_text: Rc, + /// Stack of open delimiters and their spans. Used for error message. + token: token::Token, + span: Span, + open_braces: Vec<(token::DelimToken, Span)>, } -impl<'a> Reader for StringReader<'a> { +impl<'a> StringReader<'a> { + fn next_token(&mut self) -> TokenAndSpan where Self: Sized { + let res = self.try_next_token(); + self.unwrap_or_abort(res) + } + fn unwrap_or_abort(&mut self, res: Result) -> TokenAndSpan { + match res { + Ok(tok) => tok, + Err(_) => { + self.emit_fatal_errors(); + panic!(FatalError); + } + } + } + fn try_real_token(&mut self) -> Result { + let mut t = self.try_next_token()?; + loop { + match t.tok { + token::Whitespace | token::Comment | token::Shebang(_) => { + t = self.try_next_token()?; + } + _ => break, + } + } + self.token = t.tok.clone(); + self.span = t.sp; + Ok(t) + } + pub fn real_token(&mut self) -> TokenAndSpan { + let res = self.try_real_token(); + self.unwrap_or_abort(res) + } fn is_eof(&self) -> bool { if self.ch.is_none() { return true; @@ -131,9 +167,6 @@ impl<'a> Reader for StringReader<'a> { fn fatal(&self, m: &str) -> FatalError { self.fatal_span(self.peek_span, m) } - fn err(&self, m: &str) { - self.err_span(self.peek_span, m) - } fn emit_fatal_errors(&mut self) { for err in &mut self.fatal_errs { err.emit(); @@ -209,6 +242,9 @@ impl<'a> StringReader<'a> { peek_span: syntax_pos::DUMMY_SP, source_text: source_text, fatal_errs: Vec::new(), + token: token::Eof, + span: syntax_pos::DUMMY_SP, + open_braces: Vec::new(), } } diff --git a/src/libsyntax/parse/lexer/tokentrees.rs b/src/libsyntax/parse/lexer/tokentrees.rs new file mode 100644 index 0000000000000..7b6f00e0e8265 --- /dev/null +++ b/src/libsyntax/parse/lexer/tokentrees.rs @@ -0,0 +1,138 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use print::pprust::token_to_string; +use parse::lexer::StringReader; +use parse::{token, PResult}; +use syntax_pos::Span; +use tokenstream::{Delimited, TokenTree}; + +use std::rc::Rc; + +impl<'a> StringReader<'a> { + // Parse a stream of tokens into a list of `TokenTree`s, up to an `Eof`. + pub fn parse_all_token_trees(&mut self) -> PResult<'a, Vec> { + let mut tts = Vec::new(); + while self.token != token::Eof { + tts.push(self.parse_token_tree()?); + } + Ok(tts) + } + + // Parse a stream of tokens into a list of `TokenTree`s, up to a `CloseDelim`. + fn parse_token_trees_until_close_delim(&mut self) -> Vec { + let mut tts = vec![]; + loop { + if let token::CloseDelim(..) = self.token { + return tts; + } + match self.parse_token_tree() { + Ok(tt) => tts.push(tt), + Err(mut e) => { + e.emit(); + return tts; + } + } + } + } + + fn parse_token_tree(&mut self) -> PResult<'a, TokenTree> { + match self.token { + token::Eof => { + let msg = "this file contains an un-closed delimiter"; + let mut err = self.sess.span_diagnostic.struct_span_err(self.span, msg); + for &(_, sp) in &self.open_braces { + err.span_help(sp, "did you mean to close this delimiter?"); + } + Err(err) + }, + token::OpenDelim(delim) => { + // The span for beginning of the delimited section + let pre_span = self.span; + + // Parse the open delimiter. + self.open_braces.push((delim, self.span)); + let open_span = self.span; + self.real_token(); + + // Parse the token trees within the delimiters. + // We stop at any delimiter so we can try to recover if the user + // uses an incorrect delimiter. + let tts = self.parse_token_trees_until_close_delim(); + + let close_span = self.span; + // Expand to cover the entire delimited token tree + let span = Span { hi: close_span.hi, ..pre_span }; + + match self.token { + // Correct delimiter. + token::CloseDelim(d) if d == delim => { + self.open_braces.pop().unwrap(); + + // Parse the close delimiter. + self.real_token(); + } + // Incorrect delimiter. + token::CloseDelim(other) => { + let token_str = token_to_string(&self.token); + let msg = format!("incorrect close delimiter: `{}`", token_str); + let mut err = self.sess.span_diagnostic.struct_span_err(self.span, &msg); + // This is a conservative error: only report the last unclosed delimiter. + // The previous unclosed delimiters could actually be closed! The parser + // just hasn't gotten to them yet. + if let Some(&(_, sp)) = self.open_braces.last() { + err.span_note(sp, "unclosed delimiter"); + }; + err.emit(); + + self.open_braces.pop().unwrap(); + + // If the incorrect delimiter matches an earlier opening + // delimiter, then don't consume it (it can be used to + // close the earlier one). Otherwise, consume it. + // E.g., we try to recover from: + // fn foo() { + // bar(baz( + // } // Incorrect delimiter but matches the earlier `{` + if !self.open_braces.iter().any(|&(b, _)| b == other) { + self.real_token(); + } + } + token::Eof => { + // Silently recover, the EOF token will be seen again + // and an error emitted then. Thus we don't pop from + // self.open_braces here. + }, + _ => {} + } + + Ok(TokenTree::Delimited(span, Rc::new(Delimited { + delim: delim, + open_span: open_span, + tts: tts, + close_span: close_span, + }))) + }, + token::CloseDelim(_) => { + // An unexpected closing delimiter (i.e., there is no + // matching opening delimiter). + let token_str = token_to_string(&self.token); + let msg = format!("unexpected close delimiter: `{}`", token_str); + let err = self.sess.span_diagnostic.struct_span_err(self.span, &msg); + Err(err) + }, + _ => { + let tt = TokenTree::Token(self.span, self.token.clone()); + self.real_token(); + Ok(tt) + } + } + } +} diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 74b313ba395a3..500e8285b4c05 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -219,13 +219,10 @@ fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option) } /// Given a filemap, produce a sequence of token-trees -pub fn filemap_to_tts(sess: &ParseSess, filemap: Rc) - -> Vec { - // it appears to me that the cfg doesn't matter here... indeed, - // parsing tt's probably shouldn't require a parser at all. - let srdr = lexer::StringReader::new(sess, filemap); - let mut p1 = Parser::new(sess, Box::new(srdr), None, false); - panictry!(p1.parse_all_token_trees()) +pub fn filemap_to_tts(sess: &ParseSess, filemap: Rc) -> Vec { + let mut srdr = lexer::StringReader::new(sess, filemap); + srdr.real_token(); + panictry!(srdr.parse_all_token_trees()) } /// Given tts and the ParseSess, produce a parser From debcbf0b8e8fcf6f1d44e8f79cc06c0866d8d1dd Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Fri, 13 Jan 2017 04:49:20 +0000 Subject: [PATCH 14/37] Refactor the parser to consume token trees. --- src/librustc/session/config.rs | 3 +- src/librustc_metadata/cstore_impl.rs | 18 +---- src/libsyntax/ext/base.rs | 4 +- src/libsyntax/ext/tt/macro_parser.rs | 7 +- src/libsyntax/ext/tt/macro_rules.rs | 20 +++-- src/libsyntax/ext/tt/transcribe.rs | 11 ++- src/libsyntax/parse/lexer/mod.rs | 74 ----------------- src/libsyntax/parse/mod.rs | 5 +- src/libsyntax/parse/parser.rs | 115 +++++---------------------- src/libsyntax/tokenstream.rs | 13 +-- src/test/parse-fail/issue-33569.rs | 2 +- 11 files changed, 59 insertions(+), 213 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 104c851e057e6..7d8f7fcefe639 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -25,6 +25,7 @@ use lint; use middle::cstore; use syntax::ast::{self, IntTy, UintTy}; +use syntax::parse::token; use syntax::parse; use syntax::symbol::Symbol; use syntax::feature_gate::UnstableFeatures; @@ -1259,7 +1260,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec ) -> ast::CrateConfig { let meta_item = panictry!(parser.parse_meta_item()); - if !parser.reader.is_eof() { + if parser.token != token::Eof { early_error(ErrorOutputType::default(), &format!("invalid --cfg argument: {}", s)) } else if meta_item.is_meta_item_list() { let msg = diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 3d025e984b040..d962d1175527a 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -29,7 +29,7 @@ use rustc_back::PanicStrategy; use syntax::ast; use syntax::attr; -use syntax::parse::new_parser_from_source_str; +use syntax::parse::filemap_to_tts; use syntax::symbol::Symbol; use syntax_pos::{mk_sp, Span}; use rustc::hir::svh::Svh; @@ -395,19 +395,9 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { let (name, def) = data.get_macro(id.index); let source_name = format!("<{} macros>", name); - // NB: Don't use parse_tts_from_source_str because it parses with quote_depth > 0. - let mut parser = new_parser_from_source_str(&sess.parse_sess, source_name, def.body); - - let lo = parser.span.lo; - let body = match parser.parse_all_token_trees() { - Ok(body) => body, - Err(mut err) => { - err.emit(); - sess.abort_if_errors(); - unreachable!(); - } - }; - let local_span = mk_sp(lo, parser.prev_span.hi); + let filemap = sess.parse_sess.codemap().new_filemap(source_name, None, def.body); + let local_span = mk_sp(filemap.start_pos, filemap.end_pos); + let body = filemap_to_tts(&sess.parse_sess, filemap); // Mark the attrs as used let attrs = data.get_item_attrs(id.index); diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 68d261c64f83c..edf74e1fe19f1 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -615,9 +615,7 @@ impl<'a> ExtCtxt<'a> { pub fn new_parser_from_tts(&self, tts: &[tokenstream::TokenTree]) -> parser::Parser<'a> { - let mut parser = parse::tts_to_parser(self.parse_sess, tts.to_vec()); - parser.allow_interpolated_tts = false; // FIXME(jseyfried) `quote!` can't handle these yet - parser + parse::tts_to_parser(self.parse_sess, tts.to_vec()) } pub fn codemap(&self) -> &'a CodeMap { self.parse_sess.codemap() } pub fn parse_sess(&self) -> &'a parse::ParseSess { self.parse_sess } diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 2de31166070e7..46ffc93d2ee69 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -82,7 +82,6 @@ use ast::Ident; use syntax_pos::{self, BytePos, mk_sp, Span}; use codemap::Spanned; use errors::FatalError; -use parse::lexer::*; //resolve bug? use parse::{Directory, ParseSess}; use parse::parser::{PathStyle, Parser}; use parse::token::{DocComment, MatchNt, SubstNt}; @@ -407,9 +406,9 @@ fn inner_parse_loop(cur_eis: &mut SmallVector>, Success(()) } -pub fn parse(sess: &ParseSess, rdr: TtReader, ms: &[TokenTree], directory: Option) +pub fn parse(sess: &ParseSess, tts: Vec, ms: &[TokenTree], directory: Option) -> NamedParseResult { - let mut parser = Parser::new(sess, Box::new(rdr), directory, true); + let mut parser = Parser::new(sess, tts, directory, true); let mut cur_eis = SmallVector::one(initial_matcher_pos(ms.to_owned(), parser.span.lo)); let mut next_eis = Vec::new(); // or proceed normally @@ -527,7 +526,7 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { "ident" => match p.token { token::Ident(sn) => { p.bump(); - token::NtIdent(Spanned::{node: sn, span: p.span}) + token::NtIdent(Spanned::{node: sn, span: p.prev_span}) } _ => { let token_str = pprust::token_to_string(&p.token); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 3abd24b50ba9a..585232c5462b4 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -16,8 +16,8 @@ use ext::expand::{Expansion, ExpansionKind}; use ext::tt::macro_parser::{Success, Error, Failure}; use ext::tt::macro_parser::{MatchedSeq, MatchedNonterminal}; use ext::tt::macro_parser::{parse, parse_failure_msg}; +use ext::tt::transcribe::new_tt_reader; use parse::{Directory, ParseSess}; -use parse::lexer::new_tt_reader; use parse::parser::Parser; use parse::token::{self, NtTT, Token}; use parse::token::Token::*; @@ -113,13 +113,21 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, _ => cx.span_bug(sp, "malformed macro rhs"), }; // rhs has holes ( `$id` and `$(...)` that need filled) - let trncbr = + let mut trncbr = new_tt_reader(&cx.parse_sess.span_diagnostic, Some(named_matches), rhs); + let mut tts = Vec::new(); + loop { + let tok = trncbr.real_token(); + if tok.tok == token::Eof { + break + } + tts.push(TokenTree::Token(tok.sp, tok.tok)); + } let directory = Directory { path: cx.current_expansion.module.directory.clone(), ownership: cx.current_expansion.directory_ownership, }; - let mut p = Parser::new(cx.parse_sess(), Box::new(trncbr), Some(directory), false); + let mut p = Parser::new(cx.parse_sess(), tts, Some(directory), false); p.root_module_name = cx.current_expansion.module.mod_path.last() .map(|id| (*id.name.as_str()).to_owned()); @@ -187,10 +195,8 @@ pub fn compile(sess: &ParseSess, def: &ast::MacroDef) -> SyntaxExtension { })), ]; - // Parse the macro_rules! invocation (`none` is for no interpolations): - let arg_reader = new_tt_reader(&sess.span_diagnostic, None, def.body.clone()); - - let argument_map = match parse(sess, arg_reader, &argument_gram, None) { + // Parse the macro_rules! invocation + let argument_map = match parse(sess, def.body.clone(), &argument_gram, None) { Success(m) => m, Failure(sp, tok) => { let s = parse_failure_msg(tok); diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 37e329e5d3b29..82f1e18389565 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -10,7 +10,7 @@ use self::LockstepIterSize::*; use ast::Ident; -use errors::{Handler, DiagnosticBuilder}; +use errors::Handler; use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal}; use parse::token::{self, MatchNt, SubstNt, Token, NtIdent}; use parse::lexer::TokenAndSpan; @@ -44,8 +44,12 @@ pub struct TtReader<'a> { /* cached: */ pub cur_tok: Token, pub cur_span: Span, - /// Transform doc comments. Only useful in macro invocations - pub fatal_errs: Vec>, +} + +impl<'a> TtReader<'a> { + pub fn real_token(&mut self) -> TokenAndSpan { + tt_next_token(self) + } } /// This can do Macro-By-Example transcription. On the other hand, if @@ -76,7 +80,6 @@ pub fn new_tt_reader(sp_diag: &Handler, /* dummy values, never read: */ cur_tok: token::Eof, cur_span: DUMMY_SP, - fatal_errs: Vec::new(), }; tt_next_token(&mut r); /* get cur_tok and cur_span set up */ r diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 6c6161998d711..12b9130c47439 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -12,7 +12,6 @@ use ast::{self, Ident}; use syntax_pos::{self, BytePos, CharPos, Pos, Span}; use codemap::CodeMap; use errors::{FatalError, DiagnosticBuilder}; -use ext::tt::transcribe::tt_next_token; use parse::{token, ParseSess}; use str::char_at; use symbol::{Symbol, keywords}; @@ -23,53 +22,10 @@ use std::char; use std::mem::replace; use std::rc::Rc; -pub use ext::tt::transcribe::{TtReader, new_tt_reader}; - pub mod comments; mod tokentrees; mod unicode_chars; -pub trait Reader { - fn is_eof(&self) -> bool; - fn try_next_token(&mut self) -> Result; - fn next_token(&mut self) -> TokenAndSpan where Self: Sized { - let res = self.try_next_token(); - self.unwrap_or_abort(res) - } - /// Report a fatal error with the current span. - fn fatal(&self, &str) -> FatalError; - /// Report a non-fatal error with the current span. - fn err(&self, &str); - fn emit_fatal_errors(&mut self); - fn unwrap_or_abort(&mut self, res: Result) -> TokenAndSpan { - match res { - Ok(tok) => tok, - Err(_) => { - self.emit_fatal_errors(); - panic!(FatalError); - } - } - } - fn peek(&self) -> TokenAndSpan; - /// Get a token the parser cares about. - fn try_real_token(&mut self) -> Result { - let mut t = self.try_next_token()?; - loop { - match t.tok { - token::Whitespace | token::Comment | token::Shebang(_) => { - t = self.try_next_token()?; - } - _ => break, - } - } - Ok(t) - } - fn real_token(&mut self) -> TokenAndSpan { - let res = self.try_real_token(); - self.unwrap_or_abort(res) - } -} - #[derive(Clone, PartialEq, Eq, Debug)] pub struct TokenAndSpan { pub tok: token::Token, @@ -182,36 +138,6 @@ impl<'a> StringReader<'a> { } } -impl<'a> Reader for TtReader<'a> { - fn is_eof(&self) -> bool { - self.peek().tok == token::Eof - } - fn try_next_token(&mut self) -> Result { - assert!(self.fatal_errs.is_empty()); - let r = tt_next_token(self); - debug!("TtReader: r={:?}", r); - Ok(r) - } - fn fatal(&self, m: &str) -> FatalError { - self.sp_diag.span_fatal(self.cur_span, m) - } - fn err(&self, m: &str) { - self.sp_diag.span_err(self.cur_span, m); - } - fn emit_fatal_errors(&mut self) { - for err in &mut self.fatal_errs { - err.emit(); - } - self.fatal_errs.clear(); - } - fn peek(&self) -> TokenAndSpan { - TokenAndSpan { - tok: self.cur_tok.clone(), - sp: self.cur_span, - } - } -} - impl<'a> StringReader<'a> { /// For comments.rs, which hackily pokes into next_pos and ch pub fn new_raw<'b>(sess: &'a ParseSess, filemap: Rc) -> Self { diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 500e8285b4c05..0937ef15b4d6d 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -45,7 +45,7 @@ pub mod obsolete; /// Info about a parsing session. pub struct ParseSess { - pub span_diagnostic: Handler, // better be the same as the one in the reader! + pub span_diagnostic: Handler, pub unstable_features: UnstableFeatures, pub config: CrateConfig, /// Used to determine and report recursive mod inclusions @@ -227,8 +227,7 @@ pub fn filemap_to_tts(sess: &ParseSess, filemap: Rc) -> Vec(sess: &'a ParseSess, tts: Vec) -> Parser<'a> { - let trdr = lexer::new_tt_reader(&sess.span_diagnostic, None, tts); - let mut p = Parser::new(sess, Box::new(trdr), None, false); + let mut p = Parser::new(sess, tts, None, false); p.check_unknown_macro_variable(); p } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9ba6d4d17f794..608f8688e8810 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -46,7 +46,7 @@ use ext::tt::macro_parser; use parse; use parse::classify; use parse::common::SeqSep; -use parse::lexer::{Reader, TokenAndSpan}; +use parse::lexer::TokenAndSpan; use parse::obsolete::ObsoleteSyntax; use parse::token::{self, MatchNt, SubstNt}; use parse::{new_sub_parser_from_file, ParseSess, Directory, DirectoryOwnership}; @@ -188,14 +188,11 @@ pub struct Parser<'a> { pub restrictions: Restrictions, pub quote_depth: usize, // not (yet) related to the quasiquoter parsing_token_tree: bool, - pub reader: Box, /// The set of seen errors about obsolete syntax. Used to suppress /// extra detail when the same error is seen twice pub obsolete_set: HashSet, /// Used to determine the path to externally loaded source files pub directory: Directory, - /// Stack of open delimiters and their spans. Used for error message. - pub open_braces: Vec<(token::DelimToken, Span)>, /// Name of the root module this parser originated from. If `None`, then the /// name is not known. This does not change while the parser is descending /// into modules, and sub-parsers have new values for this name. @@ -203,7 +200,6 @@ pub struct Parser<'a> { pub expected_tokens: Vec, pub tts: Vec<(TokenTree, usize)>, pub desugar_doc_comments: bool, - pub allow_interpolated_tts: bool, } #[derive(PartialEq, Eq, Clone)] @@ -269,12 +265,17 @@ impl From> for LhsExpr { impl<'a> Parser<'a> { pub fn new(sess: &'a ParseSess, - rdr: Box, + tokens: Vec, directory: Option, desugar_doc_comments: bool) -> Self { + let tt = TokenTree::Delimited(syntax_pos::DUMMY_SP, Rc::new(Delimited { + delim: token::NoDelim, + open_span: syntax_pos::DUMMY_SP, + tts: tokens, + close_span: syntax_pos::DUMMY_SP, + })); let mut parser = Parser { - reader: rdr, sess: sess, token: token::Underscore, span: syntax_pos::DUMMY_SP, @@ -286,12 +287,10 @@ impl<'a> Parser<'a> { parsing_token_tree: false, obsolete_set: HashSet::new(), directory: Directory { path: PathBuf::new(), ownership: DirectoryOwnership::Owned }, - open_braces: Vec::new(), root_module_name: None, expected_tokens: Vec::new(), - tts: Vec::new(), + tts: if tt.len() > 0 { vec![(tt, 0)] } else { Vec::new() }, desugar_doc_comments: desugar_doc_comments, - allow_interpolated_tts: true, }; let tok = parser.next_tok(); @@ -320,7 +319,7 @@ impl<'a> Parser<'a> { continue } } else { - self.reader.real_token() + TokenAndSpan { tok: token::Eof, sp: self.span } }; loop { @@ -2688,94 +2687,28 @@ impl<'a> Parser<'a> { // whether something will be a nonterminal or a seq // yet. match self.token { - token::Eof => { - let mut err: DiagnosticBuilder<'a> = - self.diagnostic().struct_span_err(self.span, - "this file contains an un-closed delimiter"); - for &(_, sp) in &self.open_braces { - err.span_help(sp, "did you mean to close this delimiter?"); - } - - Err(err) - }, token::OpenDelim(delim) => { - if self.tts.last().map(|&(_, i)| i == 1).unwrap_or(false) { + if self.quote_depth == 0 && self.tts.last().map(|&(_, i)| i == 1).unwrap_or(false) { let tt = self.tts.pop().unwrap().0; self.bump(); - return Ok(if self.allow_interpolated_tts { - // avoid needlessly reparsing token trees in recursive macro expansions - TokenTree::Token(tt.span(), token::Interpolated(Rc::new(token::NtTT(tt)))) - } else { - tt - }); + return Ok(tt); } let parsing_token_tree = ::std::mem::replace(&mut self.parsing_token_tree, true); - // The span for beginning of the delimited section - let pre_span = self.span; - - // Parse the open delimiter. - self.open_braces.push((delim, self.span)); let open_span = self.span; self.bump(); - - // Parse the token trees within the delimiters. - // We stop at any delimiter so we can try to recover if the user - // uses an incorrect delimiter. let tts = self.parse_seq_to_before_tokens(&[&token::CloseDelim(token::Brace), &token::CloseDelim(token::Paren), &token::CloseDelim(token::Bracket)], SeqSep::none(), |p| p.parse_token_tree(), |mut e| e.emit()); + self.parsing_token_tree = parsing_token_tree; let close_span = self.span; - // Expand to cover the entire delimited token tree - let span = Span { hi: close_span.hi, ..pre_span }; - - match self.token { - // Correct delimiter. - token::CloseDelim(d) if d == delim => { - self.open_braces.pop().unwrap(); - - // Parse the close delimiter. - self.bump(); - } - // Incorrect delimiter. - token::CloseDelim(other) => { - let token_str = self.this_token_to_string(); - let mut err = self.diagnostic().struct_span_err(self.span, - &format!("incorrect close delimiter: `{}`", token_str)); - // This is a conservative error: only report the last unclosed delimiter. - // The previous unclosed delimiters could actually be closed! The parser - // just hasn't gotten to them yet. - if let Some(&(_, sp)) = self.open_braces.last() { - err.span_note(sp, "unclosed delimiter"); - }; - err.emit(); - - self.open_braces.pop().unwrap(); - - // If the incorrect delimiter matches an earlier opening - // delimiter, then don't consume it (it can be used to - // close the earlier one). Otherwise, consume it. - // E.g., we try to recover from: - // fn foo() { - // bar(baz( - // } // Incorrect delimiter but matches the earlier `{` - if !self.open_braces.iter().any(|&(b, _)| b == other) { - self.bump(); - } - } - token::Eof => { - // Silently recover, the EOF token will be seen again - // and an error emitted then. Thus we don't pop from - // self.open_braces here. - }, - _ => {} - } + self.bump(); - self.parsing_token_tree = parsing_token_tree; + let span = Span { lo: open_span.lo, ..close_span }; Ok(TokenTree::Delimited(span, Rc::new(Delimited { delim: delim, open_span: open_span, @@ -2783,21 +2716,9 @@ impl<'a> Parser<'a> { close_span: close_span, }))) }, - token::CloseDelim(_) => { - // An unexpected closing delimiter (i.e., there is no - // matching opening delimiter). - let token_str = self.this_token_to_string(); - let err = self.diagnostic().struct_span_err(self.span, - &format!("unexpected close delimiter: `{}`", token_str)); - Err(err) - }, - /* we ought to allow different depths of unquotation */ - token::Dollar | token::SubstNt(..) if self.quote_depth > 0 => { - self.parse_unquoted() - } - _ => { - Ok(TokenTree::Token(self.span, self.bump_and_get())) - } + token::CloseDelim(_) | token::Eof => unreachable!(), + token::Dollar | token::SubstNt(..) if self.quote_depth > 0 => self.parse_unquoted(), + _ => Ok(TokenTree::Token(self.span, self.bump_and_get())), } } diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index e352e7853c71c..ab5dc8181e05b 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -30,7 +30,6 @@ use codemap::{Spanned, combine_spans}; use ext::base; use ext::tt::macro_parser; use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration}; -use parse::lexer; use parse::{self, Directory}; use parse::token::{self, Token, Lit, Nonterminal}; use print::pprust; @@ -139,7 +138,10 @@ impl TokenTree { if let Nonterminal::NtTT(..) = **nt { 1 } else { 0 } }, TokenTree::Token(_, token::MatchNt(..)) => 3, - TokenTree::Delimited(_, ref delimed) => delimed.tts.len() + 2, + TokenTree::Delimited(_, ref delimed) => match delimed.delim { + token::NoDelim => delimed.tts.len(), + _ => delimed.tts.len() + 2, + }, TokenTree::Sequence(_, ref seq) => seq.tts.len(), TokenTree::Token(..) => 0, } @@ -181,6 +183,9 @@ impl TokenTree { close_span: sp, })) } + (&TokenTree::Delimited(_, ref delimed), _) if delimed.delim == token::NoDelim => { + delimed.tts[index].clone() + } (&TokenTree::Delimited(_, ref delimed), _) => { if index == 0 { return delimed.open_tt(); @@ -215,14 +220,12 @@ impl TokenTree { mtch: &[TokenTree], tts: &[TokenTree]) -> macro_parser::NamedParseResult { - let diag = &cx.parse_sess().span_diagnostic; // `None` is because we're not interpolating - let arg_rdr = lexer::new_tt_reader(diag, None, tts.iter().cloned().collect()); let directory = Directory { path: cx.current_expansion.module.directory.clone(), ownership: cx.current_expansion.directory_ownership, }; - macro_parser::parse(cx.parse_sess(), arg_rdr, mtch, Some(directory)) + macro_parser::parse(cx.parse_sess(), tts.iter().cloned().collect(), mtch, Some(directory)) } /// Check if this TokenTree is equal to the other, regardless of span information. diff --git a/src/test/parse-fail/issue-33569.rs b/src/test/parse-fail/issue-33569.rs index 130278d778ab0..e3c17af82aab4 100644 --- a/src/test/parse-fail/issue-33569.rs +++ b/src/test/parse-fail/issue-33569.rs @@ -13,6 +13,6 @@ macro_rules! foo { { $+ } => { //~ ERROR expected identifier, found `+` $(x)(y) //~ ERROR expected `*` or `+` - //~^ ERROR no rules expected the token `y` + //~^ ERROR no rules expected the token `)` } } From 6a9248fc1525e619d4ffb2b895a8d15c4bf90de8 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 14 Jan 2017 12:15:26 +0000 Subject: [PATCH 15/37] Clean up `ext::tt::transcribe`. --- src/libsyntax/ext/tt/macro_rules.rs | 13 +--- src/libsyntax/ext/tt/transcribe.rs | 96 ++++++++++------------------- 2 files changed, 35 insertions(+), 74 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 585232c5462b4..f6a25d4aceed7 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -16,7 +16,7 @@ use ext::expand::{Expansion, ExpansionKind}; use ext::tt::macro_parser::{Success, Error, Failure}; use ext::tt::macro_parser::{MatchedSeq, MatchedNonterminal}; use ext::tt::macro_parser::{parse, parse_failure_msg}; -use ext::tt::transcribe::new_tt_reader; +use ext::tt::transcribe::transcribe; use parse::{Directory, ParseSess}; use parse::parser::Parser; use parse::token::{self, NtTT, Token}; @@ -113,16 +113,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, _ => cx.span_bug(sp, "malformed macro rhs"), }; // rhs has holes ( `$id` and `$(...)` that need filled) - let mut trncbr = - new_tt_reader(&cx.parse_sess.span_diagnostic, Some(named_matches), rhs); - let mut tts = Vec::new(); - loop { - let tok = trncbr.real_token(); - if tok.tok == token::Eof { - break - } - tts.push(TokenTree::Token(tok.sp, tok.tok)); - } + let tts = transcribe(&cx.parse_sess.span_diagnostic, Some(named_matches), rhs); let directory = Directory { path: cx.current_expansion.module.directory.clone(), ownership: cx.current_expansion.directory_ownership, diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 82f1e18389565..bf6851ec1dc01 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -13,7 +13,6 @@ use ast::Ident; use errors::Handler; use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal}; use parse::token::{self, MatchNt, SubstNt, Token, NtIdent}; -use parse::lexer::TokenAndSpan; use syntax_pos::{Span, DUMMY_SP}; use tokenstream::{self, TokenTree}; use util::small_vector::SmallVector; @@ -32,8 +31,8 @@ struct TtFrame { } #[derive(Clone)] -pub struct TtReader<'a> { - pub sp_diag: &'a Handler, +struct TtReader<'a> { + sp_diag: &'a Handler, /// the unzipped tree: stack: SmallVector, /* for MBE-style macro transcription */ @@ -41,24 +40,15 @@ pub struct TtReader<'a> { repeat_idx: Vec, repeat_len: Vec, - /* cached: */ - pub cur_tok: Token, - pub cur_span: Span, -} - -impl<'a> TtReader<'a> { - pub fn real_token(&mut self) -> TokenAndSpan { - tt_next_token(self) - } } /// This can do Macro-By-Example transcription. On the other hand, if /// `src` contains no `TokenTree::Sequence`s, `MatchNt`s or `SubstNt`s, `interp` can /// (and should) be None. -pub fn new_tt_reader(sp_diag: &Handler, - interp: Option>>, - src: Vec) - -> TtReader { +pub fn transcribe(sp_diag: &Handler, + interp: Option>>, + src: Vec) + -> Vec { let mut r = TtReader { sp_diag: sp_diag, stack: SmallVector::one(TtFrame { @@ -77,12 +67,15 @@ pub fn new_tt_reader(sp_diag: &Handler, }, repeat_idx: Vec::new(), repeat_len: Vec::new(), - /* dummy values, never read: */ - cur_tok: token::Eof, - cur_span: DUMMY_SP, }; - tt_next_token(&mut r); /* get cur_tok and cur_span set up */ - r + + let mut tts = Vec::new(); + let mut prev_span = DUMMY_SP; + while let Some(tt) = tt_next_token(&mut r, prev_span) { + prev_span = tt.span(); + tts.push(tt); + } + tts } fn lookup_cur_matched_by_matched(r: &TtReader, start: Rc) -> Rc { @@ -156,38 +149,24 @@ fn lockstep_iter_size(t: &TokenTree, r: &TtReader) -> LockstepIterSize { /// Return the next token from the TtReader. /// EFFECT: advances the reader's token field -pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { - // FIXME(pcwalton): Bad copy? - let ret_val = TokenAndSpan { - tok: r.cur_tok.clone(), - sp: r.cur_span.clone(), - }; +fn tt_next_token(r: &mut TtReader, prev_span: Span) -> Option { loop { - let should_pop = match r.stack.last() { - None => { - assert_eq!(ret_val.tok, token::Eof); - return ret_val; - } - Some(frame) => { - if frame.idx < frame.forest.len() { - break; - } - !frame.dotdotdoted || - *r.repeat_idx.last().unwrap() == *r.repeat_len.last().unwrap() - 1 + let should_pop = if let Some(frame) = r.stack.last() { + if frame.idx < frame.forest.len() { + break; } + !frame.dotdotdoted || *r.repeat_idx.last().unwrap() == *r.repeat_len.last().unwrap() - 1 + } else { + return None; }; /* done with this set; pop or repeat? */ if should_pop { let prev = r.stack.pop().unwrap(); - match r.stack.last_mut() { - None => { - r.cur_tok = token::Eof; - return ret_val; - } - Some(frame) => { - frame.idx += 1; - } + if let Some(frame) = r.stack.last_mut() { + frame.idx += 1; + } else { + return None; } if prev.dotdotdoted { r.repeat_idx.pop(); @@ -197,8 +176,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { *r.repeat_idx.last_mut().unwrap() += 1; r.stack.last_mut().unwrap().idx = 0; if let Some(tk) = r.stack.last().unwrap().sep.clone() { - r.cur_tok = tk; // repeat same span, I guess - return ret_val; + return Some(TokenTree::Token(prev_span, tk)); // repeat same span, I guess } } } @@ -234,7 +212,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { } r.stack.last_mut().unwrap().idx += 1; - return tt_next_token(r); + return tt_next_token(r, prev_span); } r.repeat_len.push(len); r.repeat_idx.push(0); @@ -252,9 +230,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { r.stack.last_mut().unwrap().idx += 1; match lookup_cur_matched(r, ident) { None => { - r.cur_span = sp; - r.cur_tok = SubstNt(ident); - return ret_val; + return Some(TokenTree::Token(sp, SubstNt(ident))); // this can't be 0 length, just like TokenTree::Delimited } Some(cur_matched) => if let MatchedNonterminal(ref nt) = *cur_matched { @@ -263,15 +239,11 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { // (a) idents can be in lots of places, so it'd be a pain // (b) we actually can, since it's a token. NtIdent(ref sn) => { - r.cur_span = sn.span; - r.cur_tok = token::Ident(sn.node); - return ret_val; + return Some(TokenTree::Token(sn.span, token::Ident(sn.node))); } _ => { - // FIXME(pcwalton): Bad copy. - r.cur_span = sp; - r.cur_tok = token::Interpolated(nt.clone()); - return ret_val; + // FIXME(pcwalton): Bad copy + return Some(TokenTree::Token(sp, token::Interpolated(nt.clone()))); } } } else { @@ -292,11 +264,9 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { }); // if this could be 0-length, we'd need to potentially recur here } - TokenTree::Token(sp, tok) => { - r.cur_span = sp; - r.cur_tok = tok; + tt @ TokenTree::Token(..) => { r.stack.last_mut().unwrap().idx += 1; - return ret_val; + return Some(tt); } } } From 57c0ed097ce150fa1d684b5b3b5479a5dedd2b7b Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 14 Jan 2017 12:42:00 +0000 Subject: [PATCH 16/37] Avoid interpolated token trees. --- src/libsyntax/ext/tt/macro_parser.rs | 17 +---------------- src/libsyntax/ext/tt/transcribe.rs | 3 ++- src/libsyntax/parse/parser.rs | 26 ++++++-------------------- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 46ffc93d2ee69..834ece97af544 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -480,23 +480,8 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { match name { "tt" => { p.quote_depth += 1; //but in theory, non-quoted tts might be useful - let mut tt = panictry!(p.parse_token_tree()); + let tt = panictry!(p.parse_token_tree()); p.quote_depth -= 1; - while let TokenTree::Token(sp, token::Interpolated(nt)) = tt { - if let token::NtTT(..) = *nt { - match Rc::try_unwrap(nt) { - Ok(token::NtTT(sub_tt)) => tt = sub_tt, - Ok(_) => unreachable!(), - Err(nt_rc) => match *nt_rc { - token::NtTT(ref sub_tt) => tt = sub_tt.clone(), - _ => unreachable!(), - }, - } - } else { - tt = TokenTree::Token(sp, token::Interpolated(nt.clone())); - break - } - } return token::NtTT(tt); } _ => {} diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index bf6851ec1dc01..38becbe7b1d30 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -12,7 +12,7 @@ use self::LockstepIterSize::*; use ast::Ident; use errors::Handler; use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal}; -use parse::token::{self, MatchNt, SubstNt, Token, NtIdent}; +use parse::token::{self, MatchNt, SubstNt, Token, NtIdent, NtTT}; use syntax_pos::{Span, DUMMY_SP}; use tokenstream::{self, TokenTree}; use util::small_vector::SmallVector; @@ -241,6 +241,7 @@ fn tt_next_token(r: &mut TtReader, prev_span: Span) -> Option { NtIdent(ref sn) => { return Some(TokenTree::Token(sn.span, token::Ident(sn.node))); } + NtTT(ref tt) => return Some(tt.clone()), _ => { // FIXME(pcwalton): Bad copy return Some(TokenTree::Token(sp, token::Interpolated(nt.clone()))); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 608f8688e8810..f958cedd286f3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -306,8 +306,8 @@ impl<'a> Parser<'a> { } fn next_tok(&mut self) -> TokenAndSpan { - 'outer: loop { - let mut tok = if let Some((tts, i)) = self.tts.pop() { + loop { + let tok = if let Some((tts, i)) = self.tts.pop() { let tt = tts.get_tt(i); if i + 1 < tts.len() { self.tts.push((tts, i + 1)); @@ -322,25 +322,11 @@ impl<'a> Parser<'a> { TokenAndSpan { tok: token::Eof, sp: self.span } }; - loop { - let nt = match tok.tok { - token::Interpolated(ref nt) => nt.clone(), - token::DocComment(name) if self.desugar_doc_comments => { - self.tts.push((TokenTree::Token(tok.sp, token::DocComment(name)), 0)); - continue 'outer - } - _ => return tok, - }; - match *nt { - token::NtTT(TokenTree::Token(sp, ref t)) => { - tok = TokenAndSpan { tok: t.clone(), sp: sp }; - } - token::NtTT(ref tt) => { - self.tts.push((tt.clone(), 0)); - continue 'outer - } - _ => return tok, + match tok.tok { + token::DocComment(name) if self.desugar_doc_comments => { + self.tts.push((TokenTree::Token(tok.sp, token::DocComment(name)), 0)); } + _ => return tok, } } } From 1080a69b01f4236747bf368556e052c4a2a43c3f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 15 Jan 2017 18:50:22 -0800 Subject: [PATCH 17/37] travis: Pass --enable-llvm-static-stdcpp All our releases are compiled with this, so let's be sure to do so whenever `DEPLOY` is set. This'll ensure that we don't have dynamic dependencies on libstdc++ which LLVM depends on, but instead we link it all statically to have more portable binaries. --- src/ci/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ci/run.sh b/src/ci/run.sh index 205228a7bccc8..823970201f645 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -43,6 +43,7 @@ fi # either automatically or manually. if [ "$DEPLOY" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=nightly" + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp" if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" From 3d85f73def1869b971399bfcef7fa71cf2d83163 Mon Sep 17 00:00:00 2001 From: "Stephen E. Baker" Date: Tue, 17 Jan 2017 14:39:16 -0500 Subject: [PATCH 18/37] Clarify when range is removed by drain Based on a discussion on #rust-beginners the existing note for drain is confusing. This new wording was suggested. --- src/libcollections/vec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 4b05f8062e8bc..c5b904c8a2f0e 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1023,8 +1023,8 @@ impl Vec { /// Create a draining iterator that removes the specified range in the vector /// and yields the removed items. /// - /// Note 1: The element range is removed even if the iterator is not - /// consumed until the end. + /// Note 1: The element range is removed even if the iterator is only + /// partially consumed or not consumed at all. /// /// Note 2: It is unspecified how many elements are removed from the vector, /// if the `Drain` value is leaked. From 4c98e1bc592841c03b5228787c97c2edf67ccc6c Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 14 Jan 2017 11:13:45 +0000 Subject: [PATCH 19/37] Remove the lookahead buffer. --- src/libsyntax/parse/parser.rs | 51 ++++++++++------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f958cedd286f3..aa5331e4c7d78 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -156,22 +156,6 @@ enum PrevTokenKind { Other, } -// Simple circular buffer used for keeping few next tokens. -#[derive(Default)] -struct LookaheadBuffer { - buffer: [TokenAndSpan; LOOKAHEAD_BUFFER_CAPACITY], - start: usize, - end: usize, -} - -const LOOKAHEAD_BUFFER_CAPACITY: usize = 8; - -impl LookaheadBuffer { - fn len(&self) -> usize { - (LOOKAHEAD_BUFFER_CAPACITY + self.end - self.start) % LOOKAHEAD_BUFFER_CAPACITY - } -} - /* ident is handled by common.rs */ pub struct Parser<'a> { @@ -184,7 +168,6 @@ pub struct Parser<'a> { pub prev_span: Span, /// the previous token kind prev_token_kind: PrevTokenKind, - lookahead_buffer: LookaheadBuffer, pub restrictions: Restrictions, pub quote_depth: usize, // not (yet) related to the quasiquoter parsing_token_tree: bool, @@ -281,7 +264,6 @@ impl<'a> Parser<'a> { span: syntax_pos::DUMMY_SP, prev_span: syntax_pos::DUMMY_SP, prev_token_kind: PrevTokenKind::Other, - lookahead_buffer: Default::default(), restrictions: Restrictions::empty(), quote_depth: 0, parsing_token_tree: false, @@ -875,14 +857,7 @@ impl<'a> Parser<'a> { _ => PrevTokenKind::Other, }; - let next = if self.lookahead_buffer.start == self.lookahead_buffer.end { - self.next_tok() - } else { - // Avoid token copies with `replace`. - let old_start = self.lookahead_buffer.start; - self.lookahead_buffer.start = (old_start + 1) % LOOKAHEAD_BUFFER_CAPACITY; - mem::replace(&mut self.lookahead_buffer.buffer[old_start], Default::default()) - }; + let next = self.next_tok(); self.span = next.sp; self.token = next.tok; self.expected_tokens.clear(); @@ -917,18 +892,20 @@ impl<'a> Parser<'a> { F: FnOnce(&token::Token) -> R, { if dist == 0 { - f(&self.token) - } else if dist < LOOKAHEAD_BUFFER_CAPACITY { - while self.lookahead_buffer.len() < dist { - self.lookahead_buffer.buffer[self.lookahead_buffer.end] = self.next_tok(); - self.lookahead_buffer.end = - (self.lookahead_buffer.end + 1) % LOOKAHEAD_BUFFER_CAPACITY; - } - let index = (self.lookahead_buffer.start + dist - 1) % LOOKAHEAD_BUFFER_CAPACITY; - f(&self.lookahead_buffer.buffer[index].tok) - } else { - self.bug("lookahead distance is too large"); + return f(&self.token); + } + let mut tok = token::Eof; + if let Some(&(ref tts, mut i)) = self.tts.last() { + i += dist - 1; + if i < tts.len() { + tok = match tts.get_tt(i) { + TokenTree::Token(_, tok) => tok, + TokenTree::Delimited(_, delimited) => token::OpenDelim(delimited.delim), + TokenTree::Sequence(..) => token::Dollar, + }; + } } + f(&tok) } pub fn fatal(&self, m: &str) -> DiagnosticBuilder<'a> { self.sess.span_diagnostic.struct_span_fatal(self.span, m) From 0b9e26f390403aa95620d3b813f046732b371fb1 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Tue, 17 Jan 2017 04:50:46 +0000 Subject: [PATCH 20/37] Fix fallout in `rustdoc`. --- src/librustdoc/html/highlight.rs | 16 +++++++--------- src/libsyntax/parse/lexer/mod.rs | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index a031be8b3c2be..0629e93e7ef5d 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -27,7 +27,7 @@ use std::io; use std::io::prelude::*; use syntax::codemap::CodeMap; -use syntax::parse::lexer::{self, Reader, TokenAndSpan}; +use syntax::parse::lexer::{self, TokenAndSpan}; use syntax::parse::token; use syntax::parse; use syntax_pos::Span; @@ -42,8 +42,7 @@ pub fn render_with_highlighting(src: &str, class: Option<&str>, id: Option<&str> let mut out = Vec::new(); write_header(class, id, &mut out).unwrap(); - let mut classifier = Classifier::new(lexer::StringReader::new(&sess.span_diagnostic, fm), - sess.codemap()); + let mut classifier = Classifier::new(lexer::StringReader::new(&sess, fm), sess.codemap()); if let Err(_) = classifier.write_source(&mut out) { return format!("
{}
", src); } @@ -63,8 +62,7 @@ pub fn render_inner_with_highlighting(src: &str) -> io::Result { let fm = sess.codemap().new_filemap("".to_string(), None, src.to_string()); let mut out = Vec::new(); - let mut classifier = Classifier::new(lexer::StringReader::new(&sess.span_diagnostic, fm), - sess.codemap()); + let mut classifier = Classifier::new(lexer::StringReader::new(&sess, fm), sess.codemap()); classifier.write_source(&mut out)?; Ok(String::from_utf8_lossy(&out).into_owned()) @@ -185,10 +183,10 @@ impl<'a> Classifier<'a> { Ok(tas) => tas, Err(_) => { self.lexer.emit_fatal_errors(); - self.lexer.span_diagnostic.struct_warn("Backing out of syntax highlighting") - .note("You probably did not intend to render this \ - as a rust code-block") - .emit(); + self.lexer.sess.span_diagnostic + .struct_warn("Backing out of syntax highlighting") + .note("You probably did not intend to render this as a rust code-block") + .emit(); return Err(io::Error::new(io::ErrorKind::Other, "")); } }; diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 12b9130c47439..6bc15115b09d3 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -111,7 +111,7 @@ impl<'a> StringReader<'a> { } } /// Return the next token. EFFECT: advances the string_reader. - fn try_next_token(&mut self) -> Result { + pub fn try_next_token(&mut self) -> Result { assert!(self.fatal_errs.is_empty()); let ret_val = TokenAndSpan { tok: replace(&mut self.peek_tok, token::Underscore), @@ -123,13 +123,13 @@ impl<'a> StringReader<'a> { fn fatal(&self, m: &str) -> FatalError { self.fatal_span(self.peek_span, m) } - fn emit_fatal_errors(&mut self) { + pub fn emit_fatal_errors(&mut self) { for err in &mut self.fatal_errs { err.emit(); } self.fatal_errs.clear(); } - fn peek(&self) -> TokenAndSpan { + pub fn peek(&self) -> TokenAndSpan { // FIXME(pcwalton): Bad copy! TokenAndSpan { tok: self.peek_tok.clone(), From 9fd3860e567545a5512c5155516d3e4cd866a5f2 Mon Sep 17 00:00:00 2001 From: gralpli Date: Tue, 17 Jan 2017 22:52:43 +0100 Subject: [PATCH 21/37] Fix ICE when compiling fn f Sized>() {} --- src/librustc_typeck/collect.rs | 1 - src/test/run-pass/issue-39089.rs | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/issue-39089.rs diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index f832bf8d86e93..33309000f0652 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1665,7 +1665,6 @@ fn is_unsized<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>, for ab in ast_bounds { if let &hir::TraitTyParamBound(ref ptr, hir::TraitBoundModifier::Maybe) = ab { if unbound.is_none() { - assert!(ptr.bound_lifetimes.is_empty()); unbound = Some(ptr.trait_ref.clone()); } else { span_err!(tcx.sess, span, E0203, diff --git a/src/test/run-pass/issue-39089.rs b/src/test/run-pass/issue-39089.rs new file mode 100644 index 0000000000000..c3a58844547d6 --- /dev/null +++ b/src/test/run-pass/issue-39089.rs @@ -0,0 +1,13 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f Sized>() {} + +fn main() {} From a0a4af139dcac3c1629e5853d72df27616a00d2a Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 10 Jan 2017 00:44:02 +0000 Subject: [PATCH 22/37] 1.15 release notes --- RELEASES.md | 241 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index e85c9d18db980..b8ddeaf32b043 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,244 @@ +Version 1.15.0 (2017-02-02) +=========================== + +Language +-------- + +* Basic procedural macros allowing custom `#[derive]`, aka "macros 1.1", are + stable. This allows popular code-generating crates like Serde and Diesel to + work ergonomically. [RFC 1681]. +* [Tuple structs may be empty. Unary and empty tuple structs may be instantiated + with curly braces][36868]. Part of [RFC 1506]. +* [A number of minor changes to name resolution have been activated][37127]. + They add up to more consistent semantics, allowing for future evolution of + Rust macros. Specified in [RFC 1560], see its section on ["changes"] for + details of what is different. The breaking changes here have been transitioned + through the [`legacy_imports`] lint since 1.14, with no known regressions. +* [In `macro_rules`, `path` fragments can now be parsed as type parameter + bounds][38279] +* [`?Sized` can be used in `where` clauses][37791] +* [There is now a limit on the size of monomorphized types and it can be + modified with the `#![type_size_limit]` crate attribute, similarly to + the `#![recursion_limit]` attribute][37789] + +Compiler +-------- + +* [On Windows, the compiler will apply dllimport attributes when linking to + extern functions][37973]. Additional attributes and flags can control which + library kind is linked and its name. [RFC 1717]. +* [Rust-ABI symbols are no longer exported from cdylibs][38117] +* [The `--test` flag works with procedural macro crates][38107] +* [Fix `extern "aapcs" fn` ABI][37814] +* [The `-C no-stack-check` flag is deprecated][37636]. It does nothing. +* [The `format!` expander recognizes incorrect `printf` and shell-style + formatting directives and suggests the correct format][37613]. +* [Only report one error for all unused imports in an import list][37456] + +Compiler Performance +-------------------- + +* [Avoid unnecessary `mk_ty` calls in `Ty::super_fold_with`][37705] +* [Avoid more unnecessary `mk_ty` calls in `Ty::super_fold_with`][37979] +* [Don't clone in `UnificationTable::probe`][37848] +* [Remove `scope_auxiliary` to cut RSS by 10%][37764] +* [Use small vectors in type walker][37760] +* [Macro expansion performance was improved][37701] +* [Change `HirVec>` to `HirVec` in `hir::Expr`][37642] +* [Replace FNV with a faster hash function][37229] + +Stabilized APIs +--------------- + +* [`std::iter::Iterator::min_by`] +* [`std::iter::Iterator::max_by`] +* [`std::os::*::fs::FileExt`] +* [`std::sync::atomic::Atomic*::get_mut`] +* [`std::sync::atomic::Atomic*::into_inner`] +* [`std::vec::IntoIter::as_slice`] +* [`std::vec::IntoIter::as_mut_slice`] +* [`std::sync::mpsc::Receiver::try_iter`] +* [`std::os::unix::process::CommandExt::before_exec`] +* [`std::rc::Rc::strong_count`] +* [`std::rc::Rc::weak_count`] +* [`std::sync::Arc::strong_count`] +* [`std::sync::Arc::weak_count`] +* [`std::char::encode_utf8`] +* [`std::char::encode_utf16`] +* [`std::cell::Ref::clone`] +* [`std::io::Take::into_inner`] + +Libraries +--------- + +* [The standard sorting algorithm has been rewritten for dramatic performance + improvements][38192]. It is a hybrid merge sort, drawing influences from + Timsort. Previously it was a naive merge sort. +* [`Iterator::nth` no longer has a `Sized` bound][38134] +* [`Extend<&T>` is specialized for `Vec` where `T: Copy`][38182] to improve + performance. +* [`chars().count()` is much faster][37888] and so are [`chars().last()` + and `char_indices().last()`][37882] +* [Fix ARM Objective-C ABI in `std::env::args`][38146] +* [Chinese characters display correctly in `fmt::Debug`][37855] +* [Derive `Default` for `Duration`][37699] +* [Support creation of anonymous pipes on WinXP/2k][37677] +* [`mpsc::RecvTimeoutError` implements `Error`][37527] +* [Don't pass overlapped handles to processes][38835] + +Cargo +----- + +* [In this release, Cargo build scripts no longer have access to the `OUT_DIR` + environment variable at build time via `env!("OUT_DIR")`][cargo/3368]. They + should instead check the variable at runtime with `std::env`. That the value + was set at build time was a bug, and incorrect when cross-compiling. This + change is known to cause breakage. +* [Add `--all` flag to `cargo test`][cargo/3221] +* [Compile statically against the MSVC CRT][cargo/3363] +* [Mix feature flags into fingerprint/metadata shorthash][cargo/3102] +* [Link OpenSSL statically on OSX][cargo/3311] +* [Apply new fingerprinting to build dir outputs][cargo/3310] +* [Test for bad path overrides with summaries][cargo/3336] +* [Require `cargo install --vers` to take a semver version][cargo/3338] +* [Fix retrying crate downloads for network errors][cargo/3348] +* [Implement string lookup for `build.rustflags` config key][cargo/3356] +* [Emit more info on --message-format=json][cargo/3319] +* [Assume `build.rs` in the same directory as `Cargo.toml` is a build script][cargo/3361] +* [Don't ignore errors in workspace manifest][cargo/3409] +* [Fix `--message-format JSON` when rustc emits non-JSON warnings][cargo/3410] + +Tooling +------- + +* [Test runners (binaries built with `--test`) now support a `--list` argument + that lists the tests it contains][38185] +* [Test runners now support a `--exact` argument that makes the test filter + match exactly, instead of matching only a substring of the test name][38181] +* [rustdoc supports a `--playground-url` flag][37763] +* [rustdoc provides more details about `#[should_panic]` errors][37749] + +Misc +---- + +* [The Rust build system is now written in Rust][37817]. The Makefiles may + continue to be used in this release by passing `--disable-rustbuild` to the + configure script, but they will be deleted soon. Note that the new build + system uses a different on-disk layout that will likely affect any scripts + building Rust. +* [Rust supports i686-unknown-openbsd][38086]. Tier 3 support. No testing or + releases. +* [Rust supports the MSP430][37627]. Tier 3 support. No testing or releases. +* [Rust supports the ARMv5TE architecture][37615]. Tier 3 support. No testing or + releases. + +Compatibility Notes +------------------- + +* [A number of minor changes to name resolution have been activated][37127]. + They add up to more consistent semantics, allowing for future evolution of + Rust macros. Specified in [RFC 1560], see its section on ["changes"] for + details of what is different. The breaking changes here have been transitioned + through the [`legacy_imports`] lint since 1.14, with no known regressions. +* [In this release, Cargo build scripts no longer have access to the `OUT_DIR` + environment variable at build time via `env!("OUT_DIR")`][cargo/3368]. They + should instead check the variable at runtime with `std::env`. That the value + was set at build time was a bug, and incorrect when cross-compiling. This + change is known to cause breakage. +* [Higher-ranked lifetimes are no longer allowed to appear _only_ in associated + types][33685]. The [`hr_lifetime_in_assoc_type` lint] has been a warning since + 1.10 and is now an error by default. It will become a hard error in the near + future. +* [The semantics relating modules to file system directories are changing in + minor ways][37602]. This is captured in the new `legacy_directory_ownership` + lint, which is a warning in this release, and will become a hard error in the + future. +* [Rust-ABI symbols are no longer exported from cdylibs][38117] +* [Once `Peekable` peeks a `None` it will return that `None` without re-querying + the underlying iterator][37834] + +["changes"]: https://github.com/rust-lang/rfcs/blob/master/text/1560-name-resolution.md#changes-to-name-resolution-rules +[33685]: https://github.com/rust-lang/rust/issues/33685 +[36868]: https://github.com/rust-lang/rust/pull/36868 +[37127]: https://github.com/rust-lang/rust/pull/37127 +[37229]: https://github.com/rust-lang/rust/pull/37229 +[37456]: https://github.com/rust-lang/rust/pull/37456 +[37527]: https://github.com/rust-lang/rust/pull/37527 +[37602]: https://github.com/rust-lang/rust/pull/37602 +[37613]: https://github.com/rust-lang/rust/pull/37613 +[37615]: https://github.com/rust-lang/rust/pull/37615 +[37636]: https://github.com/rust-lang/rust/pull/37636 +[37642]: https://github.com/rust-lang/rust/pull/37642 +[37677]: https://github.com/rust-lang/rust/pull/37677 +[37699]: https://github.com/rust-lang/rust/pull/37699 +[37701]: https://github.com/rust-lang/rust/pull/37701 +[37705]: https://github.com/rust-lang/rust/pull/37705 +[37749]: https://github.com/rust-lang/rust/pull/37749 +[37760]: https://github.com/rust-lang/rust/pull/37760 +[37763]: https://github.com/rust-lang/rust/pull/37763 +[37764]: https://github.com/rust-lang/rust/pull/37764 +[37789]: https://github.com/rust-lang/rust/pull/37789 +[37791]: https://github.com/rust-lang/rust/pull/37791 +[37814]: https://github.com/rust-lang/rust/pull/37814 +[37817]: https://github.com/rust-lang/rust/pull/37817 +[37834]: https://github.com/rust-lang/rust/pull/37834 +[37848]: https://github.com/rust-lang/rust/pull/37848 +[37855]: https://github.com/rust-lang/rust/pull/37855 +[37882]: https://github.com/rust-lang/rust/pull/37882 +[37888]: https://github.com/rust-lang/rust/pull/37888 +[37973]: https://github.com/rust-lang/rust/pull/37973 +[37979]: https://github.com/rust-lang/rust/pull/37979 +[38086]: https://github.com/rust-lang/rust/pull/38086 +[38107]: https://github.com/rust-lang/rust/pull/38107 +[38117]: https://github.com/rust-lang/rust/pull/38117 +[38134]: https://github.com/rust-lang/rust/pull/38134 +[38146]: https://github.com/rust-lang/rust/pull/38146 +[38181]: https://github.com/rust-lang/rust/pull/38181 +[38182]: https://github.com/rust-lang/rust/pull/38182 +[38185]: https://github.com/rust-lang/rust/pull/38185 +[38192]: https://github.com/rust-lang/rust/pull/38192 +[38279]: https://github.com/rust-lang/rust/pull/38279 +[38835]: https://github.com/rust-lang/rust/pull/38835 +[RFC 1492]: https://github.com/rust-lang/rfcs/blob/master/text/1492-dotdot-in-patterns.md +[RFC 1506]: https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md +[RFC 1560]: https://github.com/rust-lang/rfcs/blob/master/text/1560-name-resolution.md +[RFC 1681]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md +[RFC 1717]: https://github.com/rust-lang/rfcs/blob/master/text/1717-dllimport.md +[`hr_lifetime_in_assoc_type` lint]: https://github.com/rust-lang/rust/issues/33685 +[`legacy_imports`]: https://github.com/rust-lang/rust/pull/38271 +[cargo/3102]: https://github.com/rust-lang/cargo/pull/3102 +[cargo/3221]: https://github.com/rust-lang/cargo/pull/3221 +[cargo/3310]: https://github.com/rust-lang/cargo/pull/3310 +[cargo/3311]: https://github.com/rust-lang/cargo/pull/3311 +[cargo/3319]: https://github.com/rust-lang/cargo/pull/3319 +[cargo/3336]: https://github.com/rust-lang/cargo/pull/3336 +[cargo/3338]: https://github.com/rust-lang/cargo/pull/3338 +[cargo/3348]: https://github.com/rust-lang/cargo/pull/3348 +[cargo/3356]: https://github.com/rust-lang/cargo/pull/3356 +[cargo/3361]: https://github.com/rust-lang/cargo/pull/3361 +[cargo/3363]: https://github.com/rust-lang/cargo/pull/3363 +[cargo/3368]: https://github.com/rust-lang/cargo/issues/3368 +[cargo/3409]: https://github.com/rust-lang/cargo/pull/3409 +[cargo/3410]: https://github.com/rust-lang/cargo/pull/3410 +[`std::iter::Iterator::min_by`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.min_by +[`std::iter::Iterator::max_by`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.max_by +[`std::os::*::fs::FileExt`]: https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html +[`std::sync::atomic::Atomic*::get_mut`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU8.html#method.get_mut +[`std::sync::atomic::Atomic*::into_inner`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU8.html#method.into_inner +[`std::vec::IntoIter::as_slice`]: https://doc.rust-lang.org/std/vec/struct.IntoIter.html#method.as_slice +[`std::vec::IntoIter::as_mut_slice`]: https://doc.rust-lang.org/std/vec/struct.IntoIter.html#method.as_mut_slice +[`std::sync::mpsc::Receiver::try_iter`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html#method.try_iter +[`std::os::unix::process::CommandExt::before_exec`]: https://doc.rust-lang.org/std/os/unix/process/trait.CommandExt.html#tymethod.before_exec +[`std::rc::Rc::strong_count`]: https://doc.rust-lang.org/std/rc/struct.Rc.html#method.strong_count +[`std::rc::Rc::weak_count`]: https://doc.rust-lang.org/std/rc/struct.Rc.html#method.weak_count +[`std::sync::Arc::strong_count`]: https://doc.rust-lang.org/std/sync/struct.Arc.html#method.strong_count +[`std::sync::Arc::weak_count`]: https://doc.rust-lang.org/std/sync/struct.Arc.html#method.weak_count +[`std::char::encode_utf8`]: https://doc.rust-lang.org/std/primitive.char.html#method.encode_utf8 +[`std::char::encode_utf16`]: https://doc.rust-lang.org/std/primitive.char.html#method.encode_utf16 +[`std::cell::Ref::clone`]: https://doc.rust-lang.org/std/cell/struct.Ref.html#method.clone +[`std::io::Take::into_inner`]: https://doc.rust-lang.org/std/io/struct.Take.html#method.into_inner + + Version 1.14.0 (2016-12-22) =========================== From d25f066c07a88a5eeff1e3e8799a12ffe844e959 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 17 Jan 2017 18:15:08 -0500 Subject: [PATCH 23/37] run rustdoc tests in the same sort of thread rustc runs in --- src/librustc_driver/lib.rs | 44 ++++++++++++++++++++++++-------------- src/librustdoc/test.rs | 35 ++++++++++++++++++------------ 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 25049b3d2badb..48eb6f68564f0 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -82,6 +82,7 @@ use rustc::util::common::time; use serialize::json::ToJson; +use std::any::Any; use std::cmp::max; use std::cmp::Ordering::Equal; use std::default::Default; @@ -1018,15 +1019,34 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec(f: F) -> Result> + where F: FnOnce() -> R + Send + 'static, + R: Send + 'static, +{ + // Temporarily have stack size set to 16MB to deal with nom-using crates failing + const STACK_SIZE: usize = 16 * 1024 * 1024; // 16MB + + let mut cfg = thread::Builder::new().name("rustc".to_string()); + + // FIXME: Hacks on hacks. If the env is trying to override the stack size + // then *don't* set it explicitly. + if env::var_os("RUST_MIN_STACK").is_none() { + cfg = cfg.stack_size(STACK_SIZE); + } + + let thread = cfg.spawn(f); + thread.unwrap().join() +} + /// Run a procedure which will detect panics in the compiler and print nicer /// error messages rather than just failing the test. /// /// The diagnostic emitter yielded to the procedure should be used for reporting /// errors of the compiler. pub fn monitor(f: F) { - // Temporarily have stack size set to 16MB to deal with nom-using crates failing - const STACK_SIZE: usize = 16 * 1024 * 1024; // 16MB - struct Sink(Arc>>); impl Write for Sink { fn write(&mut self, data: &[u8]) -> io::Result { @@ -1040,20 +1060,12 @@ pub fn monitor(f: F) { let data = Arc::new(Mutex::new(Vec::new())); let err = Sink(data.clone()); - let mut cfg = thread::Builder::new().name("rustc".to_string()); - - // FIXME: Hacks on hacks. If the env is trying to override the stack size - // then *don't* set it explicitly. - if env::var_os("RUST_MIN_STACK").is_none() { - cfg = cfg.stack_size(STACK_SIZE); - } - - let thread = cfg.spawn(move || { - io::set_panic(Some(box err)); - f() - }); + let result = in_rustc_thread(move || { + io::set_panic(Some(box err)); + f() + }); - if let Err(value) = thread.unwrap().join() { + if let Err(value) = result { // Thread panicked without emitting a fatal diagnostic if !value.is::() { let emitter = diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index c242eea236217..ea077e97a7efa 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -29,7 +29,7 @@ use rustc::session::config::{OutputType, OutputTypes, Externs}; use rustc::session::search_paths::{SearchPaths, PathKind}; use rustc_back::dynamic_lib::DynamicLibrary; use rustc_back::tempdir::TempDir; -use rustc_driver::{driver, Compilation}; +use rustc_driver::{self, driver, Compilation}; use rustc_driver::driver::phase_2_configure_and_expand; use rustc_metadata::cstore::CStore; use rustc_resolve::MakeGlobMap; @@ -428,19 +428,26 @@ impl Collector { should_panic: testing::ShouldPanic::No, }, testfn: testing::DynTestFn(box move |()| { - runtest(&test, - &cratename, - cfgs, - libs, - externs, - should_panic, - no_run, - as_test_harness, - compile_fail, - error_codes, - &opts, - maybe_sysroot); - }) + match { + rustc_driver::in_rustc_thread(move || { + runtest(&test, + &cratename, + cfgs, + libs, + externs, + should_panic, + no_run, + as_test_harness, + compile_fail, + error_codes, + &opts, + maybe_sysroot) + }) + } { + Ok(()) => (), + Err(err) => panic::resume_unwind(err), + } + }), }); } From f57d5ad7e11007a50db56ebdbdde3fb7f4efd2c1 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 17 Jan 2017 18:29:55 -0500 Subject: [PATCH 24/37] check inherent impls of traits for overlap as well --- src/librustc_typeck/coherence/overlap.rs | 1 + ...coherence-overlapping-inherent-impl-trait.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/test/compile-fail/coherence-overlapping-inherent-impl-trait.rs diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index 08293c1d874a8..7890ae20ec26c 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -102,6 +102,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> { match item.node { hir::ItemEnum(..) | hir::ItemStruct(..) | + hir::ItemTrait(..) | hir::ItemUnion(..) => { let type_def_id = self.tcx.map.local_def_id(item.id); self.check_for_overlapping_inherent_impls(type_def_id); diff --git a/src/test/compile-fail/coherence-overlapping-inherent-impl-trait.rs b/src/test/compile-fail/coherence-overlapping-inherent-impl-trait.rs new file mode 100644 index 0000000000000..a611b22e93de8 --- /dev/null +++ b/src/test/compile-fail/coherence-overlapping-inherent-impl-trait.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +#![deny(overlapping_inherent_impls)] + +trait C {} +impl C { fn f() {} } //~ ERROR duplicate definitions with name `f` +impl C { fn f() {} } +fn main() { } From 92e98a06d4443b9f2d108d754d3a11761a0ae7bc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 17 Jan 2017 18:55:24 -0800 Subject: [PATCH 25/37] travis: Fix post-failure lldb invocation Pass an absolute path, not just the basename. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index abd0a8fe346f0..b2ff5bb0f4e9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ matrix: echo 'bt all' > cmds; for file in $(ls /cores); do echo core file $file; - lldb -c $file `which ld` -b -s cmds; + lldb -c /cores/$file `which ld` -b -s cmds; done - env: > From deeba3443e186628fca98e7b74a0ac0616c5fa2d Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 18 Jan 2017 11:24:43 -0500 Subject: [PATCH 26/37] Add regression test for debuginfo + LTO --- .../run-pass/auxiliary/debuginfo-lto-aux.rs | 39 +++++++++++++++++++ src/test/run-pass/auxiliary/sepcomp_lib.rs | 2 +- src/test/run-pass/debuginfo-lto.rs | 33 ++++++++++++++++ src/test/run-pass/sepcomp-lib-lto.rs | 2 +- 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/auxiliary/debuginfo-lto-aux.rs create mode 100644 src/test/run-pass/debuginfo-lto.rs diff --git a/src/test/run-pass/auxiliary/debuginfo-lto-aux.rs b/src/test/run-pass/auxiliary/debuginfo-lto-aux.rs new file mode 100644 index 0000000000000..88e54d30172bc --- /dev/null +++ b/src/test/run-pass/auxiliary/debuginfo-lto-aux.rs @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -g --crate-type=rlib + +pub struct StructWithLifetime<'a>(&'a i32); +pub fn mk_struct_with_lt<'a>(x: &'a i32) -> StructWithLifetime<'a> { + StructWithLifetime(x) +} + +pub struct RegularStruct(u32); +pub fn mk_regular_struct(x: u32) -> RegularStruct { + RegularStruct(x) +} + +pub fn take_fn(f: fn(i32) -> i32, x: i32) -> i32 { + f(x) +} + +pub fn with_closure(x: i32) -> i32 { + let closure = |i| { x + i }; + + closure(1) + closure(2) +} + +pub fn generic_fn(x: T) -> (T, u32) { + (x, 1) +} + +pub fn user_of_generic_fn(x: f32) -> (f32, u32) { + generic_fn(x) +} diff --git a/src/test/run-pass/auxiliary/sepcomp_lib.rs b/src/test/run-pass/auxiliary/sepcomp_lib.rs index 9aa16fb269457..6f48978a0000d 100644 --- a/src/test/run-pass/auxiliary/sepcomp_lib.rs +++ b/src/test/run-pass/auxiliary/sepcomp_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags: -C codegen-units=3 --crate-type=rlib,dylib +// compile-flags: -C codegen-units=3 --crate-type=rlib,dylib -g pub mod a { pub fn one() -> usize { diff --git a/src/test/run-pass/debuginfo-lto.rs b/src/test/run-pass/debuginfo-lto.rs new file mode 100644 index 0000000000000..c29cfafe438ca --- /dev/null +++ b/src/test/run-pass/debuginfo-lto.rs @@ -0,0 +1,33 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test case makes sure that we don't run into LLVM's dreaded +// "possible ODR violation" assertion when compiling with LTO + Debuginfo. +// It covers cases that have traditionally been prone to cause this error. +// If new cases emerge, add them to this file. + +// aux-build:debuginfo-lto-aux.rs +// compile-flags: -C lto -g +// no-prefer-dynamic + +extern crate debuginfo_lto_aux; + +fn some_fn(x: i32) -> i32 { + x + 1 +} + +fn main() { + let i = 0; + let _ = debuginfo_lto_aux::mk_struct_with_lt(&i); + let _ = debuginfo_lto_aux::mk_regular_struct(1); + let _ = debuginfo_lto_aux::take_fn(some_fn, 1); + let _ = debuginfo_lto_aux::with_closure(22); + let _ = debuginfo_lto_aux::generic_fn(0f32); +} diff --git a/src/test/run-pass/sepcomp-lib-lto.rs b/src/test/run-pass/sepcomp-lib-lto.rs index b159b128333f0..f3e52fbd32f3e 100644 --- a/src/test/run-pass/sepcomp-lib-lto.rs +++ b/src/test/run-pass/sepcomp-lib-lto.rs @@ -12,7 +12,7 @@ // separately compiled. // aux-build:sepcomp_lib.rs -// compile-flags: -C lto +// compile-flags: -C lto -g // no-prefer-dynamic // ignore-android FIXME #18800 From 265bd53fe943a5af712bf99b35373459bbcd3014 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 19 Jan 2017 09:01:52 +0900 Subject: [PATCH 27/37] Update jemalloc to include various fixes for OSX 10.12 --- src/jemalloc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jemalloc b/src/jemalloc index e058ca661692a..11bfb0dcf85f7 160000 --- a/src/jemalloc +++ b/src/jemalloc @@ -1 +1 @@ -Subproject commit e058ca661692a8d01f8cf9d35939dfe3105ce968 +Subproject commit 11bfb0dcf85f7aa92abd30524bb1e42e18d108c6 From c457b819d7ef4749bd20a1d6ada93d1fdc59bf59 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 18 Jan 2017 16:10:05 -0800 Subject: [PATCH 28/37] travis: Stop uploading sha256 files We'll generate these later in the build process and otherwise they could just cause spurious failures with files overwriting one another. --- .travis.yml | 6 ++---- appveyor.yml | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index abd0a8fe346f0..83f5691c746e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -119,11 +119,9 @@ before_deploy: - mkdir -p deploy/$TRAVIS_COMMIT - > if [ "$TRAVIS_OS_NAME" == "osx" ]; then - cp build/dist/*.tar.gz deploy/$TRAVIS_COMMIT && - find "deploy/$TRAVIS_COMMIT" -maxdepth 1 -type f -exec sh -c 'shasum -a 256 -b "{}" > "{}.sha256"' \;; + cp build/dist/*.tar.gz deploy/$TRAVIS_COMMIT; else - cp obj/build/dist/*.tar.gz deploy/$TRAVIS_COMMIT && - find "deploy/$TRAVIS_COMMIT" -maxdepth 1 -type f -exec sh -c 'sha256sum -b "{}" > "{}.sha256"' \;; + cp obj/build/dist/*.tar.gz deploy/$TRAVIS_COMMIT; fi deploy: diff --git a/appveyor.yml b/appveyor.yml index 346ef0d8faad7..9f3e9d703f11c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -131,9 +131,6 @@ before_deploy: - ps: | New-Item -Path deploy -ItemType directory Get-ChildItem -Path build\dist -Filter '*.tar.gz' | Move-Item -Destination deploy - Get-FileHash .\deploy\* | ForEach-Object { - [io.file]::WriteAllText($_.Path + ".sha256", $_.Hash.ToLower() + "`n") - } Get-ChildItem -Path deploy | Foreach-Object { Push-AppveyorArtifact $_.FullName -FileName ${env:APPVEYOR_REPO_COMMIT}/$_ } @@ -147,7 +144,7 @@ deploy: bucket: rust-lang-ci set_public: true region: us-east-1 - artifact: /.*\.(tar.gz|sha256)/ + artifact: /.*\.tar.gz/ folder: rustc-builds on: branch: auto From 2883186180161185e72b8fa183b75c8854eb5db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 18 Jan 2017 16:33:25 -0800 Subject: [PATCH 29/37] Use multiline Diagnostic for candidate in other module --- src/librustc_resolve/lib.rs | 33 ++++++++++--------- .../ui/resolve/enums-are-namespaced-xc.stderr | 6 ++-- src/test/ui/resolve/issue-16058.stderr | 6 ++-- src/test/ui/resolve/issue-17518.stderr | 2 +- src/test/ui/resolve/issue-21221-1.stderr | 18 +++++----- src/test/ui/resolve/issue-21221-2.stderr | 2 +- src/test/ui/resolve/issue-21221-3.stderr | 2 +- src/test/ui/resolve/issue-21221-4.stderr | 2 +- src/test/ui/resolve/issue-3907.stderr | 2 +- src/test/ui/span/issue-35987.stderr | 2 +- 10 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 56e8c75b859a1..fabc8790c2a6d 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -67,6 +67,7 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan}; use errors::DiagnosticBuilder; use std::cell::{Cell, RefCell}; +use std::cmp; use std::fmt; use std::mem::replace; use std::rc::Rc; @@ -3224,7 +3225,7 @@ fn show_candidates(session: &mut DiagnosticBuilder, better: bool) { // don't show more than MAX_CANDIDATES results, so // we're consistent with the trait suggestions - const MAX_CANDIDATES: usize = 5; + const MAX_CANDIDATES: usize = 4; // we want consistent results across executions, but candidates are produced // by iterating through a hash map, so make sure they are ordered: @@ -3237,21 +3238,21 @@ fn show_candidates(session: &mut DiagnosticBuilder, 1 => " is found in another module, you can import it", _ => "s are found in other modules, you can import them", }; - session.help(&format!("possible {}candidate{} into scope:", better, msg_diff)); - - let count = path_strings.len() as isize - MAX_CANDIDATES as isize + 1; - for (idx, path_string) in path_strings.iter().enumerate() { - if idx == MAX_CANDIDATES - 1 && count > 1 { - session.help( - &format!(" and {} other candidates", count).to_string(), - ); - break; - } else { - session.help( - &format!(" `use {};`", path_string).to_string(), - ); - } - } + + let end = cmp::min(MAX_CANDIDATES, path_strings.len()); + session.help(&format!("possible {}candidate{} into scope:{}{}", + better, + msg_diff, + &path_strings[0..end].iter().map(|candidate| { + format!("\n `use {};`", candidate) + }).collect::(), + if path_strings.len() > MAX_CANDIDATES { + format!("\nand {} other candidates", + path_strings.len() - MAX_CANDIDATES) + } else { + "".to_owned() + } + )); } /// A somewhat inefficient routine to obtain the name of a module. diff --git a/src/test/ui/resolve/enums-are-namespaced-xc.stderr b/src/test/ui/resolve/enums-are-namespaced-xc.stderr index 204c574a3a996..d541aa599a48b 100644 --- a/src/test/ui/resolve/enums-are-namespaced-xc.stderr +++ b/src/test/ui/resolve/enums-are-namespaced-xc.stderr @@ -5,7 +5,7 @@ error[E0425]: cannot find value `A` in module `namespaced_enums` | ^^^^^^^^^^^^^^^^^^^ not found in `namespaced_enums` | = help: possible candidate is found in another module, you can import it into scope: - = help: `use namespaced_enums::Foo::A;` + `use namespaced_enums::Foo::A;` error[E0425]: cannot find function `B` in module `namespaced_enums` --> $DIR/enums-are-namespaced-xc.rs:18:13 @@ -14,7 +14,7 @@ error[E0425]: cannot find function `B` in module `namespaced_enums` | ^^^^^^^^^^^^^^^^^^^ not found in `namespaced_enums` | = help: possible candidate is found in another module, you can import it into scope: - = help: `use namespaced_enums::Foo::B;` + `use namespaced_enums::Foo::B;` error[E0422]: cannot find struct, variant or union type `C` in module `namespaced_enums` --> $DIR/enums-are-namespaced-xc.rs:21:13 @@ -23,7 +23,7 @@ error[E0422]: cannot find struct, variant or union type `C` in module `namespace | ^^^^^^^^^^^^^^^^^^^ not found in `namespaced_enums` | = help: possible candidate is found in another module, you can import it into scope: - = help: `use namespaced_enums::Foo::C;` + `use namespaced_enums::Foo::C;` error: aborting due to 3 previous errors diff --git a/src/test/ui/resolve/issue-16058.stderr b/src/test/ui/resolve/issue-16058.stderr index 6b00cfb869316..69c48cc1f3241 100644 --- a/src/test/ui/resolve/issue-16058.stderr +++ b/src/test/ui/resolve/issue-16058.stderr @@ -5,9 +5,9 @@ error[E0574]: expected struct, variant or union type, found enum `Result` | ^^^^^^ not a struct, variant or union type | = help: possible better candidates are found in other modules, you can import them into scope: - = help: `use std::fmt::Result;` - = help: `use std::io::Result;` - = help: `use std::thread::Result;` + `use std::fmt::Result;` + `use std::io::Result;` + `use std::thread::Result;` error: aborting due to previous error diff --git a/src/test/ui/resolve/issue-17518.stderr b/src/test/ui/resolve/issue-17518.stderr index 335510ed7e9d5..ea6841e600972 100644 --- a/src/test/ui/resolve/issue-17518.stderr +++ b/src/test/ui/resolve/issue-17518.stderr @@ -5,7 +5,7 @@ error[E0422]: cannot find struct, variant or union type `E` in this scope | ^ not found in this scope | = help: possible candidate is found in another module, you can import it into scope: - = help: `use SomeEnum::E;` + `use SomeEnum::E;` error: aborting due to previous error diff --git a/src/test/ui/resolve/issue-21221-1.stderr b/src/test/ui/resolve/issue-21221-1.stderr index d9c2f9e681eee..f38491d536258 100644 --- a/src/test/ui/resolve/issue-21221-1.stderr +++ b/src/test/ui/resolve/issue-21221-1.stderr @@ -5,9 +5,9 @@ error[E0405]: cannot find trait `Mul` in this scope | ^^^ not found in this scope | = help: possible candidates are found in other modules, you can import them into scope: - = help: `use mul1::Mul;` - = help: `use mul2::Mul;` - = help: `use std::ops::Mul;` + `use mul1::Mul;` + `use mul2::Mul;` + `use std::ops::Mul;` error[E0412]: cannot find type `Mul` in this scope --> $DIR/issue-21221-1.rs:72:16 @@ -16,11 +16,11 @@ error[E0412]: cannot find type `Mul` in this scope | ^^^ not found in this scope | = help: possible candidates are found in other modules, you can import them into scope: - = help: `use mul1::Mul;` - = help: `use mul2::Mul;` - = help: `use mul3::Mul;` - = help: `use mul4::Mul;` - = help: and 2 other candidates + `use mul1::Mul;` + `use mul2::Mul;` + `use mul3::Mul;` + `use mul4::Mul;` + and 2 other candidates error[E0405]: cannot find trait `ThisTraitReallyDoesntExistInAnyModuleReally` in this scope --> $DIR/issue-21221-1.rs:83:6 @@ -35,7 +35,7 @@ error[E0405]: cannot find trait `Div` in this scope | ^^^ not found in this scope | = help: possible candidate is found in another module, you can import it into scope: - = help: `use std::ops::Div;` + `use std::ops::Div;` error: cannot continue compilation due to previous error diff --git a/src/test/ui/resolve/issue-21221-2.stderr b/src/test/ui/resolve/issue-21221-2.stderr index eb5b1ab6918a9..14dac7de4b2e1 100644 --- a/src/test/ui/resolve/issue-21221-2.stderr +++ b/src/test/ui/resolve/issue-21221-2.stderr @@ -5,7 +5,7 @@ error[E0405]: cannot find trait `T` in this scope | ^ not found in this scope | = help: possible candidate is found in another module, you can import it into scope: - = help: `use foo::bar::T;` + `use foo::bar::T;` error: main function not found diff --git a/src/test/ui/resolve/issue-21221-3.stderr b/src/test/ui/resolve/issue-21221-3.stderr index 3594e9105a276..e1e00571e5d4a 100644 --- a/src/test/ui/resolve/issue-21221-3.stderr +++ b/src/test/ui/resolve/issue-21221-3.stderr @@ -5,7 +5,7 @@ error[E0405]: cannot find trait `OuterTrait` in this scope | ^^^^^^^^^^ not found in this scope | = help: possible candidate is found in another module, you can import it into scope: - = help: `use issue_21221_3::outer::OuterTrait;` + `use issue_21221_3::outer::OuterTrait;` error: cannot continue compilation due to previous error diff --git a/src/test/ui/resolve/issue-21221-4.stderr b/src/test/ui/resolve/issue-21221-4.stderr index 98486e5743cc9..569315a59cf34 100644 --- a/src/test/ui/resolve/issue-21221-4.stderr +++ b/src/test/ui/resolve/issue-21221-4.stderr @@ -5,7 +5,7 @@ error[E0405]: cannot find trait `T` in this scope | ^ not found in this scope | = help: possible candidate is found in another module, you can import it into scope: - = help: `use issue_21221_4::T;` + `use issue_21221_4::T;` error: cannot continue compilation due to previous error diff --git a/src/test/ui/resolve/issue-3907.stderr b/src/test/ui/resolve/issue-3907.stderr index 0a402680aa8be..a7dd494d75b0d 100644 --- a/src/test/ui/resolve/issue-3907.stderr +++ b/src/test/ui/resolve/issue-3907.stderr @@ -5,7 +5,7 @@ error[E0404]: expected trait, found type alias `Foo` | ^^^ type aliases cannot be used for traits | = help: possible better candidate is found in another module, you can import it into scope: - = help: `use issue_3907::Foo;` + `use issue_3907::Foo;` error: cannot continue compilation due to previous error diff --git a/src/test/ui/span/issue-35987.stderr b/src/test/ui/span/issue-35987.stderr index 764f34cabde9a..9dab2f7789815 100644 --- a/src/test/ui/span/issue-35987.stderr +++ b/src/test/ui/span/issue-35987.stderr @@ -5,7 +5,7 @@ error[E0404]: expected trait, found type parameter `Add` | ^^^ not a trait | = help: possible better candidate is found in another module, you can import it into scope: - = help: `use std::ops::Add;` + `use std::ops::Add;` error: main function not found From 853f6974767243e2e5defb43f5f7195ce1fb1cc7 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 19 Jan 2017 13:28:45 +0300 Subject: [PATCH 30/37] Fix regression in parsing of trait object types --- src/libsyntax/parse/parser.rs | 11 +++++++++-- src/test/parse-fail/bounds-obj-parens.rs | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/test/parse-fail/bounds-obj-parens.rs diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d1a683b0bd5b8..b5913daaa5b3c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1277,10 +1277,17 @@ impl<'a> Parser<'a> { "at least one type parameter bound \ must be specified"); } - if let TyKind::Path(None, ref path) = lhs.node { + + let mut lhs = lhs.unwrap(); + if let TyKind::Paren(ty) = lhs.node { + // We have to accept the first bound in parens for backward compatibility. + // Example: `(Bound) + Bound + Bound` + lhs = ty.unwrap(); + } + if let TyKind::Path(None, path) = lhs.node { let poly_trait_ref = PolyTraitRef { bound_lifetimes: Vec::new(), - trait_ref: TraitRef { path: path.clone(), ref_id: lhs.id }, + trait_ref: TraitRef { path: path, ref_id: lhs.id }, span: lhs.span, }; let poly_trait_ref = TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None); diff --git a/src/test/parse-fail/bounds-obj-parens.rs b/src/test/parse-fail/bounds-obj-parens.rs new file mode 100644 index 0000000000000..cbdffb4a2554e --- /dev/null +++ b/src/test/parse-fail/bounds-obj-parens.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A = Box<(Fn(D::Error) -> E) + 'static + Send + Sync>; // OK + +FAIL //~ ERROR From e8f9d2d43a190074d52a0df40725ebd2c0fb0a9e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 16 Jan 2017 23:10:00 -0800 Subject: [PATCH 31/37] travis: Get an emscripten builder online This commit adds a new entry to the Travis matrix which will execute emscripten test suites. Along the way it updates a few bits of the test suite to continue passing on emscripten, such as: * Ignoring i128/u128 tests as they're presumably just not working (didn't investigate as to why) * Disabling a few process tests (not working on emscripten) * Ignore some num tests in libstd (#39119) * Fix some warnings when compiling --- src/bootstrap/sanity.rs | 2 +- src/ci/docker/emscripten/Dockerfile | 41 +++++++++++++++++++ src/ci/docker/emscripten/build-emscripten.sh | 19 +++++++++ src/libstd/net/test.rs | 2 +- src/libstd/num.rs | 1 + src/test/codegen/fastcall-inreg.rs | 1 + src/test/compile-fail/asm-bad-clobber.rs | 1 + src/test/compile-fail/asm-in-bad-modifier.rs | 1 + src/test/compile-fail/asm-misplaced-option.rs | 1 + src/test/compile-fail/asm-out-assign-imm.rs | 1 + src/test/compile-fail/asm-out-no-modifier.rs | 1 + src/test/compile-fail/asm-out-read-uninit.rs | 1 + .../compile-fail/asm-src-loc-codegen-units.rs | 1 + src/test/compile-fail/asm-src-loc.rs | 2 + .../cdylib-deps-must-be-static.rs | 1 + .../macro-expanded-include/test.rs | 2 + .../abort-link-to-unwind-dylib.rs | 1 + src/test/compile-fail/two-allocators-3.rs | 1 + .../down-with-thread-dtors.rs | 1 + src/test/run-pass-valgrind/exit-flushes.rs | 1 + src/test/run-pass/i128-ffi.rs | 2 + src/test/run-pass/i128.rs | 3 ++ src/test/run-pass/stdio-is-blocking.rs | 2 + src/test/run-pass/try-wait.rs | 2 + src/test/run-pass/u128.rs | 3 ++ 25 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 src/ci/docker/emscripten/Dockerfile create mode 100755 src/ci/docker/emscripten/build-emscripten.sh diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index 66bdd5e00f43d..8e79c2d27d195 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -45,7 +45,7 @@ pub fn check(build: &mut Build) { let target = path.join(cmd); let mut cmd_alt = cmd.to_os_string(); cmd_alt.push(".exe"); - if target.exists() || + if target.is_file() || target.with_extension("exe").exists() || target.join(cmd_alt).exists() { return Some(target); diff --git a/src/ci/docker/emscripten/Dockerfile b/src/ci/docker/emscripten/Dockerfile new file mode 100644 index 0000000000000..84e12eb6c3e11 --- /dev/null +++ b/src/ci/docker/emscripten/Dockerfile @@ -0,0 +1,41 @@ +FROM ubuntu:16.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python \ + git \ + cmake \ + sudo \ + gdb \ + xz-utils \ + lib32stdc++6 + +ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 +RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ + tar xJf - -C /usr/local/bin --strip-components=1 + +RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ + dpkg -i dumb-init_*.deb && \ + rm dumb-init_*.deb +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +WORKDIR /tmp +COPY build-emscripten.sh /tmp/ +RUN ./build-emscripten.sh +ENV PATH=$PATH:/tmp/emsdk_portable +ENV PATH=$PATH:/tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin +ENV PATH=$PATH:/tmp/emsdk_portable/node/4.1.1_32bit/bin +ENV PATH=$PATH:/tmp/emsdk_portable/emscripten/tag-1.37.1 +ENV EMSCRIPTEN=/tmp/emsdk_portable/emscripten/tag-1.37.1 + +ENV RUST_CONFIGURE_ARGS --target=asmjs-unknown-emscripten + +# Run `emcc` first as it's got a prompt and doesn't actually do anything, after +# that's done with do the real build. +ENV SCRIPT emcc && \ + python2.7 ../x.py test --target asmjs-unknown-emscripten + diff --git a/src/ci/docker/emscripten/build-emscripten.sh b/src/ci/docker/emscripten/build-emscripten.sh new file mode 100755 index 0000000000000..2ce7a58ae6656 --- /dev/null +++ b/src/ci/docker/emscripten/build-emscripten.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +curl https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ + tar xzf - +source emsdk_portable/emsdk_env.sh +emsdk update +emsdk install --build=Release sdk-tag-1.37.1-32bit +emsdk activate --build=Release sdk-tag-1.37.1-32bit diff --git a/src/libstd/net/test.rs b/src/libstd/net/test.rs index 3f2eacda7d60e..aec3d901ece60 100644 --- a/src/libstd/net/test.rs +++ b/src/libstd/net/test.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[allow(dead_code)] // not used on emscripten +#![allow(warnings)] // not used on emscripten use env; use net::{SocketAddr, SocketAddrV4, SocketAddrV6, Ipv4Addr, Ipv6Addr, ToSocketAddrs}; diff --git a/src/libstd/num.rs b/src/libstd/num.rs index d1c2fc3d3fce9..5f83d077a1368 100644 --- a/src/libstd/num.rs +++ b/src/libstd/num.rs @@ -172,6 +172,7 @@ mod tests { macro_rules! test_checked_next_power_of_two { ($test_name:ident, $T:ident) => ( + #[cfg_attr(target_os = "emscripten", ignore)] // FIXME(#39119) fn $test_name() { #![test] assert_eq!((0 as $T).checked_next_power_of_two(), Some(1)); diff --git a/src/test/codegen/fastcall-inreg.rs b/src/test/codegen/fastcall-inreg.rs index e1dda4d2be084..1cbde9b1a7c77 100644 --- a/src/test/codegen/fastcall-inreg.rs +++ b/src/test/codegen/fastcall-inreg.rs @@ -53,6 +53,7 @@ // ignore-shave // ignore-wasm32 // ignore-wasm64 +// ignore-emscripten // compile-flags: -C no-prepopulate-passes diff --git a/src/test/compile-fail/asm-bad-clobber.rs b/src/test/compile-fail/asm-bad-clobber.rs index 85832ddefe25f..cb931329051f9 100644 --- a/src/test/compile-fail/asm-bad-clobber.rs +++ b/src/test/compile-fail/asm-bad-clobber.rs @@ -12,6 +12,7 @@ // ignore-arm // ignore-aarch64 // ignore-s390x +// ignore-emscripten #![feature(asm, rustc_attrs)] diff --git a/src/test/compile-fail/asm-in-bad-modifier.rs b/src/test/compile-fail/asm-in-bad-modifier.rs index a4d076fc90da2..7ba5beac21340 100644 --- a/src/test/compile-fail/asm-in-bad-modifier.rs +++ b/src/test/compile-fail/asm-in-bad-modifier.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-s390x +// ignore-emscripten #![feature(asm)] diff --git a/src/test/compile-fail/asm-misplaced-option.rs b/src/test/compile-fail/asm-misplaced-option.rs index fbfc20f8d048a..bafbf625e3517 100644 --- a/src/test/compile-fail/asm-misplaced-option.rs +++ b/src/test/compile-fail/asm-misplaced-option.rs @@ -12,6 +12,7 @@ // ignore-arm // ignore-aarch64 // ignore-s390x +// ignore-emscripten #![feature(asm, rustc_attrs)] diff --git a/src/test/compile-fail/asm-out-assign-imm.rs b/src/test/compile-fail/asm-out-assign-imm.rs index 1329959fe4938..161c0b977ff0c 100644 --- a/src/test/compile-fail/asm-out-assign-imm.rs +++ b/src/test/compile-fail/asm-out-assign-imm.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-s390x +// ignore-emscripten #![feature(asm)] diff --git a/src/test/compile-fail/asm-out-no-modifier.rs b/src/test/compile-fail/asm-out-no-modifier.rs index d610f9e344024..cb8fb19a7c7f0 100644 --- a/src/test/compile-fail/asm-out-no-modifier.rs +++ b/src/test/compile-fail/asm-out-no-modifier.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-s390x +// ignore-emscripten #![feature(asm)] diff --git a/src/test/compile-fail/asm-out-read-uninit.rs b/src/test/compile-fail/asm-out-read-uninit.rs index 360f89dda9ce3..42bff4c633aa9 100644 --- a/src/test/compile-fail/asm-out-read-uninit.rs +++ b/src/test/compile-fail/asm-out-read-uninit.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-s390x +// ignore-emscripten #![feature(asm)] diff --git a/src/test/compile-fail/asm-src-loc-codegen-units.rs b/src/test/compile-fail/asm-src-loc-codegen-units.rs index 79f0c436759b3..df1a6d52f5739 100644 --- a/src/test/compile-fail/asm-src-loc-codegen-units.rs +++ b/src/test/compile-fail/asm-src-loc-codegen-units.rs @@ -12,6 +12,7 @@ // ignore-stage1 // compile-flags: -C codegen-units=2 // error-pattern: build without -C codegen-units for more exact errors +// ignore-emscripten #![feature(asm)] diff --git a/src/test/compile-fail/asm-src-loc.rs b/src/test/compile-fail/asm-src-loc.rs index e3cece7c8f0db..59b47c2408d7d 100644 --- a/src/test/compile-fail/asm-src-loc.rs +++ b/src/test/compile-fail/asm-src-loc.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + #![feature(asm)] fn main() { diff --git a/src/test/compile-fail/cdylib-deps-must-be-static.rs b/src/test/compile-fail/cdylib-deps-must-be-static.rs index 4b160f26e92ca..853507cbc6d8a 100644 --- a/src/test/compile-fail/cdylib-deps-must-be-static.rs +++ b/src/test/compile-fail/cdylib-deps-must-be-static.rs @@ -11,6 +11,7 @@ // error-pattern: dependency `cdylib_dep` not found in rlib format // aux-build:cdylib-dep.rs // ignore-musl +// ignore-emscripten #![crate_type = "cdylib"] diff --git a/src/test/compile-fail/macro-expanded-include/test.rs b/src/test/compile-fail/macro-expanded-include/test.rs index e1e85ddb2c1b1..bcc2c10653f9c 100644 --- a/src/test/compile-fail/macro-expanded-include/test.rs +++ b/src/test/compile-fail/macro-expanded-include/test.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + #![feature(asm, rustc_attrs)] #![allow(unused)] diff --git a/src/test/compile-fail/panic-runtime/abort-link-to-unwind-dylib.rs b/src/test/compile-fail/panic-runtime/abort-link-to-unwind-dylib.rs index c3242a5082b62..1fd60b15a72ac 100644 --- a/src/test/compile-fail/panic-runtime/abort-link-to-unwind-dylib.rs +++ b/src/test/compile-fail/panic-runtime/abort-link-to-unwind-dylib.rs @@ -10,6 +10,7 @@ // compile-flags:-C panic=abort -C prefer-dynamic // ignore-musl - no dylibs here +// ignore-emscripten // error-pattern:`panic_unwind` is not compiled with this crate's panic strategy // This is a test where the local crate, compiled with `panic=abort`, links to diff --git a/src/test/compile-fail/two-allocators-3.rs b/src/test/compile-fail/two-allocators-3.rs index 7782d0e338ef4..965e4e0e2eabe 100644 --- a/src/test/compile-fail/two-allocators-3.rs +++ b/src/test/compile-fail/two-allocators-3.rs @@ -11,6 +11,7 @@ // aux-build:allocator1.rs // error-pattern: cannot link together two allocators // ignore-musl no dylibs on musl yet +// ignore-emscripten // We're linking std dynamically (via -C prefer-dynamic for this test) which // has an allocator and then we're also linking in a new allocator (allocator1) diff --git a/src/test/run-pass-valgrind/down-with-thread-dtors.rs b/src/test/run-pass-valgrind/down-with-thread-dtors.rs index 0bf10c67d9fc2..90c20444842f4 100644 --- a/src/test/run-pass-valgrind/down-with-thread-dtors.rs +++ b/src/test/run-pass-valgrind/down-with-thread-dtors.rs @@ -9,6 +9,7 @@ // except according to those terms. // no-prefer-dynamic +// ignore-emscripten thread_local!(static FOO: Foo = Foo); thread_local!(static BAR: Bar = Bar(1)); diff --git a/src/test/run-pass-valgrind/exit-flushes.rs b/src/test/run-pass-valgrind/exit-flushes.rs index 1897b92140182..b72d2659967c4 100644 --- a/src/test/run-pass-valgrind/exit-flushes.rs +++ b/src/test/run-pass-valgrind/exit-flushes.rs @@ -11,6 +11,7 @@ // no-prefer-dynamic // ignore-macos this needs valgrind 3.11 or higher; see // https://github.com/rust-lang/rust/pull/30365#issuecomment-165763679 +// ignore-emscripten use std::env; use std::process::{exit, Command}; diff --git a/src/test/run-pass/i128-ffi.rs b/src/test/run-pass/i128-ffi.rs index 3b5f4884d21e7..222f32754fb6b 100644 --- a/src/test/run-pass/i128-ffi.rs +++ b/src/test/run-pass/i128-ffi.rs @@ -20,6 +20,8 @@ // Ignore 32 bit targets: // ignore-x86, ignore-arm +// ignore-emscripten + #![feature(i128_type)] #[link(name = "rust_test_helpers", kind = "static")] diff --git a/src/test/run-pass/i128.rs b/src/test/run-pass/i128.rs index a4ff36d20e4fa..3eb1c95050267 100644 --- a/src/test/run-pass/i128.rs +++ b/src/test/run-pass/i128.rs @@ -10,6 +10,9 @@ // ignore-stage0 // ignore-stage1 + +// ignore-emscripten + #![feature(i128_type, test)] extern crate test; diff --git a/src/test/run-pass/stdio-is-blocking.rs b/src/test/run-pass/stdio-is-blocking.rs index 74170ca6506ec..448bb7de7727f 100644 --- a/src/test/run-pass/stdio-is-blocking.rs +++ b/src/test/run-pass/stdio-is-blocking.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + use std::env; use std::io::prelude::*; use std::process::Command; diff --git a/src/test/run-pass/try-wait.rs b/src/test/run-pass/try-wait.rs index fdaf0cfd5b0c8..d9826373cceb0 100644 --- a/src/test/run-pass/try-wait.rs +++ b/src/test/run-pass/try-wait.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten + #![feature(process_try_wait)] use std::env; diff --git a/src/test/run-pass/u128.rs b/src/test/run-pass/u128.rs index 53d726f1f663b..139d42e3a3524 100644 --- a/src/test/run-pass/u128.rs +++ b/src/test/run-pass/u128.rs @@ -10,6 +10,9 @@ // ignore-stage0 // ignore-stage1 + +// ignore-emscripten + #![feature(i128_type, test)] extern crate test; From 0a7420acd1097ce7cfc8ae3604e18177c9f9b403 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 18 Jan 2017 16:04:22 -0800 Subject: [PATCH 32/37] travis: Move glibc backwards in time This commit updates the compilers for many of the artifacts that we're producing on Travis. These compilers are all compiled by crosstool-ng as they're currently done for the images in which we're building all our cross compiled compilers. The purpose of this commit is that when we ship binaries the artifacts won't require a newer glibc, but rather be as compatible as possible with Linux distributions by working with a very old version of glibc. This commit always allocates a new matrix entry for the i686/x86_64 builder. This builder is dedicated to just producing artifacts and eventually we'll expand it to building other tools like Cargo and the RLS. The other builders testing i686 and x86_64 won't use these historical toolchains. --- .travis.yml | 5 +- src/ci/docker/README.md | 145 +++++ src/ci/docker/dist-arm-linux/Dockerfile | 81 ++- .../dist-arm-linux/arm-linux-gnueabi.config | 560 +++++++++++++++++ .../dist-arm-linux/arm-linux-gnueabihf.config | 561 +++++++++++++++++ .../dist-armv7-aarch64-linux/Dockerfile | 81 ++- .../aarch64-linux-gnu.config | 551 +++++++++++++++++ .../armv7-linux-gnueabihf.config | 569 ++++++++++++++++++ src/ci/docker/dist-x86-linux/Dockerfile | 83 +++ .../docker/dist-x86-linux/build-binutils.sh | 26 + src/ci/docker/dist-x86-linux/build-cmake.sh | 25 + src/ci/docker/dist-x86-linux/build-curl.sh | 43 ++ src/ci/docker/dist-x86-linux/build-gcc.sh | 31 + src/ci/docker/dist-x86-linux/build-git.sh | 24 + src/ci/docker/dist-x86-linux/build-openssl.sh | 27 + src/ci/docker/dist-x86-linux/build-python.sh | 30 + src/ci/docker/dist-x86-linux/shared.sh | 25 + src/ci/docker/run.sh | 1 + src/ci/run.sh | 23 +- 19 files changed, 2857 insertions(+), 34 deletions(-) create mode 100644 src/ci/docker/README.md create mode 100644 src/ci/docker/dist-arm-linux/arm-linux-gnueabi.config create mode 100644 src/ci/docker/dist-arm-linux/arm-linux-gnueabihf.config create mode 100644 src/ci/docker/dist-armv7-aarch64-linux/aarch64-linux-gnu.config create mode 100644 src/ci/docker/dist-armv7-aarch64-linux/armv7-linux-gnueabihf.config create mode 100644 src/ci/docker/dist-x86-linux/Dockerfile create mode 100755 src/ci/docker/dist-x86-linux/build-binutils.sh create mode 100755 src/ci/docker/dist-x86-linux/build-cmake.sh create mode 100755 src/ci/docker/dist-x86-linux/build-curl.sh create mode 100755 src/ci/docker/dist-x86-linux/build-gcc.sh create mode 100755 src/ci/docker/dist-x86-linux/build-git.sh create mode 100755 src/ci/docker/dist-x86-linux/build-openssl.sh create mode 100755 src/ci/docker/dist-x86-linux/build-python.sh create mode 100644 src/ci/docker/dist-x86-linux/shared.sh diff --git a/.travis.yml b/.travis.yml index abd0a8fe346f0..6facf7c18898a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,9 +23,10 @@ matrix: - env: IMAGE=dist-powerpc-linux DEPLOY=1 - env: IMAGE=dist-powerpc64-linux DEPLOY=1 - env: IMAGE=dist-s390x-linux-netbsd DEPLOY=1 - - env: IMAGE=i686-gnu DEPLOY=1 + - env: IMAGE=dist-x86-linux DEPLOY=1 + - env: IMAGE=i686-gnu - env: IMAGE=i686-gnu-nopt - - env: IMAGE=x86_64-gnu DEPLOY=1 + - env: IMAGE=x86_64-gnu - env: IMAGE=x86_64-gnu-full-bootstrap - env: IMAGE=x86_64-gnu-aux - env: IMAGE=x86_64-gnu-debug diff --git a/src/ci/docker/README.md b/src/ci/docker/README.md new file mode 100644 index 0000000000000..9a0a4c8cb530a --- /dev/null +++ b/src/ci/docker/README.md @@ -0,0 +1,145 @@ +# Docker images for CI + +This folder contains a bunch of docker images used by the continuous integration +(CI) of Rust. An script is accompanied (`run.sh`) with these images to actually +execute them. To test out an image execute: + +``` +./src/ci/docker/run.sh $image_name +``` + +for example: + +``` +./src/ci/docker/run.sh x86_64-gnu +``` + +Images will output artifacts in an `obj` dir at the root of a repository. + +## Cross toolchains + +A number of these images take quite a long time to compile as they're building +whole gcc toolchains to do cross builds with. Much of this is relatively +self-explanatory but some images use [crosstool-ng] which isn't quite as self +explanatory. Below is a description of where these `*.config` files come form, +how to generate them, and how the existing ones were generated. + +[crosstool-ng]: https://github.com/crosstool-ng/crosstool-ng + +### Generating a `.config` file + +If you have a `linux-cross` image lying around you can use that and skip the +next two steps. + +- First we spin up a container and copy `build_toolchain_root.sh` into it. All + these steps are outside the container: + +``` +# Note: We use ubuntu:15.10 because that's the "base" of linux-cross Docker +# image +$ docker run -it ubuntu:15.10 bash +$ docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +cfbec05ed730 ubuntu:15.10 "bash" 16 seconds ago Up 15 seconds drunk_murdock +$ docker cp build_toolchain_root.sh drunk_murdock:/ +``` + +- Then inside the container we build crosstool-ng by simply calling the bash + script we copied in the previous step: + +``` +$ bash build_toolchain_root.sh +``` + +- Now, inside the container run the following command to configure the + toolchain. To get a clue of which options need to be changed check the next + section and come back. + +``` +$ ct-ng menuconfig +``` + +- Finally, we retrieve the `.config` file from the container and give it a + meaningful name. This is done outside the container. + +``` +$ docker drunk_murdock:/.config arm-linux-gnueabi.config +``` + +- Now you can shutdown the container or repeat the two last steps to generate a + new `.config` file. + +### Toolchain configuration + +Changes on top of the default toolchain configuration used to generate the +`.config` files in this directory. The changes are formatted as follows: + +``` +$category > $option = $value -- $comment +``` + +### `arm-linux-gnueabi.config` + +For targets: `arm-unknown-linux-gnueabi` + +- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET} +- Target options > Target Architecture = arm +- Target options > Architecture level = armv6 -- (+) +- Target options > Floating point = software (no FPU) -- (\*) +- Operating System > Target OS = linux +- Operating System > Linux kernel version = 3.2.72 -- Precise kernel +- C-library > glibc version = 2.14.1 +- C compiler > gcc version = 4.9.3 +- C compiler > C++ = ENABLE -- to cross compile LLVM + +### `arm-linux-gnueabihf.config` + +For targets: `arm-unknown-linux-gnueabihf` + +- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET} +- Target options > Target Architecture = arm +- Target options > Architecture level = armv6 -- (+) +- Target options > Use specific FPU = vfp -- (+) +- Target options > Floating point = hardware (FPU) -- (\*) +- Target options > Default instruction set mode = arm -- (+) +- Operating System > Target OS = linux +- Operating System > Linux kernel version = 3.2.72 -- Precise kernel +- C-library > glibc version = 2.14.1 +- C compiler > gcc version = 4.9.3 +- C compiler > C++ = ENABLE -- to cross compile LLVM + +### `armv7-linux-gnueabihf.config` + +For targets: `armv7-unknown-linux-gnueabihf` + +- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET} +- Target options > Target Architecture = arm +- Target options > Suffix to the arch-part = v7 +- Target options > Architecture level = armv7-a -- (+) +- Target options > Use specific FPU = vfpv3-d16 -- (\*) +- Target options > Floating point = hardware (FPU) -- (\*) +- Target options > Default instruction set mode = thumb -- (\*) +- Operating System > Target OS = linux +- Operating System > Linux kernel version = 3.2.72 -- Precise kernel +- C-library > glibc version = 2.14.1 +- C compiler > gcc version = 4.9.3 +- C compiler > C++ = ENABLE -- to cross compile LLVM + +(\*) These options have been selected to match the configuration of the arm + toolchains shipped with Ubuntu 15.10 +(+) These options have been selected to match the gcc flags we use to compile C + libraries like jemalloc. See the mk/cfg/arm(v7)-uknown-linux-gnueabi{,hf}.mk + file in Rust's source code. + +## `aarch64-linux-gnu.config` + +For targets: `aarch64-unknown-linux-gnu` + +- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET} +- Target options > Target Architecture = arm +- Target options > Bitness = 64-bit +- Operating System > Target OS = linux +- Operating System > Linux kernel version = 4.2.6 +- C-library > glibc version = 2.17 -- aarch64 support was introduced in this version +- C compiler > gcc version = 5.2.0 +- C compiler > C++ = ENABLE -- to cross compile LLVM diff --git a/src/ci/docker/dist-arm-linux/Dockerfile b/src/ci/docker/dist-arm-linux/Dockerfile index 1aafc669d1023..4d21473ba7126 100644 --- a/src/ci/docker/dist-arm-linux/Dockerfile +++ b/src/ci/docker/dist-arm-linux/Dockerfile @@ -1,19 +1,29 @@ FROM ubuntu:16.04 RUN apt-get update && apt-get install -y --no-install-recommends \ + automake \ + bison \ + bzip2 \ + ca-certificates \ + cmake \ + curl \ + file \ + flex \ g++ \ + gawk \ + gdb \ + git \ + gperf \ + help2man \ + libncurses-dev \ + libtool-bin \ make \ - file \ - curl \ - ca-certificates \ + patch \ python2.7 \ - git \ - cmake \ sudo \ - gdb \ - xz-utils \ - g++-arm-linux-gnueabi \ - g++-arm-linux-gnueabihf + texinfo \ + wget \ + xz-utils ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ @@ -24,6 +34,59 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] +# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# toolchains we build below chokes on that, so go back to make 3 +RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ + cd make-3.81 && \ + ./configure --prefix=/usr && \ + make && \ + make install && \ + cd .. && \ + rm -rf make-3.81 + +RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ + tar xjf - && \ + cd crosstool-ng && \ + ./configure --prefix=/usr/local && \ + make -j$(nproc) && \ + make install && \ + cd .. && \ + rm -rf crosstool-ng + +RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild +RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +USER rustbuild +WORKDIR /tmp + +COPY arm-linux-gnueabi.config /tmp/ +RUN mkdir build && \ + cd build && \ + cp ../arm-linux-gnueabi.config .config && \ + ct-ng oldconfig && \ + ct-ng build && \ + cd .. && \ + rm -rf build +COPY arm-linux-gnueabihf.config /tmp/ +RUN mkdir build && \ + cd build && \ + cp ../arm-linux-gnueabihf.config .config && \ + ct-ng oldconfig && \ + ct-ng build && \ + cd .. && \ + rm -rf build + +USER root + +ENV PATH=$PATH:/x-tools/arm-unknown-linux-gnueabi/bin +ENV PATH=$PATH:/x-tools/arm-unknown-linux-gnueabihf/bin + +ENV CC_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-gcc \ + AR_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-ar \ + CXX_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-g++ \ + CC_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-gcc \ + AR_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-ar \ + CXX_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-g++ + ENV RUST_CONFIGURE_ARGS \ --host=arm-unknown-linux-gnueabi,arm-unknown-linux-gnueabihf ENV SCRIPT \ diff --git a/src/ci/docker/dist-arm-linux/arm-linux-gnueabi.config b/src/ci/docker/dist-arm-linux/arm-linux-gnueabi.config new file mode 100644 index 0000000000000..f73ad069550e1 --- /dev/null +++ b/src/ci/docker/dist-arm-linux/arm-linux-gnueabi.config @@ -0,0 +1,560 @@ +# +# Automatically generated file; DO NOT EDIT. +# Crosstool-NG Configuration +# +CT_CONFIGURE_has_make381=y +CT_MODULES=y + +# +# Paths and misc options +# + +# +# crosstool-NG behavior +# +# CT_OBSOLETE is not set +# CT_EXPERIMENTAL is not set +# CT_DEBUG_CT is not set + +# +# Paths +# +CT_LOCAL_TARBALLS_DIR="" +CT_WORK_DIR="${CT_TOP_DIR}/.build" +CT_PREFIX_DIR="/x-tools/${CT_TARGET}" +CT_INSTALL_DIR="${CT_PREFIX_DIR}" +CT_RM_RF_PREFIX_DIR=y +CT_REMOVE_DOCS=y +CT_INSTALL_DIR_RO=y +CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES=y +# CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES is not set + +# +# Downloading +# +# CT_FORBID_DOWNLOAD is not set +# CT_FORCE_DOWNLOAD is not set +CT_CONNECT_TIMEOUT=10 +# CT_ONLY_DOWNLOAD is not set +# CT_USE_MIRROR is not set + +# +# Extracting +# +# CT_FORCE_EXTRACT is not set +CT_OVERIDE_CONFIG_GUESS_SUB=y +# CT_ONLY_EXTRACT is not set +CT_PATCH_BUNDLED=y +# CT_PATCH_LOCAL is not set +# CT_PATCH_BUNDLED_LOCAL is not set +# CT_PATCH_LOCAL_BUNDLED is not set +# CT_PATCH_BUNDLED_FALLBACK_LOCAL is not set +# CT_PATCH_LOCAL_FALLBACK_BUNDLED is not set +# CT_PATCH_NONE is not set +CT_PATCH_ORDER="bundled" + +# +# Build behavior +# +CT_PARALLEL_JOBS=0 +CT_LOAD="" +CT_USE_PIPES=y +CT_EXTRA_CFLAGS_FOR_BUILD="" +CT_EXTRA_LDFLAGS_FOR_BUILD="" +CT_EXTRA_CFLAGS_FOR_HOST="" +CT_EXTRA_LDFLAGS_FOR_HOST="" +# CT_CONFIG_SHELL_SH is not set +# CT_CONFIG_SHELL_ASH is not set +CT_CONFIG_SHELL_BASH=y +# CT_CONFIG_SHELL_CUSTOM is not set +CT_CONFIG_SHELL="${bash}" + +# +# Logging +# +# CT_LOG_ERROR is not set +# CT_LOG_WARN is not set +CT_LOG_INFO=y +# CT_LOG_EXTRA is not set +# CT_LOG_ALL is not set +# CT_LOG_DEBUG is not set +CT_LOG_LEVEL_MAX="INFO" +# CT_LOG_SEE_TOOLS_WARN is not set +CT_LOG_PROGRESS_BAR=y +CT_LOG_TO_FILE=y +CT_LOG_FILE_COMPRESS=y + +# +# Target options +# +CT_ARCH="arm" +CT_ARCH_SUPPORTS_BOTH_MMU=y +CT_ARCH_SUPPORTS_BOTH_ENDIAN=y +CT_ARCH_SUPPORTS_32=y +CT_ARCH_SUPPORTS_64=y +CT_ARCH_SUPPORTS_WITH_ARCH=y +CT_ARCH_SUPPORTS_WITH_CPU=y +CT_ARCH_SUPPORTS_WITH_TUNE=y +CT_ARCH_SUPPORTS_WITH_FLOAT=y +CT_ARCH_SUPPORTS_WITH_FPU=y +CT_ARCH_SUPPORTS_SOFTFP=y +CT_ARCH_DEFAULT_HAS_MMU=y +CT_ARCH_DEFAULT_LE=y +CT_ARCH_DEFAULT_32=y +CT_ARCH_ARCH="armv6" +CT_ARCH_CPU="" +CT_ARCH_TUNE="" +CT_ARCH_FPU="" +# CT_ARCH_BE is not set +CT_ARCH_LE=y +CT_ARCH_32=y +# CT_ARCH_64 is not set +CT_ARCH_BITNESS=32 +# CT_ARCH_FLOAT_HW is not set +CT_ARCH_FLOAT_SW=y +CT_TARGET_CFLAGS="" +CT_TARGET_LDFLAGS="" +# CT_ARCH_alpha is not set +CT_ARCH_arm=y +# CT_ARCH_avr is not set +# CT_ARCH_m68k is not set +# CT_ARCH_mips is not set +# CT_ARCH_nios2 is not set +# CT_ARCH_powerpc is not set +# CT_ARCH_s390 is not set +# CT_ARCH_sh is not set +# CT_ARCH_sparc is not set +# CT_ARCH_x86 is not set +# CT_ARCH_xtensa is not set +CT_ARCH_alpha_AVAILABLE=y +CT_ARCH_arm_AVAILABLE=y +CT_ARCH_avr_AVAILABLE=y +CT_ARCH_m68k_AVAILABLE=y +CT_ARCH_microblaze_AVAILABLE=y +CT_ARCH_mips_AVAILABLE=y +CT_ARCH_nios2_AVAILABLE=y +CT_ARCH_powerpc_AVAILABLE=y +CT_ARCH_s390_AVAILABLE=y +CT_ARCH_sh_AVAILABLE=y +CT_ARCH_sparc_AVAILABLE=y +CT_ARCH_x86_AVAILABLE=y +CT_ARCH_xtensa_AVAILABLE=y +CT_ARCH_SUFFIX="" + +# +# Generic target options +# +# CT_MULTILIB is not set +CT_ARCH_USE_MMU=y +CT_ARCH_ENDIAN="little" + +# +# Target optimisations +# +CT_ARCH_EXCLUSIVE_WITH_CPU=y +# CT_ARCH_FLOAT_AUTO is not set +# CT_ARCH_FLOAT_SOFTFP is not set +CT_ARCH_FLOAT="soft" + +# +# arm other options +# +CT_ARCH_ARM_MODE="arm" +CT_ARCH_ARM_MODE_ARM=y +# CT_ARCH_ARM_MODE_THUMB is not set +# CT_ARCH_ARM_INTERWORKING is not set +CT_ARCH_ARM_EABI_FORCE=y +CT_ARCH_ARM_EABI=y + +# +# Toolchain options +# + +# +# General toolchain options +# +CT_FORCE_SYSROOT=y +CT_USE_SYSROOT=y +CT_SYSROOT_NAME="sysroot" +CT_SYSROOT_DIR_PREFIX="" +CT_WANTS_STATIC_LINK=y +# CT_STATIC_TOOLCHAIN is not set +CT_TOOLCHAIN_PKGVERSION="" +CT_TOOLCHAIN_BUGURL="" + +# +# Tuple completion and aliasing +# +CT_TARGET_VENDOR="unknown" +CT_TARGET_ALIAS_SED_EXPR="" +CT_TARGET_ALIAS="" + +# +# Toolchain type +# +CT_CROSS=y +# CT_CANADIAN is not set +CT_TOOLCHAIN_TYPE="cross" + +# +# Build system +# +CT_BUILD="" +CT_BUILD_PREFIX="" +CT_BUILD_SUFFIX="" + +# +# Misc options +# +# CT_TOOLCHAIN_ENABLE_NLS is not set + +# +# Operating System +# +CT_KERNEL_SUPPORTS_SHARED_LIBS=y +CT_KERNEL="linux" +CT_KERNEL_VERSION="3.2.72" +# CT_KERNEL_bare_metal is not set +CT_KERNEL_linux=y +CT_KERNEL_bare_metal_AVAILABLE=y +CT_KERNEL_linux_AVAILABLE=y +# CT_KERNEL_V_4_3 is not set +# CT_KERNEL_V_4_2 is not set +# CT_KERNEL_V_4_1 is not set +# CT_KERNEL_V_3_18 is not set +# CT_KERNEL_V_3_14 is not set +# CT_KERNEL_V_3_12 is not set +# CT_KERNEL_V_3_10 is not set +# CT_KERNEL_V_3_4 is not set +CT_KERNEL_V_3_2=y +# CT_KERNEL_V_2_6_32 is not set +# CT_KERNEL_LINUX_CUSTOM is not set +CT_KERNEL_windows_AVAILABLE=y + +# +# Common kernel options +# +CT_SHARED_LIBS=y + +# +# linux other options +# +CT_KERNEL_LINUX_VERBOSITY_0=y +# CT_KERNEL_LINUX_VERBOSITY_1 is not set +# CT_KERNEL_LINUX_VERBOSITY_2 is not set +CT_KERNEL_LINUX_VERBOSE_LEVEL=0 +CT_KERNEL_LINUX_INSTALL_CHECK=y + +# +# Binary utilities +# +CT_ARCH_BINFMT_ELF=y +CT_BINUTILS="binutils" +CT_BINUTILS_binutils=y + +# +# GNU binutils +# +# CT_CC_BINUTILS_SHOW_LINARO is not set +CT_BINUTILS_V_2_25_1=y +# CT_BINUTILS_V_2_25 is not set +# CT_BINUTILS_V_2_24 is not set +# CT_BINUTILS_V_2_23_2 is not set +# CT_BINUTILS_V_2_23_1 is not set +# CT_BINUTILS_V_2_22 is not set +# CT_BINUTILS_V_2_21_53 is not set +# CT_BINUTILS_V_2_21_1a is not set +# CT_BINUTILS_V_2_20_1a is not set +# CT_BINUTILS_V_2_19_1a is not set +# CT_BINUTILS_V_2_18a is not set +CT_BINUTILS_VERSION="2.25.1" +CT_BINUTILS_2_25_1_or_later=y +CT_BINUTILS_2_25_or_later=y +CT_BINUTILS_2_24_or_later=y +CT_BINUTILS_2_23_or_later=y +CT_BINUTILS_2_22_or_later=y +CT_BINUTILS_2_21_or_later=y +CT_BINUTILS_2_20_or_later=y +CT_BINUTILS_2_19_or_later=y +CT_BINUTILS_2_18_or_later=y +CT_BINUTILS_HAS_HASH_STYLE=y +CT_BINUTILS_HAS_GOLD=y +CT_BINUTILS_GOLD_SUPPORTS_ARCH=y +CT_BINUTILS_GOLD_SUPPORT=y +CT_BINUTILS_HAS_PLUGINS=y +CT_BINUTILS_HAS_PKGVERSION_BUGURL=y +CT_BINUTILS_FORCE_LD_BFD=y +CT_BINUTILS_LINKER_LD=y +# CT_BINUTILS_LINKER_LD_GOLD is not set +# CT_BINUTILS_LINKER_GOLD_LD is not set +CT_BINUTILS_LINKERS_LIST="ld" +CT_BINUTILS_LINKER_DEFAULT="bfd" +# CT_BINUTILS_PLUGINS is not set +CT_BINUTILS_EXTRA_CONFIG_ARRAY="" +# CT_BINUTILS_FOR_TARGET is not set + +# +# binutils other options +# + +# +# C-library +# +CT_LIBC="glibc" +CT_LIBC_VERSION="2.16.0" +CT_LIBC_glibc=y +# CT_LIBC_musl is not set +# CT_LIBC_uClibc is not set +CT_LIBC_avr_libc_AVAILABLE=y +CT_LIBC_glibc_AVAILABLE=y +CT_THREADS="nptl" +# CT_CC_GLIBC_SHOW_LINARO is not set +# CT_LIBC_GLIBC_V_2_22 is not set +# CT_LIBC_GLIBC_V_2_21 is not set +# CT_LIBC_GLIBC_V_2_20 is not set +# CT_LIBC_GLIBC_V_2_19 is not set +# CT_LIBC_GLIBC_V_2_18 is not set +# CT_LIBC_GLIBC_V_2_17 is not set +CT_LIBC_GLIBC_V_2_16_0=y +# CT_LIBC_GLIBC_V_2_15 is not set +# CT_LIBC_GLIBC_V_2_14_1 is not set +# CT_LIBC_GLIBC_V_2_14 is not set +# CT_LIBC_GLIBC_V_2_13 is not set +# CT_LIBC_GLIBC_V_2_12_2 is not set +# CT_LIBC_GLIBC_V_2_12_1 is not set +# CT_LIBC_GLIBC_V_2_11_1 is not set +# CT_LIBC_GLIBC_V_2_11 is not set +# CT_LIBC_GLIBC_V_2_10_1 is not set +# CT_LIBC_GLIBC_V_2_9 is not set +# CT_LIBC_GLIBC_V_2_8 is not set +CT_LIBC_mingw_AVAILABLE=y +CT_LIBC_musl_AVAILABLE=y +CT_LIBC_newlib_AVAILABLE=y +CT_LIBC_none_AVAILABLE=y +CT_LIBC_uClibc_AVAILABLE=y +CT_LIBC_SUPPORT_THREADS_ANY=y +CT_LIBC_SUPPORT_THREADS_NATIVE=y + +# +# Common C library options +# +CT_THREADS_NATIVE=y +CT_LIBC_XLDD=y + +# +# glibc other options +# +CT_LIBC_GLIBC_PORTS_EXTERNAL=y +CT_LIBC_GLIBC_MAY_FORCE_PORTS=y +CT_LIBC_glibc_familly=y +CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY="" +CT_LIBC_GLIBC_CONFIGPARMS="" +CT_LIBC_GLIBC_EXTRA_CFLAGS="" +CT_LIBC_EXTRA_CC_ARGS="" +# CT_LIBC_DISABLE_VERSIONING is not set +CT_LIBC_OLDEST_ABI="" +CT_LIBC_GLIBC_FORCE_UNWIND=y +CT_LIBC_GLIBC_USE_PORTS=y +CT_LIBC_ADDONS_LIST="" + +# +# WARNING !!! +# + +# +# For glibc >= 2.8, it can happen that the tarballs +# + +# +# for the addons are not available for download. +# + +# +# If that happens, bad luck... Try a previous version +# + +# +# or try again later... :-( +# +# CT_LIBC_LOCALES is not set +# CT_LIBC_GLIBC_KERNEL_VERSION_NONE is not set +CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS=y +# CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN is not set +CT_LIBC_GLIBC_MIN_KERNEL="3.2.72" + +# +# C compiler +# +CT_CC="gcc" +CT_CC_CORE_PASSES_NEEDED=y +CT_CC_CORE_PASS_1_NEEDED=y +CT_CC_CORE_PASS_2_NEEDED=y +CT_CC_gcc=y +# CT_CC_GCC_SHOW_LINARO is not set +# CT_CC_GCC_V_5_2_0 is not set +CT_CC_GCC_V_4_9_3=y +# CT_CC_GCC_V_4_8_5 is not set +# CT_CC_GCC_V_4_7_4 is not set +# CT_CC_GCC_V_4_6_4 is not set +# CT_CC_GCC_V_4_5_4 is not set +# CT_CC_GCC_V_4_4_7 is not set +# CT_CC_GCC_V_4_3_6 is not set +# CT_CC_GCC_V_4_2_4 is not set +CT_CC_GCC_4_2_or_later=y +CT_CC_GCC_4_3_or_later=y +CT_CC_GCC_4_4_or_later=y +CT_CC_GCC_4_5_or_later=y +CT_CC_GCC_4_6_or_later=y +CT_CC_GCC_4_7_or_later=y +CT_CC_GCC_4_8_or_later=y +CT_CC_GCC_4_9=y +CT_CC_GCC_4_9_or_later=y +CT_CC_GCC_HAS_GRAPHITE=y +CT_CC_GCC_USE_GRAPHITE=y +CT_CC_GCC_HAS_LTO=y +CT_CC_GCC_USE_LTO=y +CT_CC_GCC_HAS_PKGVERSION_BUGURL=y +CT_CC_GCC_HAS_BUILD_ID=y +CT_CC_GCC_HAS_LNK_HASH_STYLE=y +CT_CC_GCC_USE_GMP_MPFR=y +CT_CC_GCC_USE_MPC=y +CT_CC_GCC_HAS_LIBQUADMATH=y +CT_CC_GCC_HAS_LIBSANITIZER=y +CT_CC_GCC_VERSION="4.9.3" +# CT_CC_LANG_FORTRAN is not set +CT_CC_GCC_ENABLE_CXX_FLAGS="" +CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_EXTRA_ENV_ARRAY="" +CT_CC_GCC_STATIC_LIBSTDCXX=y +# CT_CC_GCC_SYSTEM_ZLIB is not set + +# +# Optimisation features +# + +# +# Settings for libraries running on target +# +CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y +# CT_CC_GCC_LIBMUDFLAP is not set +# CT_CC_GCC_LIBGOMP is not set +# CT_CC_GCC_LIBSSP is not set +# CT_CC_GCC_LIBQUADMATH is not set +# CT_CC_GCC_LIBSANITIZER is not set + +# +# Misc. obscure options. +# +CT_CC_CXA_ATEXIT=y +# CT_CC_GCC_DISABLE_PCH is not set +CT_CC_GCC_SJLJ_EXCEPTIONS=m +CT_CC_GCC_LDBL_128=m +# CT_CC_GCC_BUILD_ID is not set +CT_CC_GCC_LNK_HASH_STYLE_DEFAULT=y +# CT_CC_GCC_LNK_HASH_STYLE_SYSV is not set +# CT_CC_GCC_LNK_HASH_STYLE_GNU is not set +# CT_CC_GCC_LNK_HASH_STYLE_BOTH is not set +CT_CC_GCC_LNK_HASH_STYLE="" +CT_CC_GCC_DEC_FLOAT_AUTO=y +# CT_CC_GCC_DEC_FLOAT_BID is not set +# CT_CC_GCC_DEC_FLOAT_DPD is not set +# CT_CC_GCC_DEC_FLOATS_NO is not set +CT_CC_SUPPORT_CXX=y +CT_CC_SUPPORT_FORTRAN=y +CT_CC_SUPPORT_JAVA=y +CT_CC_SUPPORT_ADA=y +CT_CC_SUPPORT_OBJC=y +CT_CC_SUPPORT_OBJCXX=y +CT_CC_SUPPORT_GOLANG=y + +# +# Additional supported languages: +# +CT_CC_LANG_CXX=y +# CT_CC_LANG_JAVA is not set + +# +# Debug facilities +# +# CT_DEBUG_dmalloc is not set +# CT_DEBUG_duma is not set +# CT_DEBUG_gdb is not set +# CT_DEBUG_ltrace is not set +# CT_DEBUG_strace is not set + +# +# Companion libraries +# +CT_COMPLIBS_NEEDED=y +CT_LIBICONV_NEEDED=y +CT_GETTEXT_NEEDED=y +CT_GMP_NEEDED=y +CT_MPFR_NEEDED=y +CT_ISL_NEEDED=y +CT_CLOOG_NEEDED=y +CT_MPC_NEEDED=y +CT_COMPLIBS=y +CT_LIBICONV=y +CT_GETTEXT=y +CT_GMP=y +CT_MPFR=y +CT_ISL=y +CT_CLOOG=y +CT_MPC=y +CT_LIBICONV_V_1_14=y +CT_LIBICONV_VERSION="1.14" +CT_GETTEXT_V_0_19_6=y +CT_GETTEXT_VERSION="0.19.6" +CT_GMP_V_6_0_0=y +# CT_GMP_V_5_1_3 is not set +# CT_GMP_V_5_1_1 is not set +# CT_GMP_V_5_0_2 is not set +# CT_GMP_V_5_0_1 is not set +# CT_GMP_V_4_3_2 is not set +# CT_GMP_V_4_3_1 is not set +# CT_GMP_V_4_3_0 is not set +CT_GMP_5_0_2_or_later=y +CT_GMP_VERSION="6.0.0a" +CT_MPFR_V_3_1_3=y +# CT_MPFR_V_3_1_2 is not set +# CT_MPFR_V_3_1_0 is not set +# CT_MPFR_V_3_0_1 is not set +# CT_MPFR_V_3_0_0 is not set +# CT_MPFR_V_2_4_2 is not set +# CT_MPFR_V_2_4_1 is not set +# CT_MPFR_V_2_4_0 is not set +CT_MPFR_VERSION="3.1.3" +CT_ISL_V_0_14=y +CT_ISL_V_0_14_or_later=y +CT_ISL_V_0_12_or_later=y +CT_ISL_VERSION="0.14" +CT_CLOOG_V_0_18_4=y +# CT_CLOOG_V_0_18_1 is not set +# CT_CLOOG_V_0_18_0 is not set +CT_CLOOG_VERSION="0.18.4" +CT_CLOOG_0_18_4_or_later=y +CT_CLOOG_0_18_or_later=y +CT_MPC_V_1_0_3=y +# CT_MPC_V_1_0_2 is not set +# CT_MPC_V_1_0_1 is not set +# CT_MPC_V_1_0 is not set +# CT_MPC_V_0_9 is not set +# CT_MPC_V_0_8_2 is not set +# CT_MPC_V_0_8_1 is not set +# CT_MPC_V_0_7 is not set +CT_MPC_VERSION="1.0.3" + +# +# Companion libraries common options +# +# CT_COMPLIBS_CHECK is not set + +# +# Companion tools +# + +# +# READ HELP before you say 'Y' below !!! +# +# CT_COMP_TOOLS is not set diff --git a/src/ci/docker/dist-arm-linux/arm-linux-gnueabihf.config b/src/ci/docker/dist-arm-linux/arm-linux-gnueabihf.config new file mode 100644 index 0000000000000..1feeef1555749 --- /dev/null +++ b/src/ci/docker/dist-arm-linux/arm-linux-gnueabihf.config @@ -0,0 +1,561 @@ +# +# Automatically generated file; DO NOT EDIT. +# Crosstool-NG Configuration +# +CT_CONFIGURE_has_make381=y +CT_MODULES=y + +# +# Paths and misc options +# + +# +# crosstool-NG behavior +# +# CT_OBSOLETE is not set +# CT_EXPERIMENTAL is not set +# CT_DEBUG_CT is not set + +# +# Paths +# +CT_LOCAL_TARBALLS_DIR="" +CT_WORK_DIR="${CT_TOP_DIR}/.build" +CT_PREFIX_DIR="/x-tools/${CT_TARGET}" +CT_INSTALL_DIR="${CT_PREFIX_DIR}" +CT_RM_RF_PREFIX_DIR=y +CT_REMOVE_DOCS=y +CT_INSTALL_DIR_RO=y +CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES=y +# CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES is not set + +# +# Downloading +# +# CT_FORBID_DOWNLOAD is not set +# CT_FORCE_DOWNLOAD is not set +CT_CONNECT_TIMEOUT=10 +# CT_ONLY_DOWNLOAD is not set +# CT_USE_MIRROR is not set + +# +# Extracting +# +# CT_FORCE_EXTRACT is not set +CT_OVERIDE_CONFIG_GUESS_SUB=y +# CT_ONLY_EXTRACT is not set +CT_PATCH_BUNDLED=y +# CT_PATCH_LOCAL is not set +# CT_PATCH_BUNDLED_LOCAL is not set +# CT_PATCH_LOCAL_BUNDLED is not set +# CT_PATCH_BUNDLED_FALLBACK_LOCAL is not set +# CT_PATCH_LOCAL_FALLBACK_BUNDLED is not set +# CT_PATCH_NONE is not set +CT_PATCH_ORDER="bundled" + +# +# Build behavior +# +CT_PARALLEL_JOBS=0 +CT_LOAD="" +CT_USE_PIPES=y +CT_EXTRA_CFLAGS_FOR_BUILD="" +CT_EXTRA_LDFLAGS_FOR_BUILD="" +CT_EXTRA_CFLAGS_FOR_HOST="" +CT_EXTRA_LDFLAGS_FOR_HOST="" +# CT_CONFIG_SHELL_SH is not set +# CT_CONFIG_SHELL_ASH is not set +CT_CONFIG_SHELL_BASH=y +# CT_CONFIG_SHELL_CUSTOM is not set +CT_CONFIG_SHELL="${bash}" + +# +# Logging +# +# CT_LOG_ERROR is not set +# CT_LOG_WARN is not set +CT_LOG_INFO=y +# CT_LOG_EXTRA is not set +# CT_LOG_ALL is not set +# CT_LOG_DEBUG is not set +CT_LOG_LEVEL_MAX="INFO" +# CT_LOG_SEE_TOOLS_WARN is not set +CT_LOG_PROGRESS_BAR=y +CT_LOG_TO_FILE=y +CT_LOG_FILE_COMPRESS=y + +# +# Target options +# +CT_ARCH="arm" +CT_ARCH_SUPPORTS_BOTH_MMU=y +CT_ARCH_SUPPORTS_BOTH_ENDIAN=y +CT_ARCH_SUPPORTS_32=y +CT_ARCH_SUPPORTS_64=y +CT_ARCH_SUPPORTS_WITH_ARCH=y +CT_ARCH_SUPPORTS_WITH_CPU=y +CT_ARCH_SUPPORTS_WITH_TUNE=y +CT_ARCH_SUPPORTS_WITH_FLOAT=y +CT_ARCH_SUPPORTS_WITH_FPU=y +CT_ARCH_SUPPORTS_SOFTFP=y +CT_ARCH_DEFAULT_HAS_MMU=y +CT_ARCH_DEFAULT_LE=y +CT_ARCH_DEFAULT_32=y +CT_ARCH_ARCH="armv6" +CT_ARCH_CPU="" +CT_ARCH_TUNE="" +CT_ARCH_FPU="vfp" +# CT_ARCH_BE is not set +CT_ARCH_LE=y +CT_ARCH_32=y +# CT_ARCH_64 is not set +CT_ARCH_BITNESS=32 +CT_ARCH_FLOAT_HW=y +# CT_ARCH_FLOAT_SW is not set +CT_TARGET_CFLAGS="" +CT_TARGET_LDFLAGS="" +# CT_ARCH_alpha is not set +CT_ARCH_arm=y +# CT_ARCH_avr is not set +# CT_ARCH_m68k is not set +# CT_ARCH_mips is not set +# CT_ARCH_nios2 is not set +# CT_ARCH_powerpc is not set +# CT_ARCH_s390 is not set +# CT_ARCH_sh is not set +# CT_ARCH_sparc is not set +# CT_ARCH_x86 is not set +# CT_ARCH_xtensa is not set +CT_ARCH_alpha_AVAILABLE=y +CT_ARCH_arm_AVAILABLE=y +CT_ARCH_avr_AVAILABLE=y +CT_ARCH_m68k_AVAILABLE=y +CT_ARCH_microblaze_AVAILABLE=y +CT_ARCH_mips_AVAILABLE=y +CT_ARCH_nios2_AVAILABLE=y +CT_ARCH_powerpc_AVAILABLE=y +CT_ARCH_s390_AVAILABLE=y +CT_ARCH_sh_AVAILABLE=y +CT_ARCH_sparc_AVAILABLE=y +CT_ARCH_x86_AVAILABLE=y +CT_ARCH_xtensa_AVAILABLE=y +CT_ARCH_SUFFIX="" + +# +# Generic target options +# +# CT_MULTILIB is not set +CT_ARCH_USE_MMU=y +CT_ARCH_ENDIAN="little" + +# +# Target optimisations +# +CT_ARCH_EXCLUSIVE_WITH_CPU=y +# CT_ARCH_FLOAT_AUTO is not set +# CT_ARCH_FLOAT_SOFTFP is not set +CT_ARCH_FLOAT="hard" + +# +# arm other options +# +CT_ARCH_ARM_MODE="arm" +CT_ARCH_ARM_MODE_ARM=y +# CT_ARCH_ARM_MODE_THUMB is not set +# CT_ARCH_ARM_INTERWORKING is not set +CT_ARCH_ARM_EABI_FORCE=y +CT_ARCH_ARM_EABI=y +CT_ARCH_ARM_TUPLE_USE_EABIHF=y + +# +# Toolchain options +# + +# +# General toolchain options +# +CT_FORCE_SYSROOT=y +CT_USE_SYSROOT=y +CT_SYSROOT_NAME="sysroot" +CT_SYSROOT_DIR_PREFIX="" +CT_WANTS_STATIC_LINK=y +# CT_STATIC_TOOLCHAIN is not set +CT_TOOLCHAIN_PKGVERSION="" +CT_TOOLCHAIN_BUGURL="" + +# +# Tuple completion and aliasing +# +CT_TARGET_VENDOR="unknown" +CT_TARGET_ALIAS_SED_EXPR="" +CT_TARGET_ALIAS="" + +# +# Toolchain type +# +CT_CROSS=y +# CT_CANADIAN is not set +CT_TOOLCHAIN_TYPE="cross" + +# +# Build system +# +CT_BUILD="" +CT_BUILD_PREFIX="" +CT_BUILD_SUFFIX="" + +# +# Misc options +# +# CT_TOOLCHAIN_ENABLE_NLS is not set + +# +# Operating System +# +CT_KERNEL_SUPPORTS_SHARED_LIBS=y +CT_KERNEL="linux" +CT_KERNEL_VERSION="3.2.72" +# CT_KERNEL_bare_metal is not set +CT_KERNEL_linux=y +CT_KERNEL_bare_metal_AVAILABLE=y +CT_KERNEL_linux_AVAILABLE=y +# CT_KERNEL_V_4_3 is not set +# CT_KERNEL_V_4_2 is not set +# CT_KERNEL_V_4_1 is not set +# CT_KERNEL_V_3_18 is not set +# CT_KERNEL_V_3_14 is not set +# CT_KERNEL_V_3_12 is not set +# CT_KERNEL_V_3_10 is not set +# CT_KERNEL_V_3_4 is not set +CT_KERNEL_V_3_2=y +# CT_KERNEL_V_2_6_32 is not set +# CT_KERNEL_LINUX_CUSTOM is not set +CT_KERNEL_windows_AVAILABLE=y + +# +# Common kernel options +# +CT_SHARED_LIBS=y + +# +# linux other options +# +CT_KERNEL_LINUX_VERBOSITY_0=y +# CT_KERNEL_LINUX_VERBOSITY_1 is not set +# CT_KERNEL_LINUX_VERBOSITY_2 is not set +CT_KERNEL_LINUX_VERBOSE_LEVEL=0 +CT_KERNEL_LINUX_INSTALL_CHECK=y + +# +# Binary utilities +# +CT_ARCH_BINFMT_ELF=y +CT_BINUTILS="binutils" +CT_BINUTILS_binutils=y + +# +# GNU binutils +# +# CT_CC_BINUTILS_SHOW_LINARO is not set +CT_BINUTILS_V_2_25_1=y +# CT_BINUTILS_V_2_25 is not set +# CT_BINUTILS_V_2_24 is not set +# CT_BINUTILS_V_2_23_2 is not set +# CT_BINUTILS_V_2_23_1 is not set +# CT_BINUTILS_V_2_22 is not set +# CT_BINUTILS_V_2_21_53 is not set +# CT_BINUTILS_V_2_21_1a is not set +# CT_BINUTILS_V_2_20_1a is not set +# CT_BINUTILS_V_2_19_1a is not set +# CT_BINUTILS_V_2_18a is not set +CT_BINUTILS_VERSION="2.25.1" +CT_BINUTILS_2_25_1_or_later=y +CT_BINUTILS_2_25_or_later=y +CT_BINUTILS_2_24_or_later=y +CT_BINUTILS_2_23_or_later=y +CT_BINUTILS_2_22_or_later=y +CT_BINUTILS_2_21_or_later=y +CT_BINUTILS_2_20_or_later=y +CT_BINUTILS_2_19_or_later=y +CT_BINUTILS_2_18_or_later=y +CT_BINUTILS_HAS_HASH_STYLE=y +CT_BINUTILS_HAS_GOLD=y +CT_BINUTILS_GOLD_SUPPORTS_ARCH=y +CT_BINUTILS_GOLD_SUPPORT=y +CT_BINUTILS_HAS_PLUGINS=y +CT_BINUTILS_HAS_PKGVERSION_BUGURL=y +CT_BINUTILS_FORCE_LD_BFD=y +CT_BINUTILS_LINKER_LD=y +# CT_BINUTILS_LINKER_LD_GOLD is not set +# CT_BINUTILS_LINKER_GOLD_LD is not set +CT_BINUTILS_LINKERS_LIST="ld" +CT_BINUTILS_LINKER_DEFAULT="bfd" +# CT_BINUTILS_PLUGINS is not set +CT_BINUTILS_EXTRA_CONFIG_ARRAY="" +# CT_BINUTILS_FOR_TARGET is not set + +# +# binutils other options +# + +# +# C-library +# +CT_LIBC="glibc" +CT_LIBC_VERSION="2.16.0" +CT_LIBC_glibc=y +# CT_LIBC_musl is not set +# CT_LIBC_uClibc is not set +CT_LIBC_avr_libc_AVAILABLE=y +CT_LIBC_glibc_AVAILABLE=y +CT_THREADS="nptl" +# CT_CC_GLIBC_SHOW_LINARO is not set +# CT_LIBC_GLIBC_V_2_22 is not set +# CT_LIBC_GLIBC_V_2_21 is not set +# CT_LIBC_GLIBC_V_2_20 is not set +# CT_LIBC_GLIBC_V_2_19 is not set +# CT_LIBC_GLIBC_V_2_18 is not set +# CT_LIBC_GLIBC_V_2_17 is not set +CT_LIBC_GLIBC_V_2_16_0=y +# CT_LIBC_GLIBC_V_2_15 is not set +# CT_LIBC_GLIBC_V_2_14_1 is not set +# CT_LIBC_GLIBC_V_2_14 is not set +# CT_LIBC_GLIBC_V_2_13 is not set +# CT_LIBC_GLIBC_V_2_12_2 is not set +# CT_LIBC_GLIBC_V_2_12_1 is not set +# CT_LIBC_GLIBC_V_2_11_1 is not set +# CT_LIBC_GLIBC_V_2_11 is not set +# CT_LIBC_GLIBC_V_2_10_1 is not set +# CT_LIBC_GLIBC_V_2_9 is not set +# CT_LIBC_GLIBC_V_2_8 is not set +CT_LIBC_mingw_AVAILABLE=y +CT_LIBC_musl_AVAILABLE=y +CT_LIBC_newlib_AVAILABLE=y +CT_LIBC_none_AVAILABLE=y +CT_LIBC_uClibc_AVAILABLE=y +CT_LIBC_SUPPORT_THREADS_ANY=y +CT_LIBC_SUPPORT_THREADS_NATIVE=y + +# +# Common C library options +# +CT_THREADS_NATIVE=y +CT_LIBC_XLDD=y + +# +# glibc other options +# +CT_LIBC_GLIBC_PORTS_EXTERNAL=y +CT_LIBC_GLIBC_MAY_FORCE_PORTS=y +CT_LIBC_glibc_familly=y +CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY="" +CT_LIBC_GLIBC_CONFIGPARMS="" +CT_LIBC_GLIBC_EXTRA_CFLAGS="" +CT_LIBC_EXTRA_CC_ARGS="" +# CT_LIBC_DISABLE_VERSIONING is not set +CT_LIBC_OLDEST_ABI="" +CT_LIBC_GLIBC_FORCE_UNWIND=y +CT_LIBC_GLIBC_USE_PORTS=y +CT_LIBC_ADDONS_LIST="" + +# +# WARNING !!! +# + +# +# For glibc >= 2.8, it can happen that the tarballs +# + +# +# for the addons are not available for download. +# + +# +# If that happens, bad luck... Try a previous version +# + +# +# or try again later... :-( +# +# CT_LIBC_LOCALES is not set +# CT_LIBC_GLIBC_KERNEL_VERSION_NONE is not set +CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS=y +# CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN is not set +CT_LIBC_GLIBC_MIN_KERNEL="3.2.72" + +# +# C compiler +# +CT_CC="gcc" +CT_CC_CORE_PASSES_NEEDED=y +CT_CC_CORE_PASS_1_NEEDED=y +CT_CC_CORE_PASS_2_NEEDED=y +CT_CC_gcc=y +# CT_CC_GCC_SHOW_LINARO is not set +# CT_CC_GCC_V_5_2_0 is not set +CT_CC_GCC_V_4_9_3=y +# CT_CC_GCC_V_4_8_5 is not set +# CT_CC_GCC_V_4_7_4 is not set +# CT_CC_GCC_V_4_6_4 is not set +# CT_CC_GCC_V_4_5_4 is not set +# CT_CC_GCC_V_4_4_7 is not set +# CT_CC_GCC_V_4_3_6 is not set +# CT_CC_GCC_V_4_2_4 is not set +CT_CC_GCC_4_2_or_later=y +CT_CC_GCC_4_3_or_later=y +CT_CC_GCC_4_4_or_later=y +CT_CC_GCC_4_5_or_later=y +CT_CC_GCC_4_6_or_later=y +CT_CC_GCC_4_7_or_later=y +CT_CC_GCC_4_8_or_later=y +CT_CC_GCC_4_9=y +CT_CC_GCC_4_9_or_later=y +CT_CC_GCC_HAS_GRAPHITE=y +CT_CC_GCC_USE_GRAPHITE=y +CT_CC_GCC_HAS_LTO=y +CT_CC_GCC_USE_LTO=y +CT_CC_GCC_HAS_PKGVERSION_BUGURL=y +CT_CC_GCC_HAS_BUILD_ID=y +CT_CC_GCC_HAS_LNK_HASH_STYLE=y +CT_CC_GCC_USE_GMP_MPFR=y +CT_CC_GCC_USE_MPC=y +CT_CC_GCC_HAS_LIBQUADMATH=y +CT_CC_GCC_HAS_LIBSANITIZER=y +CT_CC_GCC_VERSION="4.9.3" +# CT_CC_LANG_FORTRAN is not set +CT_CC_GCC_ENABLE_CXX_FLAGS="" +CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_EXTRA_ENV_ARRAY="" +CT_CC_GCC_STATIC_LIBSTDCXX=y +# CT_CC_GCC_SYSTEM_ZLIB is not set + +# +# Optimisation features +# + +# +# Settings for libraries running on target +# +CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y +# CT_CC_GCC_LIBMUDFLAP is not set +# CT_CC_GCC_LIBGOMP is not set +# CT_CC_GCC_LIBSSP is not set +# CT_CC_GCC_LIBQUADMATH is not set +# CT_CC_GCC_LIBSANITIZER is not set + +# +# Misc. obscure options. +# +CT_CC_CXA_ATEXIT=y +# CT_CC_GCC_DISABLE_PCH is not set +CT_CC_GCC_SJLJ_EXCEPTIONS=m +CT_CC_GCC_LDBL_128=m +# CT_CC_GCC_BUILD_ID is not set +CT_CC_GCC_LNK_HASH_STYLE_DEFAULT=y +# CT_CC_GCC_LNK_HASH_STYLE_SYSV is not set +# CT_CC_GCC_LNK_HASH_STYLE_GNU is not set +# CT_CC_GCC_LNK_HASH_STYLE_BOTH is not set +CT_CC_GCC_LNK_HASH_STYLE="" +CT_CC_GCC_DEC_FLOAT_AUTO=y +# CT_CC_GCC_DEC_FLOAT_BID is not set +# CT_CC_GCC_DEC_FLOAT_DPD is not set +# CT_CC_GCC_DEC_FLOATS_NO is not set +CT_CC_SUPPORT_CXX=y +CT_CC_SUPPORT_FORTRAN=y +CT_CC_SUPPORT_JAVA=y +CT_CC_SUPPORT_ADA=y +CT_CC_SUPPORT_OBJC=y +CT_CC_SUPPORT_OBJCXX=y +CT_CC_SUPPORT_GOLANG=y + +# +# Additional supported languages: +# +CT_CC_LANG_CXX=y +# CT_CC_LANG_JAVA is not set + +# +# Debug facilities +# +# CT_DEBUG_dmalloc is not set +# CT_DEBUG_duma is not set +# CT_DEBUG_gdb is not set +# CT_DEBUG_ltrace is not set +# CT_DEBUG_strace is not set + +# +# Companion libraries +# +CT_COMPLIBS_NEEDED=y +CT_LIBICONV_NEEDED=y +CT_GETTEXT_NEEDED=y +CT_GMP_NEEDED=y +CT_MPFR_NEEDED=y +CT_ISL_NEEDED=y +CT_CLOOG_NEEDED=y +CT_MPC_NEEDED=y +CT_COMPLIBS=y +CT_LIBICONV=y +CT_GETTEXT=y +CT_GMP=y +CT_MPFR=y +CT_ISL=y +CT_CLOOG=y +CT_MPC=y +CT_LIBICONV_V_1_14=y +CT_LIBICONV_VERSION="1.14" +CT_GETTEXT_V_0_19_6=y +CT_GETTEXT_VERSION="0.19.6" +CT_GMP_V_6_0_0=y +# CT_GMP_V_5_1_3 is not set +# CT_GMP_V_5_1_1 is not set +# CT_GMP_V_5_0_2 is not set +# CT_GMP_V_5_0_1 is not set +# CT_GMP_V_4_3_2 is not set +# CT_GMP_V_4_3_1 is not set +# CT_GMP_V_4_3_0 is not set +CT_GMP_5_0_2_or_later=y +CT_GMP_VERSION="6.0.0a" +CT_MPFR_V_3_1_3=y +# CT_MPFR_V_3_1_2 is not set +# CT_MPFR_V_3_1_0 is not set +# CT_MPFR_V_3_0_1 is not set +# CT_MPFR_V_3_0_0 is not set +# CT_MPFR_V_2_4_2 is not set +# CT_MPFR_V_2_4_1 is not set +# CT_MPFR_V_2_4_0 is not set +CT_MPFR_VERSION="3.1.3" +CT_ISL_V_0_14=y +CT_ISL_V_0_14_or_later=y +CT_ISL_V_0_12_or_later=y +CT_ISL_VERSION="0.14" +CT_CLOOG_V_0_18_4=y +# CT_CLOOG_V_0_18_1 is not set +# CT_CLOOG_V_0_18_0 is not set +CT_CLOOG_VERSION="0.18.4" +CT_CLOOG_0_18_4_or_later=y +CT_CLOOG_0_18_or_later=y +CT_MPC_V_1_0_3=y +# CT_MPC_V_1_0_2 is not set +# CT_MPC_V_1_0_1 is not set +# CT_MPC_V_1_0 is not set +# CT_MPC_V_0_9 is not set +# CT_MPC_V_0_8_2 is not set +# CT_MPC_V_0_8_1 is not set +# CT_MPC_V_0_7 is not set +CT_MPC_VERSION="1.0.3" + +# +# Companion libraries common options +# +# CT_COMPLIBS_CHECK is not set + +# +# Companion tools +# + +# +# READ HELP before you say 'Y' below !!! +# +# CT_COMP_TOOLS is not set diff --git a/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile b/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile index 134e2b062ef0b..c3115b177ff46 100644 --- a/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile +++ b/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile @@ -1,19 +1,29 @@ FROM ubuntu:16.04 RUN apt-get update && apt-get install -y --no-install-recommends \ + automake \ + bison \ + bzip2 \ + ca-certificates \ + cmake \ + curl \ + file \ + flex \ g++ \ + gawk \ + gdb \ + git \ + gperf \ + help2man \ + libncurses-dev \ + libtool-bin \ make \ - file \ - curl \ - ca-certificates \ + patch \ python2.7 \ - git \ - cmake \ sudo \ - gdb \ - xz-utils \ - g++-arm-linux-gnueabihf \ - g++-aarch64-linux-gnu + texinfo \ + wget \ + xz-utils ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ @@ -24,6 +34,59 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] +# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# toolchains we build below chokes on that, so go back to make 3 +RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ + cd make-3.81 && \ + ./configure --prefix=/usr && \ + make && \ + make install && \ + cd .. && \ + rm -rf make-3.81 + +RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ + tar xjf - && \ + cd crosstool-ng && \ + ./configure --prefix=/usr/local && \ + make -j$(nproc) && \ + make install && \ + cd .. && \ + rm -rf crosstool-ng + +RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild +RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +USER rustbuild +WORKDIR /tmp + +COPY armv7-linux-gnueabihf.config /tmp/ +RUN mkdir build && \ + cd build && \ + cp ../armv7-linux-gnueabihf.config .config && \ + ct-ng oldconfig && \ + ct-ng build && \ + cd .. && \ + rm -rf build +COPY aarch64-linux-gnu.config /tmp/ +RUN mkdir build && \ + cd build && \ + cp ../aarch64-linux-gnu.config .config && \ + ct-ng oldconfig && \ + ct-ng build && \ + cd .. && \ + rm -rf build + +USER root + +ENV PATH=$PATH:/x-tools/aarch64-unknown-linux-gnueabi/bin +ENV PATH=$PATH:/x-tools/armv7-unknown-linux-gnueabihf/bin + +ENV CC_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnueabi-gcc \ + AR_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnueabi-ar \ + CXX_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnueabi-g++ \ + CC_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-gcc \ + AR_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-ar \ + CXX_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-g++ + ENV RUST_CONFIGURE_ARGS \ --host=armv7-unknown-linux-gnueabihf,aarch64-unknown-linux-gnu ENV SCRIPT \ diff --git a/src/ci/docker/dist-armv7-aarch64-linux/aarch64-linux-gnu.config b/src/ci/docker/dist-armv7-aarch64-linux/aarch64-linux-gnu.config new file mode 100644 index 0000000000000..3d30ee49022d8 --- /dev/null +++ b/src/ci/docker/dist-armv7-aarch64-linux/aarch64-linux-gnu.config @@ -0,0 +1,551 @@ +# +# Automatically generated file; DO NOT EDIT. +# Crosstool-NG Configuration +# +CT_CONFIGURE_has_make381=y +CT_CONFIGURE_has_xz=y +CT_MODULES=y + +# +# Paths and misc options +# + +# +# crosstool-NG behavior +# +# CT_OBSOLETE is not set +# CT_EXPERIMENTAL is not set +# CT_DEBUG_CT is not set + +# +# Paths +# +CT_LOCAL_TARBALLS_DIR="" +CT_WORK_DIR="${CT_TOP_DIR}/.build" +CT_PREFIX_DIR="/x-tools/${CT_TARGET}" +CT_INSTALL_DIR="${CT_PREFIX_DIR}" +CT_RM_RF_PREFIX_DIR=y +CT_REMOVE_DOCS=y +CT_INSTALL_DIR_RO=y +CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES=y +# CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES is not set + +# +# Downloading +# +# CT_FORBID_DOWNLOAD is not set +# CT_FORCE_DOWNLOAD is not set +CT_CONNECT_TIMEOUT=10 +# CT_ONLY_DOWNLOAD is not set +# CT_USE_MIRROR is not set + +# +# Extracting +# +# CT_FORCE_EXTRACT is not set +CT_OVERIDE_CONFIG_GUESS_SUB=y +# CT_ONLY_EXTRACT is not set +CT_PATCH_BUNDLED=y +# CT_PATCH_LOCAL is not set +# CT_PATCH_BUNDLED_LOCAL is not set +# CT_PATCH_LOCAL_BUNDLED is not set +# CT_PATCH_BUNDLED_FALLBACK_LOCAL is not set +# CT_PATCH_LOCAL_FALLBACK_BUNDLED is not set +# CT_PATCH_NONE is not set +CT_PATCH_ORDER="bundled" + +# +# Build behavior +# +CT_PARALLEL_JOBS=0 +CT_LOAD="" +CT_USE_PIPES=y +CT_EXTRA_CFLAGS_FOR_BUILD="" +CT_EXTRA_LDFLAGS_FOR_BUILD="" +CT_EXTRA_CFLAGS_FOR_HOST="" +CT_EXTRA_LDFLAGS_FOR_HOST="" +# CT_CONFIG_SHELL_SH is not set +# CT_CONFIG_SHELL_ASH is not set +CT_CONFIG_SHELL_BASH=y +# CT_CONFIG_SHELL_CUSTOM is not set +CT_CONFIG_SHELL="${bash}" + +# +# Logging +# +# CT_LOG_ERROR is not set +# CT_LOG_WARN is not set +CT_LOG_INFO=y +# CT_LOG_EXTRA is not set +# CT_LOG_ALL is not set +# CT_LOG_DEBUG is not set +CT_LOG_LEVEL_MAX="INFO" +# CT_LOG_SEE_TOOLS_WARN is not set +CT_LOG_PROGRESS_BAR=y +CT_LOG_TO_FILE=y +CT_LOG_FILE_COMPRESS=y + +# +# Target options +# +CT_ARCH="arm" +CT_ARCH_SUPPORTS_BOTH_MMU=y +CT_ARCH_SUPPORTS_BOTH_ENDIAN=y +CT_ARCH_SUPPORTS_32=y +CT_ARCH_SUPPORTS_64=y +CT_ARCH_SUPPORTS_WITH_ARCH=y +CT_ARCH_SUPPORTS_WITH_CPU=y +CT_ARCH_SUPPORTS_WITH_TUNE=y +CT_ARCH_DEFAULT_HAS_MMU=y +CT_ARCH_DEFAULT_LE=y +CT_ARCH_DEFAULT_32=y +CT_ARCH_ARCH="" +CT_ARCH_CPU="" +CT_ARCH_TUNE="" +# CT_ARCH_BE is not set +CT_ARCH_LE=y +# CT_ARCH_32 is not set +CT_ARCH_64=y +CT_ARCH_BITNESS=64 +CT_TARGET_CFLAGS="" +CT_TARGET_LDFLAGS="" +# CT_ARCH_alpha is not set +CT_ARCH_arm=y +# CT_ARCH_avr is not set +# CT_ARCH_m68k is not set +# CT_ARCH_mips is not set +# CT_ARCH_nios2 is not set +# CT_ARCH_powerpc is not set +# CT_ARCH_s390 is not set +# CT_ARCH_sh is not set +# CT_ARCH_sparc is not set +# CT_ARCH_x86 is not set +# CT_ARCH_xtensa is not set +CT_ARCH_alpha_AVAILABLE=y +CT_ARCH_arm_AVAILABLE=y +CT_ARCH_avr_AVAILABLE=y +CT_ARCH_m68k_AVAILABLE=y +CT_ARCH_microblaze_AVAILABLE=y +CT_ARCH_mips_AVAILABLE=y +CT_ARCH_nios2_AVAILABLE=y +CT_ARCH_powerpc_AVAILABLE=y +CT_ARCH_s390_AVAILABLE=y +CT_ARCH_sh_AVAILABLE=y +CT_ARCH_sparc_AVAILABLE=y +CT_ARCH_x86_AVAILABLE=y +CT_ARCH_xtensa_AVAILABLE=y +CT_ARCH_SUFFIX="" + +# +# Generic target options +# +# CT_MULTILIB is not set +CT_ARCH_USE_MMU=y +CT_ARCH_ENDIAN="little" + +# +# Target optimisations +# +CT_ARCH_EXCLUSIVE_WITH_CPU=y +CT_ARCH_FLOAT="" + +# +# arm other options +# +CT_ARCH_ARM_MODE="arm" +CT_ARCH_ARM_MODE_ARM=y +# CT_ARCH_ARM_MODE_THUMB is not set +# CT_ARCH_ARM_INTERWORKING is not set +CT_ARCH_ARM_EABI_FORCE=y +CT_ARCH_ARM_EABI=y + +# +# Toolchain options +# + +# +# General toolchain options +# +CT_FORCE_SYSROOT=y +CT_USE_SYSROOT=y +CT_SYSROOT_NAME="sysroot" +CT_SYSROOT_DIR_PREFIX="" +CT_WANTS_STATIC_LINK=y +# CT_STATIC_TOOLCHAIN is not set +CT_TOOLCHAIN_PKGVERSION="" +CT_TOOLCHAIN_BUGURL="" + +# +# Tuple completion and aliasing +# +CT_TARGET_VENDOR="unknown" +CT_TARGET_ALIAS_SED_EXPR="" +CT_TARGET_ALIAS="" + +# +# Toolchain type +# +CT_CROSS=y +# CT_CANADIAN is not set +CT_TOOLCHAIN_TYPE="cross" + +# +# Build system +# +CT_BUILD="" +CT_BUILD_PREFIX="" +CT_BUILD_SUFFIX="" + +# +# Misc options +# +# CT_TOOLCHAIN_ENABLE_NLS is not set + +# +# Operating System +# +CT_KERNEL_SUPPORTS_SHARED_LIBS=y +CT_KERNEL="linux" +CT_KERNEL_VERSION="4.2.6" +# CT_KERNEL_bare_metal is not set +CT_KERNEL_linux=y +CT_KERNEL_bare_metal_AVAILABLE=y +CT_KERNEL_linux_AVAILABLE=y +# CT_KERNEL_V_4_3 is not set +CT_KERNEL_V_4_2=y +# CT_KERNEL_V_4_1 is not set +# CT_KERNEL_V_3_18 is not set +# CT_KERNEL_V_3_14 is not set +# CT_KERNEL_V_3_12 is not set +# CT_KERNEL_V_3_10 is not set +# CT_KERNEL_V_3_4 is not set +# CT_KERNEL_V_3_2 is not set +# CT_KERNEL_V_2_6_32 is not set +# CT_KERNEL_LINUX_CUSTOM is not set +CT_KERNEL_windows_AVAILABLE=y + +# +# Common kernel options +# +CT_SHARED_LIBS=y + +# +# linux other options +# +CT_KERNEL_LINUX_VERBOSITY_0=y +# CT_KERNEL_LINUX_VERBOSITY_1 is not set +# CT_KERNEL_LINUX_VERBOSITY_2 is not set +CT_KERNEL_LINUX_VERBOSE_LEVEL=0 +CT_KERNEL_LINUX_INSTALL_CHECK=y + +# +# Binary utilities +# +CT_ARCH_BINFMT_ELF=y +CT_BINUTILS="binutils" +CT_BINUTILS_binutils=y + +# +# GNU binutils +# +# CT_CC_BINUTILS_SHOW_LINARO is not set +CT_BINUTILS_V_2_25_1=y +# CT_BINUTILS_V_2_25 is not set +# CT_BINUTILS_V_2_24 is not set +# CT_BINUTILS_V_2_23_2 is not set +# CT_BINUTILS_V_2_23_1 is not set +# CT_BINUTILS_V_2_22 is not set +# CT_BINUTILS_V_2_21_53 is not set +# CT_BINUTILS_V_2_21_1a is not set +# CT_BINUTILS_V_2_20_1a is not set +# CT_BINUTILS_V_2_19_1a is not set +# CT_BINUTILS_V_2_18a is not set +CT_BINUTILS_VERSION="2.25.1" +CT_BINUTILS_2_25_1_or_later=y +CT_BINUTILS_2_25_or_later=y +CT_BINUTILS_2_24_or_later=y +CT_BINUTILS_2_23_or_later=y +CT_BINUTILS_2_22_or_later=y +CT_BINUTILS_2_21_or_later=y +CT_BINUTILS_2_20_or_later=y +CT_BINUTILS_2_19_or_later=y +CT_BINUTILS_2_18_or_later=y +CT_BINUTILS_HAS_HASH_STYLE=y +CT_BINUTILS_HAS_GOLD=y +CT_BINUTILS_GOLD_SUPPORTS_ARCH=y +CT_BINUTILS_GOLD_SUPPORT=y +CT_BINUTILS_HAS_PLUGINS=y +CT_BINUTILS_HAS_PKGVERSION_BUGURL=y +CT_BINUTILS_FORCE_LD_BFD=y +CT_BINUTILS_LINKER_LD=y +# CT_BINUTILS_LINKER_LD_GOLD is not set +# CT_BINUTILS_LINKER_GOLD_LD is not set +CT_BINUTILS_LINKERS_LIST="ld" +CT_BINUTILS_LINKER_DEFAULT="bfd" +# CT_BINUTILS_PLUGINS is not set +CT_BINUTILS_EXTRA_CONFIG_ARRAY="" +# CT_BINUTILS_FOR_TARGET is not set + +# +# binutils other options +# + +# +# C-library +# +CT_LIBC="glibc" +CT_LIBC_VERSION="2.17" +CT_LIBC_glibc=y +# CT_LIBC_musl is not set +# CT_LIBC_uClibc is not set +CT_LIBC_avr_libc_AVAILABLE=y +CT_LIBC_glibc_AVAILABLE=y +CT_THREADS="nptl" +# CT_CC_GLIBC_SHOW_LINARO is not set +# CT_LIBC_GLIBC_V_2_22 is not set +# CT_LIBC_GLIBC_V_2_21 is not set +# CT_LIBC_GLIBC_V_2_20 is not set +# CT_LIBC_GLIBC_V_2_19 is not set +# CT_LIBC_GLIBC_V_2_18 is not set +CT_LIBC_GLIBC_V_2_17=y +# CT_LIBC_GLIBC_V_2_16_0 is not set +# CT_LIBC_GLIBC_V_2_15 is not set +# CT_LIBC_GLIBC_V_2_14_1 is not set +# CT_LIBC_GLIBC_V_2_14 is not set +# CT_LIBC_GLIBC_V_2_13 is not set +# CT_LIBC_GLIBC_V_2_12_2 is not set +# CT_LIBC_GLIBC_V_2_12_1 is not set +# CT_LIBC_GLIBC_V_2_11_1 is not set +# CT_LIBC_GLIBC_V_2_11 is not set +# CT_LIBC_GLIBC_V_2_10_1 is not set +# CT_LIBC_GLIBC_V_2_9 is not set +# CT_LIBC_GLIBC_V_2_8 is not set +CT_LIBC_GLIBC_2_17_or_later=y +CT_LIBC_mingw_AVAILABLE=y +CT_LIBC_musl_AVAILABLE=y +CT_LIBC_newlib_AVAILABLE=y +CT_LIBC_none_AVAILABLE=y +CT_LIBC_uClibc_AVAILABLE=y +CT_LIBC_SUPPORT_THREADS_ANY=y +CT_LIBC_SUPPORT_THREADS_NATIVE=y + +# +# Common C library options +# +CT_THREADS_NATIVE=y +CT_LIBC_XLDD=y + +# +# glibc other options +# +# CT_LIBC_GLIBC_PORTS_EXTERNAL is not set +CT_LIBC_GLIBC_MAY_FORCE_PORTS=y +CT_LIBC_glibc_familly=y +CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY="" +CT_LIBC_GLIBC_CONFIGPARMS="" +CT_LIBC_GLIBC_EXTRA_CFLAGS="" +CT_LIBC_EXTRA_CC_ARGS="" +# CT_LIBC_DISABLE_VERSIONING is not set +CT_LIBC_OLDEST_ABI="" +CT_LIBC_GLIBC_FORCE_UNWIND=y +CT_LIBC_GLIBC_USE_PORTS=y +CT_LIBC_ADDONS_LIST="" + +# +# WARNING !!! +# + +# +# For glibc >= 2.8, it can happen that the tarballs +# + +# +# for the addons are not available for download. +# + +# +# If that happens, bad luck... Try a previous version +# + +# +# or try again later... :-( +# +# CT_LIBC_LOCALES is not set +# CT_LIBC_GLIBC_KERNEL_VERSION_NONE is not set +CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS=y +# CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN is not set +CT_LIBC_GLIBC_MIN_KERNEL="4.2.6" + +# +# C compiler +# +CT_CC="gcc" +CT_CC_CORE_PASSES_NEEDED=y +CT_CC_CORE_PASS_1_NEEDED=y +CT_CC_CORE_PASS_2_NEEDED=y +CT_CC_gcc=y +# CT_CC_GCC_SHOW_LINARO is not set +CT_CC_GCC_V_5_2_0=y +# CT_CC_GCC_V_4_9_3 is not set +# CT_CC_GCC_V_4_8_5 is not set +# CT_CC_GCC_V_4_7_4 is not set +# CT_CC_GCC_V_4_6_4 is not set +# CT_CC_GCC_V_4_5_4 is not set +# CT_CC_GCC_V_4_4_7 is not set +# CT_CC_GCC_V_4_3_6 is not set +# CT_CC_GCC_V_4_2_4 is not set +CT_CC_GCC_4_2_or_later=y +CT_CC_GCC_4_3_or_later=y +CT_CC_GCC_4_4_or_later=y +CT_CC_GCC_4_5_or_later=y +CT_CC_GCC_4_6_or_later=y +CT_CC_GCC_4_7_or_later=y +CT_CC_GCC_4_8_or_later=y +CT_CC_GCC_4_9_or_later=y +CT_CC_GCC_5=y +CT_CC_GCC_5_or_later=y +CT_CC_GCC_HAS_GRAPHITE=y +CT_CC_GCC_USE_GRAPHITE=y +CT_CC_GCC_HAS_LTO=y +CT_CC_GCC_USE_LTO=y +CT_CC_GCC_HAS_PKGVERSION_BUGURL=y +CT_CC_GCC_HAS_BUILD_ID=y +CT_CC_GCC_HAS_LNK_HASH_STYLE=y +CT_CC_GCC_USE_GMP_MPFR=y +CT_CC_GCC_USE_MPC=y +CT_CC_GCC_HAS_LIBQUADMATH=y +CT_CC_GCC_HAS_LIBSANITIZER=y +CT_CC_GCC_VERSION="5.2.0" +# CT_CC_LANG_FORTRAN is not set +CT_CC_GCC_ENABLE_CXX_FLAGS="" +CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_EXTRA_ENV_ARRAY="" +CT_CC_GCC_STATIC_LIBSTDCXX=y +# CT_CC_GCC_SYSTEM_ZLIB is not set + +# +# Optimisation features +# + +# +# Settings for libraries running on target +# +CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y +# CT_CC_GCC_LIBMUDFLAP is not set +# CT_CC_GCC_LIBGOMP is not set +# CT_CC_GCC_LIBSSP is not set +# CT_CC_GCC_LIBQUADMATH is not set +# CT_CC_GCC_LIBSANITIZER is not set + +# +# Misc. obscure options. +# +CT_CC_CXA_ATEXIT=y +# CT_CC_GCC_DISABLE_PCH is not set +CT_CC_GCC_SJLJ_EXCEPTIONS=m +CT_CC_GCC_LDBL_128=m +# CT_CC_GCC_BUILD_ID is not set +CT_CC_GCC_LNK_HASH_STYLE_DEFAULT=y +# CT_CC_GCC_LNK_HASH_STYLE_SYSV is not set +# CT_CC_GCC_LNK_HASH_STYLE_GNU is not set +# CT_CC_GCC_LNK_HASH_STYLE_BOTH is not set +CT_CC_GCC_LNK_HASH_STYLE="" +CT_CC_GCC_DEC_FLOAT_AUTO=y +# CT_CC_GCC_DEC_FLOAT_BID is not set +# CT_CC_GCC_DEC_FLOAT_DPD is not set +# CT_CC_GCC_DEC_FLOATS_NO is not set +CT_CC_SUPPORT_CXX=y +CT_CC_SUPPORT_FORTRAN=y +CT_CC_SUPPORT_JAVA=y +CT_CC_SUPPORT_ADA=y +CT_CC_SUPPORT_OBJC=y +CT_CC_SUPPORT_OBJCXX=y +CT_CC_SUPPORT_GOLANG=y + +# +# Additional supported languages: +# +CT_CC_LANG_CXX=y +# CT_CC_LANG_JAVA is not set + +# +# Debug facilities +# +# CT_DEBUG_dmalloc is not set +# CT_DEBUG_duma is not set +# CT_DEBUG_gdb is not set +# CT_DEBUG_ltrace is not set +# CT_DEBUG_strace is not set + +# +# Companion libraries +# +CT_COMPLIBS_NEEDED=y +CT_LIBICONV_NEEDED=y +CT_GETTEXT_NEEDED=y +CT_GMP_NEEDED=y +CT_MPFR_NEEDED=y +CT_ISL_NEEDED=y +CT_MPC_NEEDED=y +CT_COMPLIBS=y +CT_LIBICONV=y +CT_GETTEXT=y +CT_GMP=y +CT_MPFR=y +CT_ISL=y +CT_MPC=y +CT_LIBICONV_V_1_14=y +CT_LIBICONV_VERSION="1.14" +CT_GETTEXT_V_0_19_6=y +CT_GETTEXT_VERSION="0.19.6" +CT_GMP_V_6_0_0=y +# CT_GMP_V_5_1_3 is not set +# CT_GMP_V_5_1_1 is not set +# CT_GMP_V_5_0_2 is not set +# CT_GMP_V_5_0_1 is not set +# CT_GMP_V_4_3_2 is not set +# CT_GMP_V_4_3_1 is not set +# CT_GMP_V_4_3_0 is not set +CT_GMP_5_0_2_or_later=y +CT_GMP_VERSION="6.0.0a" +CT_MPFR_V_3_1_3=y +# CT_MPFR_V_3_1_2 is not set +# CT_MPFR_V_3_1_0 is not set +# CT_MPFR_V_3_0_1 is not set +# CT_MPFR_V_3_0_0 is not set +# CT_MPFR_V_2_4_2 is not set +# CT_MPFR_V_2_4_1 is not set +# CT_MPFR_V_2_4_0 is not set +CT_MPFR_VERSION="3.1.3" +CT_ISL_V_0_14=y +# CT_ISL_V_0_12_2 is not set +CT_ISL_V_0_14_or_later=y +CT_ISL_V_0_12_or_later=y +CT_ISL_VERSION="0.14" +# CT_CLOOG_V_0_18_4 is not set +# CT_CLOOG_V_0_18_1 is not set +# CT_CLOOG_V_0_18_0 is not set +CT_MPC_V_1_0_3=y +# CT_MPC_V_1_0_2 is not set +# CT_MPC_V_1_0_1 is not set +# CT_MPC_V_1_0 is not set +# CT_MPC_V_0_9 is not set +# CT_MPC_V_0_8_2 is not set +# CT_MPC_V_0_8_1 is not set +# CT_MPC_V_0_7 is not set +CT_MPC_VERSION="1.0.3" + +# +# Companion libraries common options +# +# CT_COMPLIBS_CHECK is not set + +# +# Companion tools +# + +# +# READ HELP before you say 'Y' below !!! +# +# CT_COMP_TOOLS is not set diff --git a/src/ci/docker/dist-armv7-aarch64-linux/armv7-linux-gnueabihf.config b/src/ci/docker/dist-armv7-aarch64-linux/armv7-linux-gnueabihf.config new file mode 100644 index 0000000000000..79d6c77c41152 --- /dev/null +++ b/src/ci/docker/dist-armv7-aarch64-linux/armv7-linux-gnueabihf.config @@ -0,0 +1,569 @@ +# +# Automatically generated file; DO NOT EDIT. +# Crosstool-NG Configuration +# +CT_CONFIGURE_has_make381=y +CT_MODULES=y + +# +# Paths and misc options +# + +# +# crosstool-NG behavior +# +# CT_OBSOLETE is not set +# CT_EXPERIMENTAL is not set +# CT_DEBUG_CT is not set + +# +# Paths +# +CT_LOCAL_TARBALLS_DIR="" +CT_WORK_DIR="${CT_TOP_DIR}/.build" +CT_PREFIX_DIR="/x-tools/${CT_TARGET}" +CT_INSTALL_DIR="${CT_PREFIX_DIR}" +CT_RM_RF_PREFIX_DIR=y +CT_REMOVE_DOCS=y +CT_INSTALL_DIR_RO=y +CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES=y +# CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES is not set + +# +# Downloading +# +# CT_FORBID_DOWNLOAD is not set +# CT_FORCE_DOWNLOAD is not set +CT_CONNECT_TIMEOUT=10 +# CT_ONLY_DOWNLOAD is not set +# CT_USE_MIRROR is not set + +# +# Extracting +# +# CT_FORCE_EXTRACT is not set +CT_OVERIDE_CONFIG_GUESS_SUB=y +# CT_ONLY_EXTRACT is not set +CT_PATCH_BUNDLED=y +# CT_PATCH_LOCAL is not set +# CT_PATCH_BUNDLED_LOCAL is not set +# CT_PATCH_LOCAL_BUNDLED is not set +# CT_PATCH_BUNDLED_FALLBACK_LOCAL is not set +# CT_PATCH_LOCAL_FALLBACK_BUNDLED is not set +# CT_PATCH_NONE is not set +CT_PATCH_ORDER="bundled" + +# +# Build behavior +# +CT_PARALLEL_JOBS=0 +CT_LOAD="" +CT_USE_PIPES=y +CT_EXTRA_CFLAGS_FOR_BUILD="" +CT_EXTRA_LDFLAGS_FOR_BUILD="" +CT_EXTRA_CFLAGS_FOR_HOST="" +CT_EXTRA_LDFLAGS_FOR_HOST="" +# CT_CONFIG_SHELL_SH is not set +# CT_CONFIG_SHELL_ASH is not set +CT_CONFIG_SHELL_BASH=y +# CT_CONFIG_SHELL_CUSTOM is not set +CT_CONFIG_SHELL="${bash}" + +# +# Logging +# +# CT_LOG_ERROR is not set +# CT_LOG_WARN is not set +CT_LOG_INFO=y +# CT_LOG_EXTRA is not set +# CT_LOG_ALL is not set +# CT_LOG_DEBUG is not set +CT_LOG_LEVEL_MAX="INFO" +# CT_LOG_SEE_TOOLS_WARN is not set +CT_LOG_PROGRESS_BAR=y +CT_LOG_TO_FILE=y +CT_LOG_FILE_COMPRESS=y + +# +# Target options +# +CT_ARCH="arm" +CT_ARCH_SUPPORTS_BOTH_MMU=y +CT_ARCH_SUPPORTS_BOTH_ENDIAN=y +CT_ARCH_SUPPORTS_32=y +CT_ARCH_SUPPORTS_64=y +CT_ARCH_SUPPORTS_WITH_ARCH=y +CT_ARCH_SUPPORTS_WITH_CPU=y +CT_ARCH_SUPPORTS_WITH_TUNE=y +CT_ARCH_SUPPORTS_WITH_FLOAT=y +CT_ARCH_SUPPORTS_WITH_FPU=y +CT_ARCH_SUPPORTS_SOFTFP=y +CT_ARCH_DEFAULT_HAS_MMU=y +CT_ARCH_DEFAULT_LE=y +CT_ARCH_DEFAULT_32=y +CT_ARCH_ARCH="armv7-a" +CT_ARCH_CPU="" +CT_ARCH_TUNE="" +CT_ARCH_FPU="vfpv3-d16" +# CT_ARCH_BE is not set +CT_ARCH_LE=y +CT_ARCH_32=y +# CT_ARCH_64 is not set +CT_ARCH_BITNESS=32 +CT_ARCH_FLOAT_HW=y +# CT_ARCH_FLOAT_SW is not set +CT_TARGET_CFLAGS="" +CT_TARGET_LDFLAGS="" +# CT_ARCH_alpha is not set +CT_ARCH_arm=y +# CT_ARCH_avr is not set +# CT_ARCH_m68k is not set +# CT_ARCH_mips is not set +# CT_ARCH_nios2 is not set +# CT_ARCH_powerpc is not set +# CT_ARCH_s390 is not set +# CT_ARCH_sh is not set +# CT_ARCH_sparc is not set +# CT_ARCH_x86 is not set +# CT_ARCH_xtensa is not set +CT_ARCH_alpha_AVAILABLE=y +CT_ARCH_arm_AVAILABLE=y +CT_ARCH_avr_AVAILABLE=y +CT_ARCH_m68k_AVAILABLE=y +CT_ARCH_microblaze_AVAILABLE=y +CT_ARCH_mips_AVAILABLE=y +CT_ARCH_nios2_AVAILABLE=y +CT_ARCH_powerpc_AVAILABLE=y +CT_ARCH_s390_AVAILABLE=y +CT_ARCH_sh_AVAILABLE=y +CT_ARCH_sparc_AVAILABLE=y +CT_ARCH_x86_AVAILABLE=y +CT_ARCH_xtensa_AVAILABLE=y +CT_ARCH_SUFFIX="v7" + +# +# Generic target options +# +# CT_MULTILIB is not set +CT_ARCH_USE_MMU=y +CT_ARCH_ENDIAN="little" + +# +# Target optimisations +# +CT_ARCH_EXCLUSIVE_WITH_CPU=y +# CT_ARCH_FLOAT_AUTO is not set +# CT_ARCH_FLOAT_SOFTFP is not set +CT_ARCH_FLOAT="hard" +# CT_ARCH_ALPHA_EV4 is not set +# CT_ARCH_ALPHA_EV45 is not set +# CT_ARCH_ALPHA_EV5 is not set +# CT_ARCH_ALPHA_EV56 is not set +# CT_ARCH_ALPHA_EV6 is not set +# CT_ARCH_ALPHA_EV67 is not set + +# +# arm other options +# +CT_ARCH_ARM_MODE="thumb" +# CT_ARCH_ARM_MODE_ARM is not set +CT_ARCH_ARM_MODE_THUMB=y +# CT_ARCH_ARM_INTERWORKING is not set +CT_ARCH_ARM_EABI_FORCE=y +CT_ARCH_ARM_EABI=y +CT_ARCH_ARM_TUPLE_USE_EABIHF=y + +# +# Toolchain options +# + +# +# General toolchain options +# +CT_FORCE_SYSROOT=y +CT_USE_SYSROOT=y +CT_SYSROOT_NAME="sysroot" +CT_SYSROOT_DIR_PREFIX="" +CT_WANTS_STATIC_LINK=y +# CT_STATIC_TOOLCHAIN is not set +CT_TOOLCHAIN_PKGVERSION="" +CT_TOOLCHAIN_BUGURL="" + +# +# Tuple completion and aliasing +# +CT_TARGET_VENDOR="unknown" +CT_TARGET_ALIAS_SED_EXPR="" +CT_TARGET_ALIAS="" + +# +# Toolchain type +# +CT_CROSS=y +# CT_CANADIAN is not set +CT_TOOLCHAIN_TYPE="cross" + +# +# Build system +# +CT_BUILD="" +CT_BUILD_PREFIX="" +CT_BUILD_SUFFIX="" + +# +# Misc options +# +# CT_TOOLCHAIN_ENABLE_NLS is not set + +# +# Operating System +# +CT_KERNEL_SUPPORTS_SHARED_LIBS=y +CT_KERNEL="linux" +CT_KERNEL_VERSION="3.2.72" +# CT_KERNEL_bare_metal is not set +CT_KERNEL_linux=y +CT_KERNEL_bare_metal_AVAILABLE=y +CT_KERNEL_linux_AVAILABLE=y +# CT_KERNEL_V_4_3 is not set +# CT_KERNEL_V_4_2 is not set +# CT_KERNEL_V_4_1 is not set +# CT_KERNEL_V_3_18 is not set +# CT_KERNEL_V_3_14 is not set +# CT_KERNEL_V_3_12 is not set +# CT_KERNEL_V_3_10 is not set +# CT_KERNEL_V_3_4 is not set +CT_KERNEL_V_3_2=y +# CT_KERNEL_V_2_6_32 is not set +# CT_KERNEL_LINUX_CUSTOM is not set +CT_KERNEL_windows_AVAILABLE=y + +# +# Common kernel options +# +CT_SHARED_LIBS=y + +# +# linux other options +# +CT_KERNEL_LINUX_VERBOSITY_0=y +# CT_KERNEL_LINUX_VERBOSITY_1 is not set +# CT_KERNEL_LINUX_VERBOSITY_2 is not set +CT_KERNEL_LINUX_VERBOSE_LEVEL=0 +CT_KERNEL_LINUX_INSTALL_CHECK=y + +# +# Binary utilities +# +CT_ARCH_BINFMT_ELF=y +CT_BINUTILS="binutils" +CT_BINUTILS_binutils=y + +# +# GNU binutils +# +# CT_CC_BINUTILS_SHOW_LINARO is not set +CT_BINUTILS_V_2_25_1=y +# CT_BINUTILS_V_2_25 is not set +# CT_BINUTILS_V_2_24 is not set +# CT_BINUTILS_V_2_23_2 is not set +# CT_BINUTILS_V_2_23_1 is not set +# CT_BINUTILS_V_2_22 is not set +# CT_BINUTILS_V_2_21_53 is not set +# CT_BINUTILS_V_2_21_1a is not set +# CT_BINUTILS_V_2_20_1a is not set +# CT_BINUTILS_V_2_19_1a is not set +# CT_BINUTILS_V_2_18a is not set +CT_BINUTILS_VERSION="2.25.1" +CT_BINUTILS_2_25_1_or_later=y +CT_BINUTILS_2_25_or_later=y +CT_BINUTILS_2_24_or_later=y +CT_BINUTILS_2_23_or_later=y +CT_BINUTILS_2_22_or_later=y +CT_BINUTILS_2_21_or_later=y +CT_BINUTILS_2_20_or_later=y +CT_BINUTILS_2_19_or_later=y +CT_BINUTILS_2_18_or_later=y +CT_BINUTILS_HAS_HASH_STYLE=y +CT_BINUTILS_HAS_GOLD=y +CT_BINUTILS_GOLD_SUPPORTS_ARCH=y +CT_BINUTILS_GOLD_SUPPORT=y +CT_BINUTILS_HAS_PLUGINS=y +CT_BINUTILS_HAS_PKGVERSION_BUGURL=y +CT_BINUTILS_FORCE_LD_BFD=y +CT_BINUTILS_LINKER_LD=y +# CT_BINUTILS_LINKER_LD_GOLD is not set +# CT_BINUTILS_LINKER_GOLD_LD is not set +CT_BINUTILS_LINKERS_LIST="ld" +CT_BINUTILS_LINKER_DEFAULT="bfd" +# CT_BINUTILS_PLUGINS is not set +CT_BINUTILS_EXTRA_CONFIG_ARRAY="" +# CT_BINUTILS_FOR_TARGET is not set + +# +# binutils other options +# + +# +# C-library +# +CT_LIBC="glibc" +CT_LIBC_VERSION="2.16.0" +CT_LIBC_glibc=y +# CT_LIBC_musl is not set +# CT_LIBC_newlib is not set +# CT_LIBC_none is not set +# CT_LIBC_uClibc is not set +CT_LIBC_avr_libc_AVAILABLE=y +CT_LIBC_glibc_AVAILABLE=y +CT_THREADS="nptl" +# CT_CC_GLIBC_SHOW_LINARO is not set +# CT_LIBC_GLIBC_V_2_22 is not set +# CT_LIBC_GLIBC_V_2_21 is not set +# CT_LIBC_GLIBC_V_2_20 is not set +# CT_LIBC_GLIBC_V_2_19 is not set +# CT_LIBC_GLIBC_V_2_18 is not set +# CT_LIBC_GLIBC_V_2_17 is not set +CT_LIBC_GLIBC_V_2_16_0=y +# CT_LIBC_GLIBC_V_2_15 is not set +# CT_LIBC_GLIBC_V_2_14_1 is not set +# CT_LIBC_GLIBC_V_2_14 is not set +# CT_LIBC_GLIBC_V_2_13 is not set +# CT_LIBC_GLIBC_V_2_12_2 is not set +# CT_LIBC_GLIBC_V_2_12_1 is not set +# CT_LIBC_GLIBC_V_2_11_1 is not set +# CT_LIBC_GLIBC_V_2_11 is not set +# CT_LIBC_GLIBC_V_2_10_1 is not set +# CT_LIBC_GLIBC_V_2_9 is not set +# CT_LIBC_GLIBC_V_2_8 is not set +CT_LIBC_mingw_AVAILABLE=y +CT_LIBC_musl_AVAILABLE=y +CT_LIBC_newlib_AVAILABLE=y +CT_LIBC_none_AVAILABLE=y +CT_LIBC_uClibc_AVAILABLE=y +CT_LIBC_SUPPORT_THREADS_ANY=y +CT_LIBC_SUPPORT_THREADS_NATIVE=y + +# +# Common C library options +# +CT_THREADS_NATIVE=y +CT_LIBC_XLDD=y + +# +# glibc other options +# +CT_LIBC_GLIBC_PORTS_EXTERNAL=y +CT_LIBC_GLIBC_MAY_FORCE_PORTS=y +CT_LIBC_glibc_familly=y +CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY="" +CT_LIBC_GLIBC_CONFIGPARMS="" +CT_LIBC_GLIBC_EXTRA_CFLAGS="" +CT_LIBC_EXTRA_CC_ARGS="" +# CT_LIBC_DISABLE_VERSIONING is not set +CT_LIBC_OLDEST_ABI="" +CT_LIBC_GLIBC_FORCE_UNWIND=y +CT_LIBC_GLIBC_USE_PORTS=y +CT_LIBC_ADDONS_LIST="" + +# +# WARNING !!! +# + +# +# For glibc >= 2.8, it can happen that the tarballs +# + +# +# for the addons are not available for download. +# + +# +# If that happens, bad luck... Try a previous version +# + +# +# or try again later... :-( +# +# CT_LIBC_LOCALES is not set +# CT_LIBC_GLIBC_KERNEL_VERSION_NONE is not set +CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS=y +# CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN is not set +CT_LIBC_GLIBC_MIN_KERNEL="3.2.72" + +# +# C compiler +# +CT_CC="gcc" +CT_CC_CORE_PASSES_NEEDED=y +CT_CC_CORE_PASS_1_NEEDED=y +CT_CC_CORE_PASS_2_NEEDED=y +CT_CC_gcc=y +# CT_CC_GCC_SHOW_LINARO is not set +# CT_CC_GCC_V_5_2_0 is not set +CT_CC_GCC_V_4_9_3=y +# CT_CC_GCC_V_4_8_5 is not set +# CT_CC_GCC_V_4_7_4 is not set +# CT_CC_GCC_V_4_6_4 is not set +# CT_CC_GCC_V_4_5_4 is not set +# CT_CC_GCC_V_4_4_7 is not set +# CT_CC_GCC_V_4_3_6 is not set +# CT_CC_GCC_V_4_2_4 is not set +CT_CC_GCC_4_2_or_later=y +CT_CC_GCC_4_3_or_later=y +CT_CC_GCC_4_4_or_later=y +CT_CC_GCC_4_5_or_later=y +CT_CC_GCC_4_6_or_later=y +CT_CC_GCC_4_7_or_later=y +CT_CC_GCC_4_8_or_later=y +CT_CC_GCC_4_9=y +CT_CC_GCC_4_9_or_later=y +CT_CC_GCC_HAS_GRAPHITE=y +CT_CC_GCC_USE_GRAPHITE=y +CT_CC_GCC_HAS_LTO=y +CT_CC_GCC_USE_LTO=y +CT_CC_GCC_HAS_PKGVERSION_BUGURL=y +CT_CC_GCC_HAS_BUILD_ID=y +CT_CC_GCC_HAS_LNK_HASH_STYLE=y +CT_CC_GCC_USE_GMP_MPFR=y +CT_CC_GCC_USE_MPC=y +CT_CC_GCC_HAS_LIBQUADMATH=y +CT_CC_GCC_HAS_LIBSANITIZER=y +CT_CC_GCC_VERSION="4.9.3" +# CT_CC_LANG_FORTRAN is not set +CT_CC_GCC_ENABLE_CXX_FLAGS="" +CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_EXTRA_ENV_ARRAY="" +CT_CC_GCC_STATIC_LIBSTDCXX=y +# CT_CC_GCC_SYSTEM_ZLIB is not set + +# +# Optimisation features +# + +# +# Settings for libraries running on target +# +CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y +# CT_CC_GCC_LIBMUDFLAP is not set +# CT_CC_GCC_LIBGOMP is not set +# CT_CC_GCC_LIBSSP is not set +# CT_CC_GCC_LIBQUADMATH is not set +# CT_CC_GCC_LIBSANITIZER is not set + +# +# Misc. obscure options. +# +CT_CC_CXA_ATEXIT=y +# CT_CC_GCC_DISABLE_PCH is not set +CT_CC_GCC_SJLJ_EXCEPTIONS=m +CT_CC_GCC_LDBL_128=m +# CT_CC_GCC_BUILD_ID is not set +CT_CC_GCC_LNK_HASH_STYLE_DEFAULT=y +# CT_CC_GCC_LNK_HASH_STYLE_SYSV is not set +# CT_CC_GCC_LNK_HASH_STYLE_GNU is not set +# CT_CC_GCC_LNK_HASH_STYLE_BOTH is not set +CT_CC_GCC_LNK_HASH_STYLE="" +CT_CC_GCC_DEC_FLOAT_AUTO=y +# CT_CC_GCC_DEC_FLOAT_BID is not set +# CT_CC_GCC_DEC_FLOAT_DPD is not set +# CT_CC_GCC_DEC_FLOATS_NO is not set +CT_CC_SUPPORT_CXX=y +CT_CC_SUPPORT_FORTRAN=y +CT_CC_SUPPORT_JAVA=y +CT_CC_SUPPORT_ADA=y +CT_CC_SUPPORT_OBJC=y +CT_CC_SUPPORT_OBJCXX=y +CT_CC_SUPPORT_GOLANG=y + +# +# Additional supported languages: +# +CT_CC_LANG_CXX=y +# CT_CC_LANG_JAVA is not set + +# +# Debug facilities +# +# CT_DEBUG_dmalloc is not set +# CT_DEBUG_duma is not set +# CT_DEBUG_gdb is not set +# CT_DEBUG_ltrace is not set +# CT_DEBUG_strace is not set + +# +# Companion libraries +# +CT_COMPLIBS_NEEDED=y +CT_LIBICONV_NEEDED=y +CT_GETTEXT_NEEDED=y +CT_GMP_NEEDED=y +CT_MPFR_NEEDED=y +CT_ISL_NEEDED=y +CT_CLOOG_NEEDED=y +CT_MPC_NEEDED=y +CT_COMPLIBS=y +CT_LIBICONV=y +CT_GETTEXT=y +CT_GMP=y +CT_MPFR=y +CT_ISL=y +CT_CLOOG=y +CT_MPC=y +CT_LIBICONV_V_1_14=y +CT_LIBICONV_VERSION="1.14" +CT_GETTEXT_V_0_19_6=y +CT_GETTEXT_VERSION="0.19.6" +CT_GMP_V_6_0_0=y +# CT_GMP_V_5_1_3 is not set +# CT_GMP_V_5_1_1 is not set +# CT_GMP_V_5_0_2 is not set +# CT_GMP_V_5_0_1 is not set +# CT_GMP_V_4_3_2 is not set +# CT_GMP_V_4_3_1 is not set +# CT_GMP_V_4_3_0 is not set +CT_GMP_5_0_2_or_later=y +CT_GMP_VERSION="6.0.0a" +CT_MPFR_V_3_1_3=y +# CT_MPFR_V_3_1_2 is not set +# CT_MPFR_V_3_1_0 is not set +# CT_MPFR_V_3_0_1 is not set +# CT_MPFR_V_3_0_0 is not set +# CT_MPFR_V_2_4_2 is not set +# CT_MPFR_V_2_4_1 is not set +# CT_MPFR_V_2_4_0 is not set +CT_MPFR_VERSION="3.1.3" +CT_ISL_V_0_14=y +CT_ISL_V_0_14_or_later=y +CT_ISL_V_0_12_or_later=y +CT_ISL_VERSION="0.14" +CT_CLOOG_V_0_18_4=y +# CT_CLOOG_V_0_18_1 is not set +# CT_CLOOG_V_0_18_0 is not set +CT_CLOOG_VERSION="0.18.4" +CT_CLOOG_0_18_4_or_later=y +CT_CLOOG_0_18_or_later=y +CT_MPC_V_1_0_3=y +# CT_MPC_V_1_0_2 is not set +# CT_MPC_V_1_0_1 is not set +# CT_MPC_V_1_0 is not set +# CT_MPC_V_0_9 is not set +# CT_MPC_V_0_8_2 is not set +# CT_MPC_V_0_8_1 is not set +# CT_MPC_V_0_7 is not set +CT_MPC_VERSION="1.0.3" + +# +# Companion libraries common options +# +# CT_COMPLIBS_CHECK is not set + +# +# Companion tools +# + +# +# READ HELP before you say 'Y' below !!! +# +# CT_COMP_TOOLS is not set diff --git a/src/ci/docker/dist-x86-linux/Dockerfile b/src/ci/docker/dist-x86-linux/Dockerfile new file mode 100644 index 0000000000000..51e568a032338 --- /dev/null +++ b/src/ci/docker/dist-x86-linux/Dockerfile @@ -0,0 +1,83 @@ +FROM centos:5 + +WORKDIR /build + +RUN yum upgrade -y && yum install -y \ + curl \ + bzip2 \ + gcc \ + make \ + glibc-devel \ + perl \ + zlib-devel \ + file \ + xz \ + which \ + pkg-config \ + wget \ + autoconf \ + gettext + +ENV PATH=/rustroot/bin:$PATH +ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib +WORKDIR /tmp + +# binutils < 2.22 has a bug where the 32-bit executables it generates +# immediately segfault in Rust, so we need to install our own binutils. +# +# See https://github.com/rust-lang/rust/issues/20440 for more info +COPY shared.sh build-binutils.sh /tmp/ +RUN ./build-binutils.sh + +# Need a newer version of gcc than centos has to compile LLVM nowadays +COPY build-gcc.sh /tmp/ +RUN ./build-gcc.sh + +# We need a build of openssl which supports SNI to download artifacts from +# static.rust-lang.org. This'll be used to link into libcurl below (and used +# later as well), so build a copy of OpenSSL with dynamic libraries into our +# generic root. +COPY build-openssl.sh /tmp/ +RUN ./build-openssl.sh + +# The `curl` binary on CentOS doesn't support SNI which is needed for fetching +# some https urls we have, so install a new version of libcurl + curl which is +# using the openssl we just built previously. +# +# Note that we also disable a bunch of optional features of curl that we don't +# really need. +COPY build-curl.sh /tmp/ +RUN ./build-curl.sh + +# CentOS 5.5 has Python 2.4 by default, but LLVM needs 2.7+ +COPY build-python.sh /tmp/ +RUN ./build-python.sh + +# Apparently CentOS 5.5 desn't have `git` in yum, but we're gonna need it for +# cloning, so download and build it here. +COPY build-git.sh /tmp/ +RUN ./build-git.sh + +# libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS +# only has 2.6.4, so build our own +COPY build-cmake.sh /tmp/ +RUN ./build-cmake.sh + +RUN curl -Lo /rustroot/dumb-init \ + https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && \ + chmod +x /rustroot/dumb-init +ENTRYPOINT ["/rustroot/dumb-init", "--"] + +ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783 +RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \ + xz --decompress | \ + tar xf - -C /usr/local/bin --strip-components=1 + +ENV RUST_CONFIGURE_ARGS \ + --host=i686-unknown-linux-gnu,x86_64-unknown-linux-gnu +ENV SCRIPT \ + python2.7 ../x.py dist \ + --host i686-unknown-linux-gnu \ + --target i686-unknown-linux-gnu \ + --host x86_64-unknown-linux-gnu \ + --target x86_64-unknown-linux-gnu diff --git a/src/ci/docker/dist-x86-linux/build-binutils.sh b/src/ci/docker/dist-x86-linux/build-binutils.sh new file mode 100755 index 0000000000000..80aa1f2a01613 --- /dev/null +++ b/src/ci/docker/dist-x86-linux/build-binutils.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +source shared.sh + +curl https://ftp.gnu.org/gnu/binutils/binutils-2.25.1.tar.bz2 | tar xfj - + +mkdir binutils-build +cd binutils-build +hide_output ../binutils-2.25.1/configure --prefix=/rustroot +hide_output make -j10 +hide_output make install + +cd .. +rm -rf binutils-build +rm -rf binutils-2.25.1 diff --git a/src/ci/docker/dist-x86-linux/build-cmake.sh b/src/ci/docker/dist-x86-linux/build-cmake.sh new file mode 100755 index 0000000000000..82e46455cb0f0 --- /dev/null +++ b/src/ci/docker/dist-x86-linux/build-cmake.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex +source shared.sh + +curl https://cmake.org/files/v3.6/cmake-3.6.3.tar.gz | tar xzf - + +mkdir cmake-build +cd cmake-build +hide_output ../cmake-3.6.3/configure --prefix=/rustroot +hide_output make -j10 +hide_output make install + +cd .. +rm -rf cmake-build +rm -rf cmake-3.6.3 diff --git a/src/ci/docker/dist-x86-linux/build-curl.sh b/src/ci/docker/dist-x86-linux/build-curl.sh new file mode 100755 index 0000000000000..b7d22755a571b --- /dev/null +++ b/src/ci/docker/dist-x86-linux/build-curl.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex +source shared.sh + +VERSION=7.51.0 + +curl http://cool.haxx.se/download/curl-$VERSION.tar.bz2 | tar xjf - + +mkdir curl-build +cd curl-build +hide_output ../curl-$VERSION/configure \ + --prefix=/rustroot \ + --with-ssl=/rustroot \ + --disable-sspi \ + --disable-gopher \ + --disable-smtp \ + --disable-smb \ + --disable-imap \ + --disable-pop3 \ + --disable-tftp \ + --disable-telnet \ + --disable-manual \ + --disable-dict \ + --disable-rtsp \ + --disable-ldaps \ + --disable-ldap +hide_output make -j10 +hide_output make install + +cd .. +rm -rf curl-build +rm -rf curl-$VERSION +yum erase -y curl diff --git a/src/ci/docker/dist-x86-linux/build-gcc.sh b/src/ci/docker/dist-x86-linux/build-gcc.sh new file mode 100755 index 0000000000000..06198eb0c97fc --- /dev/null +++ b/src/ci/docker/dist-x86-linux/build-gcc.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +source shared.sh + +curl https://ftp.gnu.org/gnu/gcc/gcc-4.7.4/gcc-4.7.4.tar.bz2 | tar xjf - +cd gcc-4.7.4 +./contrib/download_prerequisites +mkdir ../gcc-build +cd ../gcc-build +hide_output ../gcc-4.7.4/configure \ + --prefix=/rustroot \ + --enable-languages=c,c++ +hide_output make -j10 +hide_output make install +ln -nsf gcc /rustroot/bin/cc + +cd .. +rm -rf gcc-build +rm -rf gcc-4.7.4 +yum erase -y gcc binutils diff --git a/src/ci/docker/dist-x86-linux/build-git.sh b/src/ci/docker/dist-x86-linux/build-git.sh new file mode 100755 index 0000000000000..92fa66b496d93 --- /dev/null +++ b/src/ci/docker/dist-x86-linux/build-git.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex +source shared.sh + +curl https://www.kernel.org/pub/software/scm/git/git-2.10.0.tar.gz | tar xzf - + +cd git-2.10.0 +make configure +hide_output ./configure --prefix=/rustroot +hide_output make -j10 +hide_output make install + +cd .. +rm -rf git-2.10.0 diff --git a/src/ci/docker/dist-x86-linux/build-openssl.sh b/src/ci/docker/dist-x86-linux/build-openssl.sh new file mode 100755 index 0000000000000..64b1abf82a827 --- /dev/null +++ b/src/ci/docker/dist-x86-linux/build-openssl.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex +source shared.sh + +VERSION=1.0.2j + +curl https://www.openssl.org/source/openssl-$VERSION.tar.gz | tar xzf - + +cd openssl-$VERSION +hide_output ./config --prefix=/rustroot shared -fPIC +hide_output make -j10 +hide_output make install +cd .. +rm -rf openssl-$VERSION + +# Make the system cert collection available to the new install. +ln -nsf /etc/pki/tls/cert.pem /rustroot/ssl/ diff --git a/src/ci/docker/dist-x86-linux/build-python.sh b/src/ci/docker/dist-x86-linux/build-python.sh new file mode 100755 index 0000000000000..a7a450f3c8de7 --- /dev/null +++ b/src/ci/docker/dist-x86-linux/build-python.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex +source shared.sh + +curl https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz | \ + tar xzf - + +mkdir python-build +cd python-build + +# Gotta do some hackery to tell python about our custom OpenSSL build, but other +# than that fairly normal. +CFLAGS='-I /rustroot/include' LDFLAGS='-L /rustroot/lib -L /rustroot/lib64' \ + hide_output ../Python-2.7.12/configure --prefix=/rustroot +hide_output make -j10 +hide_output make install + +cd .. +rm -rf python-build +rm -rf Python-2.7.12 diff --git a/src/ci/docker/dist-x86-linux/shared.sh b/src/ci/docker/dist-x86-linux/shared.sh new file mode 100644 index 0000000000000..97e6d2908cf8a --- /dev/null +++ b/src/ci/docker/dist-x86-linux/shared.sh @@ -0,0 +1,25 @@ +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +hide_output() { + set +x + on_err=" +echo ERROR: An error was encountered with the build. +cat /tmp/build.log +exit 1 +" + trap "$on_err" ERR + bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & + PING_LOOP_PID=$! + $@ &> /tmp/build.log + trap - ERR + kill $PING_LOOP_PID + set -x +} diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 80f40d1ba4773..0ddab8c4160f4 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -51,5 +51,6 @@ exec docker \ --env DEPLOY=$DEPLOY \ --env LOCAL_USER_ID=`id -u` \ --volume "$HOME/.cargo:/cargo" \ + --rm \ rust-ci \ /checkout/src/ci/run.sh diff --git a/src/ci/run.sh b/src/ci/run.sh index 205228a7bccc8..71501a7b377d0 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -22,19 +22,6 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-quiet-tests" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules" -# FIXME: we shouldn't forcibly enable debug assertions and llvm assertions when -# `DEPLOY` is set because then we'll be shipping slower binaries. We -# should only set these for auto branches, but we need to make sure that -# if we disable this all the relevant platforms are still tested -# somewhere with debug and llvm assertions. -RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-debug-assertions" - -# In general we always want to run tests with LLVM assertions enabled, but not -# all platforms currently support that, so we have an option to disable. -if [ "$NO_LLVM_ASSERTIONS" = "" ]; then - RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions" -fi - # If we're deploying artifacts then we set the release channel, otherwise if # we're not deploying then we want to be sure to enable all assertions becauase # we'll be running tests @@ -47,6 +34,14 @@ if [ "$DEPLOY" != "" ]; then if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" fi +else + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-debug-assertions" + + # In general we always want to run tests with LLVM assertions enabled, but not + # all platforms currently support that, so we have an option to disable. + if [ "$NO_LLVM_ASSERTIONS" = "" ]; then + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions" + fi fi # We want to enable usage of the `src/vendor` dir as much as possible, but not @@ -63,7 +58,7 @@ $SRC/configure $RUST_CONFIGURE_ARGS if [ "$TRAVIS_OS_NAME" = "osx" ]; then ncpus=$(sysctl -n hw.ncpu) else - ncpus=$(nproc) + ncpus=$(grep processor /proc/cpuinfo | wc -l) fi if [ ! -z "$SCRIPT" ]; then From b9765c085faf0b350ce9056856a0a7e188cc4ea9 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Thu, 19 Jan 2017 11:32:55 -0500 Subject: [PATCH 33/37] trans: Exit earlier from base::trans_crate() when compiling rmeta crates. --- src/librustc_trans/back/write.rs | 5 +++-- src/librustc_trans/base.rs | 33 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index dac1e3b8dc1ce..e4d22b76a75a4 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -667,7 +667,8 @@ pub fn run_passes(sess: &Session, // Sanity check assert!(trans.modules.len() == sess.opts.cg.codegen_units || - sess.opts.debugging_opts.incremental.is_some()); + sess.opts.debugging_opts.incremental.is_some() || + !sess.opts.output_types.should_trans()); let tm = create_target_machine(sess); @@ -756,7 +757,7 @@ pub fn run_passes(sess: &Session, // the compiler decides the number of codegen units (and will // potentially create hundreds of them). let num_workers = work_items.len() - 1; - if num_workers == 1 { + if num_workers <= 1 { run_work_singlethreaded(sess, &trans.exported_symbols, work_items); } else { run_work_multithreaded(sess, work_items, num_workers); diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 4cdde24ed48b5..d006dccbccc58 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -1145,6 +1145,23 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; let no_builtins = attr::contains_name(&krate.attrs, "no_builtins"); + // Skip crate items and just output metadata in -Z no-trans mode. + if tcx.sess.opts.debugging_opts.no_trans || + !tcx.sess.opts.output_types.should_trans() { + let empty_exported_symbols = ExportedSymbols::empty(); + let linker_info = LinkerInfo::new(&shared_ccx, &empty_exported_symbols); + return CrateTranslation { + modules: vec![], + metadata_module: metadata_module, + link: link_meta, + metadata: metadata, + exported_symbols: empty_exported_symbols, + no_builtins: no_builtins, + linker_info: linker_info, + windows_subsystem: None, + }; + } + // Run the translation item collector and partition the collected items into // codegen units. let (codegen_units, symbol_map) = collect_and_partition_translation_items(&shared_ccx); @@ -1181,22 +1198,6 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, assert_module_sources::assert_module_sources(tcx, &modules); - // Skip crate items and just output metadata in -Z no-trans mode. - if tcx.sess.opts.debugging_opts.no_trans || - tcx.sess.opts.output_types.contains_key(&config::OutputType::Metadata) { - let linker_info = LinkerInfo::new(&shared_ccx, &ExportedSymbols::empty()); - return CrateTranslation { - modules: modules, - metadata_module: metadata_module, - link: link_meta, - metadata: metadata, - exported_symbols: ExportedSymbols::empty(), - no_builtins: no_builtins, - linker_info: linker_info, - windows_subsystem: None, - }; - } - // Instantiate translation items without filling out definitions yet... for ccx in crate_context_list.iter_need_trans() { let cgu = ccx.codegen_unit(); From 2c9c70f17b7c3ba08c3cb876a423dac76cf4c7ed Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Fri, 20 Jan 2017 01:05:54 +0200 Subject: [PATCH 34/37] Deny extra_requirement_in_impl forward-compat lint Part of #37166 --- src/librustc/lint/builtin.rs | 2 +- src/test/compile-fail/issue-18937.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 96fb168581b21..b0db3b75029fb 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -206,7 +206,7 @@ declare_lint! { declare_lint! { pub EXTRA_REQUIREMENT_IN_IMPL, - Warn, + Deny, "detects extra requirements in impls that were erroneously allowed" } diff --git a/src/test/compile-fail/issue-18937.rs b/src/test/compile-fail/issue-18937.rs index 8ac66bb44d20a..f57f3477a8a86 100644 --- a/src/test/compile-fail/issue-18937.rs +++ b/src/test/compile-fail/issue-18937.rs @@ -10,8 +10,6 @@ // Regression test for #18937. -#![deny(extra_requirement_in_impl)] - use std::fmt; #[derive(Debug)] From a7274e7a687d8a032ea130b125b245f1df4e0463 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Thu, 19 Jan 2017 18:22:46 -0500 Subject: [PATCH 35/37] Add regression test for issue #38942 --- src/test/run-pass/issue-38942.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/run-pass/issue-38942.rs diff --git a/src/test/run-pass/issue-38942.rs b/src/test/run-pass/issue-38942.rs new file mode 100644 index 0000000000000..9c1c999d090ef --- /dev/null +++ b/src/test/run-pass/issue-38942.rs @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// See https://github.com/rust-lang/rust/issues/38942 + +#[repr(u64)] +pub enum NSEventType { + NSEventTypePressure, +} + +pub const A: u64 = NSEventType::NSEventTypePressure as u64; + +fn banana() -> u64 { + A +} + +fn main() { + println!("banana! {}", banana()); +} From 1f342a68cc95e48d3b6b56970c15ddc2fe0d9ea1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 19 Jan 2017 16:38:38 -0800 Subject: [PATCH 36/37] Test fixes from the rollup --- .../coherence-overlapping-inherent-impl-trait.rs | 1 + src/test/compile-fail/feature-gate-dropck-ugeh.rs | 1 + src/test/ui/compare-method/proj-outlives-region.stderr | 7 +------ src/test/ui/compare-method/region-unrelated.stderr | 7 +------ 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/test/compile-fail/coherence-overlapping-inherent-impl-trait.rs b/src/test/compile-fail/coherence-overlapping-inherent-impl-trait.rs index a611b22e93de8..08e8605e91773 100644 --- a/src/test/compile-fail/coherence-overlapping-inherent-impl-trait.rs +++ b/src/test/compile-fail/coherence-overlapping-inherent-impl-trait.rs @@ -13,5 +13,6 @@ trait C {} impl C { fn f() {} } //~ ERROR duplicate definitions with name `f` +//~^ WARN: this was previously accepted impl C { fn f() {} } fn main() { } diff --git a/src/test/compile-fail/feature-gate-dropck-ugeh.rs b/src/test/compile-fail/feature-gate-dropck-ugeh.rs index 360895d30b0b7..d9664fda2b339 100644 --- a/src/test/compile-fail/feature-gate-dropck-ugeh.rs +++ b/src/test/compile-fail/feature-gate-dropck-ugeh.rs @@ -28,6 +28,7 @@ struct Foo { data: Vec } impl Drop for Foo { #[unsafe_destructor_blind_to_params] // This is the UGEH attribute //~^ ERROR unsafe_destructor_blind_to_params has been replaced + //~^^ WARN: use of deprecated attribute fn drop(&mut self) { } } diff --git a/src/test/ui/compare-method/proj-outlives-region.stderr b/src/test/ui/compare-method/proj-outlives-region.stderr index 79293e0deed60..021b571fe793c 100644 --- a/src/test/ui/compare-method/proj-outlives-region.stderr +++ b/src/test/ui/compare-method/proj-outlives-region.stderr @@ -1,4 +1,4 @@ -error[E0276]: impl has stricter requirements than trait +error[E0276]: impl has stricter requirements than trait, #[deny(extra_requirement_in_impl)] on by default --> $DIR/proj-outlives-region.rs:22:5 | 17 | fn foo() where T: 'a; @@ -9,11 +9,6 @@ error[E0276]: impl has stricter requirements than trait | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #37166 -note: lint level defined here - --> $DIR/proj-outlives-region.rs:12:9 - | -12 | #![deny(extra_requirement_in_impl)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/compare-method/region-unrelated.stderr b/src/test/ui/compare-method/region-unrelated.stderr index b7cfdf799bc9d..4df337c525743 100644 --- a/src/test/ui/compare-method/region-unrelated.stderr +++ b/src/test/ui/compare-method/region-unrelated.stderr @@ -1,4 +1,4 @@ -error[E0276]: impl has stricter requirements than trait +error[E0276]: impl has stricter requirements than trait, #[deny(extra_requirement_in_impl)] on by default --> $DIR/region-unrelated.rs:22:5 | 17 | fn foo() where T: 'a; @@ -9,11 +9,6 @@ error[E0276]: impl has stricter requirements than trait | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #37166 -note: lint level defined here - --> $DIR/region-unrelated.rs:12:9 - | -12 | #![deny(extra_requirement_in_impl)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error From 72c3148bb34fe7365d33f78bd732385ab091f3cb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 19 Jan 2017 17:18:12 -0800 Subject: [PATCH 37/37] More test fixes from rollup --- .travis.yml | 2 + appveyor.yml | 3 ++ src/bootstrap/compile.rs | 6 ++- src/ci/docker/cross/build-arm-musl.sh | 38 +++++++++++----- src/ci/docker/cross/build-rumprun.sh | 1 - src/ci/docker/dist-arm-linux/Dockerfile | 18 +------- .../docker/dist-arm-linux/build-toolchains.sh | 45 +++++++++++++++++++ .../dist-armv7-aarch64-linux/Dockerfile | 17 +------ .../build-toolchains.sh | 45 +++++++++++++++++++ src/ci/docker/emscripten/build-emscripten.sh | 23 ++++++++-- src/ci/docker/linux-tested-targets/Dockerfile | 2 +- src/librustc_trans/back/write.rs | 3 +- src/test/run-pass/sse2.rs | 12 +++-- 13 files changed, 162 insertions(+), 53 deletions(-) create mode 100755 src/ci/docker/dist-arm-linux/build-toolchains.sh create mode 100755 src/ci/docker/dist-armv7-aarch64-linux/build-toolchains.sh diff --git a/.travis.yml b/.travis.yml index 19d5b2d7e058e..0546f6827a6f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ git: submodules: false matrix: + fast_finish: true include: # Linux builders, all docker images - env: IMAGE=android DEPLOY=1 @@ -23,6 +24,7 @@ matrix: - env: IMAGE=dist-powerpc64-linux DEPLOY=1 - env: IMAGE=dist-s390x-linux-netbsd DEPLOY=1 - env: IMAGE=dist-x86-linux DEPLOY=1 + - env: IMAGE=emscripten - env: IMAGE=i686-gnu - env: IMAGE=i686-gnu-nopt - env: IMAGE=x86_64-gnu diff --git a/appveyor.yml b/appveyor.yml index 56ab8d98abd72..b0eb26474548e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -73,6 +73,9 @@ environment: MINGW_DIR: mingw64 DEPLOY: 1 +matrix: + fast_finish: true + clone_depth: 1 build: false diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 0eeb799672cf2..079f93e7331f1 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -213,7 +213,11 @@ pub fn rustc(build: &Build, target: &str, compiler: &Compiler) { if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { cargo.env("CFG_LLVM_ROOT", s); } - if build.config.llvm_static_stdcpp { + // Building with a static libstdc++ is only supported on linux right now, + // not for MSVC or OSX + if build.config.llvm_static_stdcpp && + !target.contains("windows") && + !target.contains("apple") { cargo.env("LLVM_STATIC_STDCPP", compiler_file(build.cxx(target), "libstdc++.a")); } diff --git a/src/ci/docker/cross/build-arm-musl.sh b/src/ci/docker/cross/build-arm-musl.sh index 989862b1b73b9..938e69834e434 100755 --- a/src/ci/docker/cross/build-arm-musl.sh +++ b/src/ci/docker/cross/build-arm-musl.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copyright 2017 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. @@ -13,16 +13,33 @@ set -ex MUSL=1.1.16 +hide_output() { + set +x + on_err=" +echo ERROR: An error was encountered with the build. +cat /tmp/build.log +exit 1 +" + trap "$on_err" ERR + bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & + PING_LOOP_PID=$! + $@ &> /tmp/build.log + trap - ERR + kill $PING_LOOP_PID + rm /tmp/build.log + set -x +} + curl -O https://www.musl-libc.org/releases/musl-$MUSL.tar.gz tar xf musl-$MUSL.tar.gz cd musl-$MUSL CC=arm-linux-gnueabi-gcc \ CFLAGS="-march=armv6 -marm" \ - ./configure \ + hide_output ./configure \ --prefix=/usr/local/arm-linux-musleabi \ --enable-wrapper=gcc -make -j$(nproc) -make install +hide_output make -j$(nproc) +hide_output make install cd .. rm -rf musl-$MUSL @@ -30,11 +47,11 @@ tar xf musl-$MUSL.tar.gz cd musl-$MUSL CC=arm-linux-gnueabihf-gcc \ CFLAGS="-march=armv6 -marm" \ - ./configure \ + hide_output ./configure \ --prefix=/usr/local/arm-linux-musleabihf \ --enable-wrapper=gcc -make -j$(nproc) -make install +hide_output make -j$(nproc) +hide_output make install cd .. rm -rf musl-$MUSL @@ -42,11 +59,11 @@ tar xf musl-$MUSL.tar.gz cd musl-$MUSL CC=arm-linux-gnueabihf-gcc \ CFLAGS="-march=armv7-a" \ - ./configure \ + hide_output ./configure \ --prefix=/usr/local/armv7-linux-musleabihf \ --enable-wrapper=gcc -make -j$(nproc) -make install +hide_output make -j$(nproc) +hide_output make install cd .. rm -rf musl-$MUSL* @@ -54,7 +71,6 @@ ln -nsf ../arm-linux-musleabi/bin/musl-gcc /usr/local/bin/arm-linux-musleabi-gcc ln -nsf ../arm-linux-musleabihf/bin/musl-gcc /usr/local/bin/arm-linux-musleabihf-gcc ln -nsf ../armv7-linux-musleabihf/bin/musl-gcc /usr/local/bin/armv7-linux-musleabihf-gcc - curl -L https://github.com/llvm-mirror/llvm/archive/release_39.tar.gz | tar xzf - curl -L https://github.com/llvm-mirror/libunwind/archive/release_39.tar.gz | tar xzf - diff --git a/src/ci/docker/cross/build-rumprun.sh b/src/ci/docker/cross/build-rumprun.sh index d0ef0e55db158..59b1c9b641535 100755 --- a/src/ci/docker/cross/build-rumprun.sh +++ b/src/ci/docker/cross/build-rumprun.sh @@ -28,7 +28,6 @@ exit 1 set -x } - git clone https://github.com/rumpkernel/rumprun cd rumprun git reset --hard 39a97f37a85e44c69b662f6b97b688fbe892603b diff --git a/src/ci/docker/dist-arm-linux/Dockerfile b/src/ci/docker/dist-arm-linux/Dockerfile index 956969684b406..03ca4c28078b6 100644 --- a/src/ci/docker/dist-arm-linux/Dockerfile +++ b/src/ci/docker/dist-arm-linux/Dockerfile @@ -58,22 +58,8 @@ RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools USER rustbuild WORKDIR /tmp -COPY arm-linux-gnueabi.config /tmp/ -RUN mkdir build && \ - cd build && \ - cp ../arm-linux-gnueabi.config .config && \ - ct-ng oldconfig && \ - ct-ng build && \ - cd .. && \ - rm -rf build -COPY arm-linux-gnueabihf.config /tmp/ -RUN mkdir build && \ - cd build && \ - cp ../arm-linux-gnueabihf.config .config && \ - ct-ng oldconfig && \ - ct-ng build && \ - cd .. && \ - rm -rf build +COPY arm-linux-gnueabihf.config arm-linux-gnueabi.config build-toolchains.sh /tmp/ +RUN ./build-toolchains.sh USER root diff --git a/src/ci/docker/dist-arm-linux/build-toolchains.sh b/src/ci/docker/dist-arm-linux/build-toolchains.sh new file mode 100755 index 0000000000000..ed1406bd7cfa7 --- /dev/null +++ b/src/ci/docker/dist-arm-linux/build-toolchains.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +hide_output() { + set +x + on_err=" +echo ERROR: An error was encountered with the build. +cat /tmp/build.log +exit 1 +" + trap "$on_err" ERR + bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & + PING_LOOP_PID=$! + $@ &> /tmp/build.log + rm /tmp/build.log + trap - ERR + kill $PING_LOOP_PID + set -x +} + +mkdir build +cd build +cp ../arm-linux-gnueabi.config .config +ct-ng oldconfig +hide_output ct-ng build +cd .. +rm -rf build + +mkdir build +cd build +cp ../arm-linux-gnueabihf.config .config +ct-ng oldconfig +hide_output ct-ng build +cd .. +rm -rf build diff --git a/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile b/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile index 2070ed47eb7f6..93d9e004c8c2d 100644 --- a/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile +++ b/src/ci/docker/dist-armv7-aarch64-linux/Dockerfile @@ -59,21 +59,8 @@ USER rustbuild WORKDIR /tmp COPY armv7-linux-gnueabihf.config /tmp/ -RUN mkdir build && \ - cd build && \ - cp ../armv7-linux-gnueabihf.config .config && \ - ct-ng oldconfig && \ - ct-ng build && \ - cd .. && \ - rm -rf build -COPY aarch64-linux-gnu.config /tmp/ -RUN mkdir build && \ - cd build && \ - cp ../aarch64-linux-gnu.config .config && \ - ct-ng oldconfig && \ - ct-ng build && \ - cd .. && \ - rm -rf build +COPY armv7-linux-gnueabihf.config aarch64-linux-gnu.config build-toolchains.sh /tmp/ +RUN ./build-toolchains.sh USER root diff --git a/src/ci/docker/dist-armv7-aarch64-linux/build-toolchains.sh b/src/ci/docker/dist-armv7-aarch64-linux/build-toolchains.sh new file mode 100755 index 0000000000000..ebd5ef4cfc492 --- /dev/null +++ b/src/ci/docker/dist-armv7-aarch64-linux/build-toolchains.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +hide_output() { + set +x + on_err=" +echo ERROR: An error was encountered with the build. +cat /tmp/build.log +exit 1 +" + trap "$on_err" ERR + bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & + PING_LOOP_PID=$! + $@ &> /tmp/build.log + rm /tmp/build.log + trap - ERR + kill $PING_LOOP_PID + set -x +} + +mkdir build +cd build +cp ../armv7-linux-gnueabihf.config .config +ct-ng oldconfig +hide_output ct-ng build +cd .. +rm -rf build + +mkdir build +cd build +cp ../aarch64-linux-gnu.config .config +ct-ng oldconfig +hide_output ct-ng build +cd .. +rm -rf build diff --git a/src/ci/docker/emscripten/build-emscripten.sh b/src/ci/docker/emscripten/build-emscripten.sh index 2ce7a58ae6656..88bf583007ce5 100755 --- a/src/ci/docker/emscripten/build-emscripten.sh +++ b/src/ci/docker/emscripten/build-emscripten.sh @@ -11,9 +11,26 @@ set -ex +hide_output() { + set +x + on_err=" +echo ERROR: An error was encountered with the build. +cat /tmp/build.log +exit 1 +" + trap "$on_err" ERR + bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & + PING_LOOP_PID=$! + $@ &> /tmp/build.log + trap - ERR + kill $PING_LOOP_PID + rm /tmp/build.log + set -x +} + curl https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ tar xzf - source emsdk_portable/emsdk_env.sh -emsdk update -emsdk install --build=Release sdk-tag-1.37.1-32bit -emsdk activate --build=Release sdk-tag-1.37.1-32bit +hide_output emsdk update +hide_output emsdk install --build=Release sdk-tag-1.37.1-32bit +hide_output emsdk activate --build=Release sdk-tag-1.37.1-32bit diff --git a/src/ci/docker/linux-tested-targets/Dockerfile b/src/ci/docker/linux-tested-targets/Dockerfile index 2a43201ed0aeb..7f95e17c7097a 100644 --- a/src/ci/docker/linux-tested-targets/Dockerfile +++ b/src/ci/docker/linux-tested-targets/Dockerfile @@ -32,10 +32,10 @@ ENV RUST_CONFIGURE_ARGS \ --musl-root-x86_64=/musl-x86_64 \ --musl-root-i686=/musl-i686 +# FIXME should also test i686-unknown-linux-musl ENV SCRIPT \ python2.7 ../x.py test \ --target x86_64-unknown-linux-musl \ - --target i686-unknown-linux-musl \ --target i586-unknown-linux-gnu \ && \ python2.7 ../x.py dist \ diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 9e5391ebd8243..b3a2d66a07c11 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -668,7 +668,8 @@ pub fn run_passes(sess: &Session, // Sanity check assert!(trans.modules.len() == sess.opts.cg.codegen_units || sess.opts.debugging_opts.incremental.is_some() || - !sess.opts.output_types.should_trans()); + !sess.opts.output_types.should_trans() || + sess.opts.debugging_opts.no_trans); let tm = create_target_machine(sess); diff --git a/src/test/run-pass/sse2.rs b/src/test/run-pass/sse2.rs index 7e42698d49676..8d88c17af79b3 100644 --- a/src/test/run-pass/sse2.rs +++ b/src/test/run-pass/sse2.rs @@ -13,10 +13,14 @@ use std::env; fn main() { - // Skip this tests on i586-unknown-linux-gnu where sse2 is disabled - let real_target = env::var("TARGET").unwrap(); - if real_target.contains("i586") { - return + match env::var("TARGET") { + Ok(s) => { + // Skip this tests on i586-unknown-linux-gnu where sse2 is disabled + if s.contains("i586") { + return + } + } + Err(_) => return, } if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { assert!(cfg!(target_feature = "sse2"),