From 90d28ec372185f94529fd6c72cc17c9cf1e9f137 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 23 Feb 2016 23:00:48 -0800 Subject: [PATCH 01/14] rustbuild: Enable bootstrapping new hosts This commit fixes a longstanding issue with the makefiles where all host platforms bootstrap themselves. This commit alters the build logic for the bootstrap to instead only bootstrap the build triple, and all other compilers are compiled from that one compiler. The benefit of this change is that we can cross-compile compilers which cannot run on the build platform. For example our builders could start creating `arm-unknown-linux-gnueabihf` compilers. This reduces the amount of bootstrapping we do, reducing the amount of test coverage, but overall it should largely just end in faster build times for multi-host compiles as well as enabling a feature which can't be done today. cc #5258 --- src/bootstrap/build/step.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/build/step.rs b/src/bootstrap/build/step.rs index 2fbf1a6ad1db2..6c0c55fddeea3 100644 --- a/src/bootstrap/build/step.rs +++ b/src/bootstrap/build/step.rs @@ -151,15 +151,12 @@ impl<'a> Step<'a> { pub fn deps(&self, build: &'a Build) -> Vec> { match self.src { Source::Rustc { stage: 0 } => { - if self.target == build.config.build { - Vec::new() - } else { - let compiler = Compiler::new(0, &build.config.build); - vec![self.librustc(0, compiler)] - } + assert!(self.target == build.config.build); + Vec::new() } Source::Rustc { stage } => { - vec![self.librustc(stage - 1, self.compiler(stage - 1))] + let compiler = Compiler::new(stage - 1, &build.config.build); + vec![self.librustc(stage - 1, compiler)] } Source::Librustc { stage, compiler } => { vec![self.libstd(stage, compiler), self.llvm(())] From 93a3b294c78f9c28f31e31564bedcddfe9b3f831 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Feb 2016 14:16:54 -0800 Subject: [PATCH 02/14] rustbuild: Only pass RUSTC_FLAGS to target compiles These flags aren't applicable to build scripts, and may actuall wreak havoc. --- src/bootstrap/rustc.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/rustc.rs b/src/bootstrap/rustc.rs index 0c30360ba79f0..4e9d6da9157de 100644 --- a/src/bootstrap/rustc.rs +++ b/src/bootstrap/rustc.rs @@ -61,6 +61,9 @@ fn main() { root.push("/lib"); cmd.arg("-L").arg(&root); } + if let Ok(s) = env::var("RUSTC_FLAGS") { + cmd.args(&s.split(" ").filter(|s| !s.is_empty()).collect::>()); + } } // Set various options from config.toml to configure how we're building @@ -79,9 +82,6 @@ fn main() { if let Ok(s) = env::var("RUSTC_CODEGEN_UNITS") { cmd.arg("-C").arg(format!("codegen-units={}", s)); } - if let Ok(s) = env::var("RUSTC_FLAGS") { - cmd.args(&s.split(" ").filter(|s| !s.is_empty()).collect::>()); - } // Actually run the compiler! std::process::exit(match cmd.status() { From 52ec682776cbf66fee16609405eb03d672eb52c2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Feb 2016 14:17:21 -0800 Subject: [PATCH 03/14] rustbuild: Sync changes to Cargo.lock --- src/rustc/std_shim/Cargo.lock | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/rustc/std_shim/Cargo.lock b/src/rustc/std_shim/Cargo.lock index 3d5f2c803e61e..530c04da8a0c9 100644 --- a/src/rustc/std_shim/Cargo.lock +++ b/src/rustc/std_shim/Cargo.lock @@ -18,9 +18,7 @@ dependencies = [ name = "alloc" version = "0.0.0" dependencies = [ - "alloc_system 0.0.0", "core 0.0.0", - "libc 0.0.0", ] [[package]] From a707a61caed22687b0a2ea9a4eea855109eafb26 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Feb 2016 14:31:18 -0800 Subject: [PATCH 04/14] rustbuild: Fix compiler-rt build on gnueabihf Needs a different target to get built and also we apparently need to appease the C++ compiler somehow. --- src/bootstrap/build/native.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bootstrap/build/native.rs b/src/bootstrap/build/native.rs index 6ad5f40412394..a9d84b60fbff8 100644 --- a/src/bootstrap/build/native.rs +++ b/src/bootstrap/build/native.rs @@ -115,6 +115,11 @@ pub fn compiler_rt(build: &Build, target: &str) { let mode = if build.config.rust_optimize {"Release"} else {"Debug"}; let (dir, build_target, libname) = if target.contains("linux") { let os = if target.contains("android") {"-android"} else {""}; + let arch = if arch.starts_with("arm") && target.contains("eabihf") { + "armhf" + } else { + arch + }; let target = format!("clang_rt.builtins-{}{}", arch, os); ("linux".to_string(), target.clone(), target) } else if target.contains("darwin") { @@ -151,7 +156,10 @@ pub fn compiler_rt(build: &Build, target: &str) { .define("COMPILER_RT_DEFAULT_TARGET_TRIPLE", target) .define("COMPILER_RT_BUILD_SANITIZERS", "OFF") .define("COMPILER_RT_BUILD_EMUTLS", "OFF") + // inform about c/c++ compilers, the c++ compiler isn't actually used but + // it's needed to get the initial configure to work on all platforms. .define("CMAKE_C_COMPILER", build.cc(target)) + .define("CMAKE_CXX_COMPILER", build.cc(target)) .build_target(&build_target); cfg.build(); } From 526640668d1d7469e0c767452bb5ac60c3fa0043 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Feb 2016 17:09:17 -0800 Subject: [PATCH 05/14] rustbuild: Enable cross-compiling LLVM Currently all multi-host builds assume the the build platform can run the `llvm-config` binary generated for each host platform we're creating a compiler for. Unfortunately this assumption isn't always true when cross compiling, so we need to handle this case. This commit alters the build script of `rustc_llvm` to understand when it's running an `llvm-config` which is different than the platform we're targeting for. --- src/bootstrap/build/compile.rs | 11 +++++--- src/librustc_llvm/build.rs | 46 +++++++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/build/compile.rs b/src/bootstrap/build/compile.rs index c22648b471098..cb7cf9bd9afbf 100644 --- a/src/bootstrap/build/compile.rs +++ b/src/bootstrap/build/compile.rs @@ -131,10 +131,13 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str, if !build.unstable_features { cargo.env("CFG_DISABLE_UNSTABLE_FEATURES", "1"); } - if let Some(config) = build.config.target_config.get(target) { - if let Some(ref s) = config.llvm_config { - cargo.env("LLVM_CONFIG", s); - } + let target_config = build.config.target_config.get(target); + if let Some(ref s) = target_config.and_then(|c| c.llvm_config.as_ref()) { + cargo.env("LLVM_CONFIG", s); + } else { + let llvm_config = build.llvm_out(&build.config.build).join("bin") + .join(exe("llvm-config", target)); + cargo.env("LLVM_CONFIG", llvm_config); } if build.config.llvm_static_stdcpp { cargo.env("LLVM_STATIC_STDCPP", diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 1c9982790cf4a..59164161b3d5e 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -38,6 +38,25 @@ fn main() { println!("cargo:rerun-if-changed={}", llvm_config.display()); + // Test whether we're cross-compiling LLVM. This is a pretty rare case + // currently where we're producing an LLVM for a different platform than + // what this build script is currently running on. + // + // In that case, there's no guarantee that we can actually run the target, + // so the build system works around this by giving us the LLVM_CONFIG for + // the host platform. This only really works if the host LLVM and target + // LLVM are compiled the same way, but for us that's typically the case. + // + // We detect this cross compiling situation by asking llvm-config what it's + // host-target is. If that's not the TARGET, then we're cross compiling. + // This generally just means that we can't trust all the output of + // llvm-config becaues it might be targeted for the host rather than the + // target. + let target = env::var("TARGET").unwrap(); + let host = output(Command::new(&llvm_config).arg("--host-target")); + let host = host.trim(); + let is_crossed = target != host; + let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl"]; @@ -69,6 +88,10 @@ fn main() { let cxxflags = output(&mut cmd); let mut cfg = gcc::Config::new(); for flag in cxxflags.split_whitespace() { + // Ignore flags like `-m64` when we're doing a cross build + if is_crossed && flag.starts_with("-m") { + continue + } cfg.flag(flag); } cfg.file("../rustllvm/ExecutionEngineWrapper.cpp") @@ -79,9 +102,16 @@ fn main() { .cpp_link_stdlib(None) // we handle this below .compile("librustllvm.a"); - // Link in all LLVM libraries + // Link in all LLVM libraries, if we're uwring the "wrong" llvm-config then + // we don't pick up system libs because unfortunately they're for the host + // of llvm-config, not the target that we're attempting to link. let mut cmd = Command::new(&llvm_config); - cmd.arg("--libs").arg("--system-libs").args(&components[..]); + cmd.arg("--libs"); + if !is_crossed { + cmd.arg("--system-libs"); + } + cmd.args(&components[..]); + for lib in output(&mut cmd).split_whitespace() { let name = if lib.starts_with("-l") { &lib[2..] @@ -105,10 +135,20 @@ fn main() { } // LLVM ldflags + // + // If we're a cross-compile of LLVM then unfortunately we can't trust these + // ldflags (largely where all the LLVM libs are located). Currently just + // hack around this by replacing the host triple with the target and pray + // that those -L directories are the same! let mut cmd = Command::new(&llvm_config); cmd.arg("--ldflags"); for lib in output(&mut cmd).split_whitespace() { - if lib.starts_with("-l") { + if is_crossed { + if lib.starts_with("-L") { + println!("cargo:rustc-link-search=native={}", + lib[2..].replace(&host, &target)); + } + } else if lib.starts_with("-l") { println!("cargo:rustc-link-lib={}", &lib[2..]); } else if lib.starts_with("-L") { println!("cargo:rustc-link-search=native={}", &lib[2..]); From 189827bd960fbb6e2e4dad5114ee414af35bb84c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Feb 2016 17:13:23 -0800 Subject: [PATCH 06/14] rustbuild: Fix a copy/paste error Fixes `--step librustc` --- src/bootstrap/build/step.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/build/step.rs b/src/bootstrap/build/step.rs index 6c0c55fddeea3..d97bc064c9848 100644 --- a/src/bootstrap/build/step.rs +++ b/src/bootstrap/build/step.rs @@ -117,7 +117,7 @@ fn add_steps<'a>(build: &'a Build, let compiler = host.compiler(stage); match &step[..] { "libstd" => targets.push(target.libstd(stage, compiler)), - "librustc" => targets.push(target.libstd(stage, compiler)), + "librustc" => targets.push(target.librustc(stage, compiler)), "rustc" => targets.push(host.rustc(stage)), "llvm" => targets.push(target.llvm(())), "compiler-rt" => targets.push(target.compiler_rt(())), From ed3d46d278a324b6d2c8740a965224b6d4075c11 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Feb 2016 19:03:48 -0800 Subject: [PATCH 07/14] rustbuild: Move assembling rustc to its own step Right now it's implicitly done as part of building the compiler, but this was intended to be a standalone step to ensure we tracked what built what. --- src/bootstrap/build/compile.rs | 32 +++++++++++++++----------------- src/bootstrap/build/mod.rs | 6 +++++- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/bootstrap/build/compile.rs b/src/bootstrap/build/compile.rs index cb7cf9bd9afbf..dc547f74db19b 100644 --- a/src/bootstrap/build/compile.rs +++ b/src/bootstrap/build/compile.rs @@ -99,7 +99,6 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str, host, target); let out_dir = build.cargo_out(stage, &host, false, target); - let rustc = out_dir.join(exe("rustc", target)); build.clear_if_dirty(&out_dir, &libstd_shim(build, stage, &host, target)); let mut cargo = build.cargo(stage, compiler, false, target, "build"); @@ -153,10 +152,6 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str, let sysroot_libdir = build.sysroot_libdir(stage, host, target); add_to_sysroot(&out_dir, &sysroot_libdir); - - if host == target { - assemble_compiler(build, stage, target, &rustc); - } } /// Cargo's output path for the standard library in a given stage, compiled @@ -172,21 +167,21 @@ fn compiler_file(compiler: &Path, file: &str) -> String { /// Prepare a new compiler from the artifacts in `stage` /// -/// This will link the compiler built by `host` during the stage -/// specified to the sysroot location for `host` to be the official -/// `stage + 1` compiler for that host. This means that the `rustc` binary -/// itself will be linked into place along with all supporting dynamic -/// libraries. -fn assemble_compiler(build: &Build, stage: u32, host: &str, rustc: &Path) { +/// This will assemble a compiler in `build/$host/stage$stage`. The compiler +/// must have been previously produced by the `stage - 1` build.config.build +/// compiler. +pub fn assemble_rustc(build: &Build, stage: u32, host: &str) { + assert!(stage > 0, "the stage0 compiler isn't assembled, it's downloaded"); + // Clear out old files - let sysroot = build.sysroot(stage + 1, host); + let sysroot = build.sysroot(stage, host); let _ = fs::remove_dir_all(&sysroot); t!(fs::create_dir_all(&sysroot)); // Link in all dylibs to the libdir let sysroot_libdir = sysroot.join(libdir(host)); t!(fs::create_dir_all(&sysroot_libdir)); - let src_libdir = build.sysroot_libdir(stage, host, host); + let src_libdir = build.sysroot_libdir(stage - 1, &build.config.build, host); for f in t!(fs::read_dir(&src_libdir)).map(|f| t!(f)) { let filename = f.file_name().into_string().unwrap(); if is_dylib(&filename) { @@ -194,17 +189,20 @@ fn assemble_compiler(build: &Build, stage: u32, host: &str, rustc: &Path) { } } + let out_dir = build.cargo_out(stage - 1, &build.config.build, false, host); + // Link the compiler binary itself into place + let rustc = out_dir.join(exe("rustc", host)); let bindir = sysroot.join("bin"); t!(fs::create_dir_all(&bindir)); - let compiler = build.compiler_path(&Compiler::new(stage + 1, host)); + let compiler = build.compiler_path(&Compiler::new(stage, host)); let _ = fs::remove_file(&compiler); t!(fs::hard_link(rustc, compiler)); // See if rustdoc exists to link it into place - let exe = exe("rustdoc", host); - let rustdoc_src = rustc.parent().unwrap().join(&exe); - let rustdoc_dst = bindir.join(exe); + let rustdoc = exe("rustdoc", host); + let rustdoc_src = out_dir.join(&rustdoc); + let rustdoc_dst = bindir.join(&rustdoc); if fs::metadata(&rustdoc_src).is_ok() { let _ = fs::remove_file(&rustdoc_dst); t!(fs::hard_link(&rustdoc_src, &rustdoc_dst)); diff --git a/src/bootstrap/build/mod.rs b/src/bootstrap/build/mod.rs index 339f91f14a24e..88ec6b72eddad 100644 --- a/src/bootstrap/build/mod.rs +++ b/src/bootstrap/build/mod.rs @@ -146,8 +146,12 @@ impl Build { Librustc { stage, compiler } => { compile::rustc(self, stage, target.target, &compiler); } + Rustc { stage: 0 } => { + assert!(target.target == self.config.build, + "only have one stage0 compiler"); + } Rustc { stage } => { - println!("ok, rustc stage{} in {}", stage, target.target); + compile::assemble_rustc(self, stage, target.target); } } } From 5abcc78ff8baf881a8e87c3fe6f188333bf0eda1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Feb 2016 19:04:35 -0800 Subject: [PATCH 08/14] rustbuild: Compile with the build compiler This switches the defaults to ensure that everything is built with the build compiler rather than the host compiler itself (which we're not guaranteed to be able to run) --- src/bootstrap/build/step.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/build/step.rs b/src/bootstrap/build/step.rs index d97bc064c9848..acbfdca0b6d77 100644 --- a/src/bootstrap/build/step.rs +++ b/src/bootstrap/build/step.rs @@ -93,13 +93,13 @@ fn top_level(build: &Build) -> Vec { continue } let host = t.target(host); - targets.push(host.librustc(stage, host.compiler(stage))); + targets.push(host.librustc(stage, t.compiler(stage))); for target in build.config.target.iter() { if !build.flags.target.contains(target) { continue } targets.push(host.target(target) - .libstd(stage, host.compiler(stage))); + .libstd(stage, t.compiler(stage))); } } } From 06773878f325e3ad180afe7abcb50e5a8bb411b9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Feb 2016 21:12:42 -0800 Subject: [PATCH 09/14] rustbuild: Document what steps are --- src/bootstrap/build/step.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/bootstrap/build/step.rs b/src/bootstrap/build/step.rs index acbfdca0b6d77..f09a6ffbbf1ca 100644 --- a/src/bootstrap/build/step.rs +++ b/src/bootstrap/build/step.rs @@ -21,9 +21,23 @@ pub struct Step<'a> { macro_rules! targets { ($m:ident) => { $m! { + // Step representing building the stageN compiler. This is just the + // compiler executable itself, not any of the support libraries (rustc, Rustc { stage: u32 }), + + // Steps for the two main cargo builds, one for the standard library + // and one for the compiler itself. These are parameterized over the + // stage output they're going to be placed in along with the + // compiler which is producing the copy of libstd or librustc (libstd, Libstd { stage: u32, compiler: Compiler<'a> }), (librustc, Librustc { stage: u32, compiler: Compiler<'a> }), + + // Steps for long-running native builds. Ideally these wouldn't + // actually exist and would be part of build scripts, but for now + // these are here. + // + // There aren't really any parameters to this, but empty structs + // with braces are unstable so we just pick something that works. (llvm, Llvm { _dummy: () }), (compiler_rt, CompilerRt { _dummy: () }), } From e9a897c10f1636fca5c99bdbf12d02ea7ffd6e4c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Feb 2016 23:50:32 -0800 Subject: [PATCH 10/14] rustbuild: Add steps for linking a sysroot When cross compiling for a new host, we can't actually run the host compiler to generate its own libs. In theory, however, all stage2 compilers (for any host) will produce the same libraries, so we just require the build compiler to produce the necessary host libraries and then we link those into place. --- src/bootstrap/build/compile.rs | 41 +++++++++++++++++++++++++++++-- src/bootstrap/build/mod.rs | 8 ++++++ src/bootstrap/build/step.rs | 45 +++++++++++++++++++++++++++++++--- 3 files changed, 88 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/build/compile.rs b/src/bootstrap/build/compile.rs index dc547f74db19b..3be4199352ca1 100644 --- a/src/bootstrap/build/compile.rs +++ b/src/bootstrap/build/compile.rs @@ -58,6 +58,30 @@ pub fn std<'a>(build: &'a Build, stage: u32, target: &str, } build.run(&mut cargo); + std_link(build, stage, target, compiler, host); +} + +/// Link all libstd rlibs/dylibs into the sysroot location. +/// +/// Links those artifacts generated in the given `stage` for `target` produced +/// by `compiler` into `host`'s sysroot. +pub fn std_link(build: &Build, + stage: u32, + target: &str, + compiler: &Compiler, + host: &str) { + let libdir = build.sysroot_libdir(stage, host, target); + let out_dir = build.cargo_out(stage, compiler.host, true, target); + + // If we're linking one compiler host's output into another, then we weren't + // called from the `std` method above. In that case we clean out what's + // already there and then also link compiler-rt into place. + if host != compiler.host { + let _ = fs::remove_dir_all(&libdir); + t!(fs::create_dir_all(&libdir)); + t!(fs::hard_link(&build.compiler_rt_built.borrow()[target], + libdir.join(staticlib("compiler-rt", target)))); + } add_to_sysroot(&out_dir, &libdir); } @@ -150,8 +174,21 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str, } build.run(&mut cargo); - let sysroot_libdir = build.sysroot_libdir(stage, host, target); - add_to_sysroot(&out_dir, &sysroot_libdir); + rustc_link(build, stage, target, compiler, compiler.host); +} + +/// Link all librustc rlibs/dylibs into the sysroot location. +/// +/// Links those artifacts generated in the given `stage` for `target` produced +/// by `compiler` into `host`'s sysroot. +pub fn rustc_link(build: &Build, + stage: u32, + target: &str, + compiler: &Compiler, + host: &str) { + let libdir = build.sysroot_libdir(stage, host, target); + let out_dir = build.cargo_out(stage, compiler.host, false, target); + add_to_sysroot(&out_dir, &libdir); } /// Cargo's output path for the standard library in a given stage, compiled diff --git a/src/bootstrap/build/mod.rs b/src/bootstrap/build/mod.rs index 88ec6b72eddad..4a77aeb97861f 100644 --- a/src/bootstrap/build/mod.rs +++ b/src/bootstrap/build/mod.rs @@ -146,6 +146,14 @@ impl Build { Librustc { stage, compiler } => { compile::rustc(self, stage, target.target, &compiler); } + LibstdLink { stage, compiler, host } => { + compile::std_link(self, stage, target.target, + &compiler, host); + } + LibrustcLink { stage, compiler, host } => { + compile::rustc_link(self, stage, target.target, + &compiler, host); + } Rustc { stage: 0 } => { assert!(target.target == self.config.build, "only have one stage0 compiler"); diff --git a/src/bootstrap/build/step.rs b/src/bootstrap/build/step.rs index f09a6ffbbf1ca..49d418580a0b4 100644 --- a/src/bootstrap/build/step.rs +++ b/src/bootstrap/build/step.rs @@ -32,6 +32,19 @@ macro_rules! targets { (libstd, Libstd { stage: u32, compiler: Compiler<'a> }), (librustc, Librustc { stage: u32, compiler: Compiler<'a> }), + // Links the standard library/librustc produced by the compiler + // provided into the host's directory also provided. + (libstd_link, LibstdLink { + stage: u32, + compiler: Compiler<'a>, + host: &'a str + }), + (librustc_link, LibrustcLink { + stage: u32, + compiler: Compiler<'a>, + host: &'a str + }), + // Steps for long-running native builds. Ideally these wouldn't // actually exist and would be part of build scripts, but for now // these are here. @@ -107,13 +120,25 @@ fn top_level(build: &Build) -> Vec { continue } let host = t.target(host); - targets.push(host.librustc(stage, t.compiler(stage))); + if host.target == build.config.build { + targets.push(host.librustc(stage, host.compiler(stage))); + } else { + targets.push(host.librustc_link(stage, t.compiler(stage), + host.target)); + } for target in build.config.target.iter() { if !build.flags.target.contains(target) { continue } - targets.push(host.target(target) - .libstd(stage, t.compiler(stage))); + + if host.target == build.config.build { + targets.push(host.target(target) + .libstd(stage, host.compiler(stage))); + } else { + targets.push(host.target(target) + .libstd_link(stage, t.compiler(stage), + host.target)); + } } } } @@ -128,10 +153,14 @@ fn add_steps<'a>(build: &'a Build, target: &Step<'a>, targets: &mut Vec>) { for step in build.flags.step.iter() { - let compiler = host.compiler(stage); + let compiler = host.target(&build.config.build).compiler(stage); match &step[..] { "libstd" => targets.push(target.libstd(stage, compiler)), "librustc" => targets.push(target.librustc(stage, compiler)), + "libstd-link" => targets.push(target.libstd_link(stage, compiler, + host.target)), + "librustc-link" => targets.push(target.librustc_link(stage, compiler, + host.target)), "rustc" => targets.push(host.rustc(stage)), "llvm" => targets.push(target.llvm(())), "compiler-rt" => targets.push(target.compiler_rt(())), @@ -179,6 +208,14 @@ impl<'a> Step<'a> { vec![self.compiler_rt(()), self.rustc(compiler.stage).target(compiler.host)] } + Source::LibrustcLink { stage, compiler, host } => { + vec![self.librustc(stage, compiler), + self.libstd_link(stage, compiler, host)] + } + Source::LibstdLink { stage, compiler, host } => { + vec![self.libstd(stage, compiler), + self.target(host).rustc(stage)] + } Source::CompilerRt { _dummy } => { vec![self.llvm(()).target(&build.config.build)] } From 506522ff4b7d25da6623791f4d620e3b1457fbdf Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Feb 2016 23:51:36 -0800 Subject: [PATCH 11/14] rustbuild: Remove extra rustc flags These should all no longer be necessary as they've been folded into the compiler. --- src/bootstrap/build/mod.rs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/bootstrap/build/mod.rs b/src/bootstrap/build/mod.rs index 4a77aeb97861f..761a7cb4c48b8 100644 --- a/src/bootstrap/build/mod.rs +++ b/src/bootstrap/build/mod.rs @@ -437,21 +437,7 @@ impl Build { } fn rustc_flags(&self, target: &str) -> Vec { - let mut base = match target { - "arm-unknown-linux-gnueabihf" => { - vec!["-Ctarget-feature=+v6,+vfp2".to_string()] - } - "mips-unknown-linux-gnu" => { - vec!["-Ctarget-cpu=mips32r2".to_string(), - "-Ctarget-feature=+mips32r2".to_string(), - "-Csoft-float".to_string()] - } - "mipsel-unknown-linux-gnu" => { - vec!["-Ctarget-cpu=mips32".to_string(), - "-Ctarget-feature=+mips32".to_string()] - } - _ => Vec::new(), - }; + let mut base = Vec::new(); if target != self.config.build && !target.contains("msvc") { base.push(format!("-Clinker={}", self.cc(target).display())); } From 93a9ab1a1bb1e692516a07ece2ec6958c1aa0d3f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Feb 2016 00:01:22 -0800 Subject: [PATCH 12/14] rustbuild: Relax assertions about stage0 This allows bootstrapping new platforms immediately in stage0 --- src/bootstrap/build/mod.rs | 3 +-- src/bootstrap/build/step.rs | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/bootstrap/build/mod.rs b/src/bootstrap/build/mod.rs index 761a7cb4c48b8..ee4d7337dc1be 100644 --- a/src/bootstrap/build/mod.rs +++ b/src/bootstrap/build/mod.rs @@ -155,8 +155,7 @@ impl Build { &compiler, host); } Rustc { stage: 0 } => { - assert!(target.target == self.config.build, - "only have one stage0 compiler"); + // nothing to do... } Rustc { stage } => { compile::assemble_rustc(self, stage, target.target); diff --git a/src/bootstrap/build/step.rs b/src/bootstrap/build/step.rs index 49d418580a0b4..21c3c514698c6 100644 --- a/src/bootstrap/build/step.rs +++ b/src/bootstrap/build/step.rs @@ -194,7 +194,6 @@ impl<'a> Step<'a> { pub fn deps(&self, build: &'a Build) -> Vec> { match self.src { Source::Rustc { stage: 0 } => { - assert!(self.target == build.config.build); Vec::new() } Source::Rustc { stage } => { From 17ae752093dca428c6c0ba4eb23678b522f33b18 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Feb 2016 09:29:02 -0800 Subject: [PATCH 13/14] rustbuild: Update nightly date Also fix a bug where we didn't clean out previous nightlies --- src/bootstrap/bootstrap.py | 1 + src/bootstrap/build/mod.rs | 17 ++++++++++------- src/nightlies.txt | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 744c30aa08f07..6659894a171f0 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -73,6 +73,7 @@ def download_rust_nightly(self): if self.rustc().startswith(self.bin_root()) and \ (not os.path.exists(self.rustc()) or self.rustc_out_of_date()): + shutil.rmtree(self.bin_root()) filename = "rust-std-nightly-" + self.build + ".tar.gz" url = "https://static.rust-lang.org/dist/" + self.snap_rustc_date() tarball = os.path.join(rustc_cache, filename) diff --git a/src/bootstrap/build/mod.rs b/src/bootstrap/build/mod.rs index ee4d7337dc1be..7b3ac7d2f7e97 100644 --- a/src/bootstrap/build/mod.rs +++ b/src/bootstrap/build/mod.rs @@ -39,6 +39,14 @@ mod sanity; mod step; mod util; +#[cfg(windows)] +mod job; + +#[cfg(not(windows))] +mod job { + pub unsafe fn setup() {} +} + pub use build::config::Config; pub use build::flags::Flags; @@ -114,14 +122,9 @@ impl Build { pub fn build(&mut self) { use build::step::Source::*; - // see comments in job.rs for what's going on here - #[cfg(windows)] - fn setup_job() { - mod job; - unsafe { job::setup() } + unsafe { + job::setup(); } - #[cfg(not(windows))] fn setup_job() {} - setup_job(); if self.flags.clean { return clean::clean(self); diff --git a/src/nightlies.txt b/src/nightlies.txt index 86186222d90bb..59e2fce6f0938 100644 --- a/src/nightlies.txt +++ b/src/nightlies.txt @@ -1,2 +1,2 @@ -rustc: 2015-12-19 +rustc: 2016-02-17 cargo: 2016-01-21 From 15b4a8c2f32460b4b9b9ba27c17cbcf5144b14bb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Feb 2016 10:38:09 -0800 Subject: [PATCH 14/14] rustbuild: Update dependencies * Fixes a warning with libc * Brings in some new flag updates for various platforms through gcc-rs * Otherwise routine updates here/there --- src/bootstrap/Cargo.lock | 53 ++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index f9593eb1609d8..05186d48ce2d1 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -3,57 +3,42 @@ name = "bootstrap" version = "0.0.0" dependencies = [ "build_helper 0.1.0", - "cmake 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "filetime 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "advapi32-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "build_helper" version = "0.1.0" [[package]] name = "cmake" -version = "0.1.10" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "filetime" -version = "0.1.8" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gcc" -version = "0.3.19" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "getopts" @@ -71,30 +56,28 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.2" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num_cpus" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-serialize" -version = "0.3.16" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "toml" -version = "0.1.23" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]]