From 4e80235de6c9708df868edafffd5858b4cd7a898 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 8 Jun 2018 19:07:09 +0200 Subject: [PATCH 1/6] Introduce a function to reduce duplication --- src/bootstrap/compile.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 11d9154ba696c..c26dddd68bf6c 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -133,15 +133,19 @@ fn copy_musl_third_party_objects(builder: &Builder, } } +fn mac_os_deployment_env_var(cargo: &mut Command) { + if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") { + cargo.env("MACOSX_DEPLOYMENT_TARGET", target); + } +} + /// Configure cargo to compile the standard library, adding appropriate env vars /// and such. pub fn std_cargo(builder: &Builder, compiler: &Compiler, target: Interned, cargo: &mut Command) { - if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") { - cargo.env("MACOSX_DEPLOYMENT_TARGET", target); - } + mac_os_deployment_env_var(cargo); if builder.no_std(target) == Some(true) { // for no-std targets we only compile a few no_std crates @@ -394,9 +398,7 @@ pub fn test_cargo(builder: &Builder, _compiler: &Compiler, _target: Interned, cargo: &mut Command) { - if let Some(target) = env::var_os("MACOSX_STD_DEPLOYMENT_TARGET") { - cargo.env("MACOSX_DEPLOYMENT_TARGET", target); - } + mac_os_deployment_env_var(cargo); cargo.arg("--manifest-path") .arg(builder.src.join("src/libtest/Cargo.toml")); } From 027dfe97b2ac92486b1a64a0153310dcd9bf0dcf Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 8 Jun 2018 19:10:50 +0200 Subject: [PATCH 2/6] Build core crates before building std crates --- src/Cargo.lock | 37 ------ src/Cargo.toml | 3 + src/bootstrap/compile.rs | 172 +++++++++++++++++++--------- src/liballoc_jemalloc/Cargo.toml | 2 - src/liballoc_system/Cargo.toml | 2 - src/libpanic_abort/Cargo.toml | 2 - src/libpanic_unwind/Cargo.toml | 3 - src/libprofiler_builtins/Cargo.toml | 4 - src/librustc_asan/Cargo.toml | 3 - src/librustc_lsan/Cargo.toml | 3 - src/librustc_msan/Cargo.toml | 3 - src/librustc_tsan/Cargo.toml | 3 - src/libstd/Cargo.toml | 4 - src/libunwind/Cargo.toml | 2 - src/rustc/dlmalloc_shim/Cargo.toml | 4 - src/rustc/libc_shim/Cargo.toml | 22 ---- 16 files changed, 120 insertions(+), 149 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index d4544ffa3244f..52a1ff18cc47c 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -21,8 +21,6 @@ version = "0.0.0" dependencies = [ "build_helper 0.1.0", "cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.0.0", - "core 0.0.0", "libc 0.0.0", ] @@ -30,8 +28,6 @@ dependencies = [ name = "alloc_system" version = "0.0.0" dependencies = [ - "compiler_builtins 0.0.0", - "core 0.0.0", "dlmalloc 0.0.0", "libc 0.0.0", ] @@ -598,10 +594,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "dlmalloc" version = "0.0.0" -dependencies = [ - "compiler_builtins 0.0.0", - "core 0.0.0", -] [[package]] name = "dtoa" @@ -1060,10 +1052,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" version = "0.0.0" -dependencies = [ - "compiler_builtins 0.0.0", - "core 0.0.0", -] [[package]] name = "libc" @@ -1350,8 +1338,6 @@ dependencies = [ name = "panic_abort" version = "0.0.0" dependencies = [ - "compiler_builtins 0.0.0", - "core 0.0.0", "libc 0.0.0", ] @@ -1359,9 +1345,6 @@ dependencies = [ name = "panic_unwind" version = "0.0.0" dependencies = [ - "alloc 0.0.0", - "compiler_builtins 0.0.0", - "core 0.0.0", "libc 0.0.0", "unwind 0.0.0", ] @@ -1501,8 +1484,6 @@ name = "profiler_builtins" version = "0.0.0" dependencies = [ "cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.0.0", - "core 0.0.0", ] [[package]] @@ -2054,12 +2035,9 @@ dependencies = [ name = "rustc_asan" version = "0.0.0" dependencies = [ - "alloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", "cmake 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.0.0", - "core 0.0.0", ] [[package]] @@ -2235,12 +2213,9 @@ dependencies = [ name = "rustc_lsan" version = "0.0.0" dependencies = [ - "alloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", "cmake 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.0.0", - "core 0.0.0", ] [[package]] @@ -2286,12 +2261,9 @@ dependencies = [ name = "rustc_msan" version = "0.0.0" dependencies = [ - "alloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", "cmake 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.0.0", - "core 0.0.0", ] [[package]] @@ -2390,12 +2362,9 @@ dependencies = [ name = "rustc_tsan" version = "0.0.0" dependencies = [ - "alloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", "cmake 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.0.0", - "core 0.0.0", ] [[package]] @@ -2632,13 +2601,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "std" version = "0.0.0" dependencies = [ - "alloc 0.0.0", "alloc_jemalloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", "cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.0.0", - "core 0.0.0", "libc 0.0.0", "panic_abort 0.0.0", "panic_unwind 0.0.0", @@ -2648,7 +2614,6 @@ dependencies = [ "rustc_lsan 0.0.0", "rustc_msan 0.0.0", "rustc_tsan 0.0.0", - "std_unicode 0.0.0", "unwind 0.0.0", ] @@ -3037,8 +3002,6 @@ dependencies = [ name = "unwind" version = "0.0.0" dependencies = [ - "compiler_builtins 0.0.0", - "core 0.0.0", "libc 0.0.0", ] diff --git a/src/Cargo.toml b/src/Cargo.toml index 8ce4c97601bab..c43ff9c19a2ab 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -1,6 +1,9 @@ [workspace] members = [ "bootstrap", + "libcore", + "libstd_unicode", + "liballoc", "rustc", "libstd", "libtest", diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index c26dddd68bf6c..258c394a2f98f 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -100,22 +100,45 @@ impl Step for Std { let out_dir = builder.cargo_out(compiler, Mode::Std, target); builder.clear_if_dirty(&out_dir, &builder.rustc(compiler)); - let mut cargo = builder.cargo(compiler, Mode::Std, target, "build"); - std_cargo(builder, &compiler, target, &mut cargo); + let mut core_cargo_invoc = builder.cargo(compiler, Mode::Std, target, "build"); + core_cargo(builder, &compiler, target, &mut core_cargo_invoc); + let std_cargo_invoc = if builder.no_std(target) != Some(true) { + let mut std_cargo_invoc = builder.cargo(compiler, Mode::Std, target, "build"); + std_cargo(builder, &compiler, target, &mut std_cargo_invoc); + Some(std_cargo_invoc) + } else { + None + }; let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage)); builder.info(&format!("Building stage{} std artifacts ({} -> {})", compiler.stage, &compiler.host, target)); run_cargo(builder, - &mut cargo, + &mut core_cargo_invoc, &libstd_stamp(builder, compiler, target), false); - - builder.ensure(StdLink { + builder.ensure(CoreLink { compiler: builder.compiler(compiler.stage, builder.config.build), target_compiler: compiler, target, }); + if let Some(mut std_cargo_invoc) = std_cargo_invoc { + run_cargo(builder, + &mut std_cargo_invoc, + &libstd_stamp(builder, compiler, target), + false); + builder.ensure(StdLink { + compiler: builder.compiler(compiler.stage, builder.config.build), + target_compiler: compiler, + target, + }); + } + + builder.ensure(tool::CleanTools { + compiler, + target, + cause: Mode::Std, + }); } } @@ -139,6 +162,23 @@ fn mac_os_deployment_env_var(cargo: &mut Command) { } } +/// Configure cargo to compile a few no_std crates like core, +/// adding appropriate env vars and such. +pub fn core_cargo(builder: &Builder, + _compiler: &Compiler, + _target: Interned, + cargo: &mut Command) { + mac_os_deployment_env_var(cargo); + + // for no-std targets we only compile a few no_std crates + cargo.arg("--features").arg("c mem") + .args(&["-p", "alloc"]) + .args(&["-p", "compiler_builtins"]) + .args(&["-p", "std_unicode"]) + .arg("--manifest-path") + .arg(builder.src.join("src/rustc/compiler_builtins_shim/Cargo.toml")); +} + /// Configure cargo to compile the standard library, adding appropriate env vars /// and such. pub fn std_cargo(builder: &Builder, @@ -147,58 +187,85 @@ pub fn std_cargo(builder: &Builder, cargo: &mut Command) { mac_os_deployment_env_var(cargo); - if builder.no_std(target) == Some(true) { - // for no-std targets we only compile a few no_std crates - cargo.arg("--features").arg("c mem") - .args(&["-p", "alloc"]) - .args(&["-p", "compiler_builtins"]) - .args(&["-p", "std_unicode"]) - .arg("--manifest-path") - .arg(builder.src.join("src/rustc/compiler_builtins_shim/Cargo.toml")); - } else { - let mut features = builder.std_features(); - - // When doing a local rebuild we tell cargo that we're stage1 rather than - // stage0. This works fine if the local rust and being-built rust have the - // same view of what the default allocator is, but fails otherwise. Since - // we don't have a way to express an allocator preference yet, work - // around the issue in the case of a local rebuild with jemalloc disabled. - if compiler.stage == 0 && builder.local_rebuild && !builder.config.use_jemalloc { - features.push_str(" force_alloc_system"); - } + let mut features = builder.std_features(); - if compiler.stage != 0 && builder.config.sanitizers { - // This variable is used by the sanitizer runtime crates, e.g. - // rustc_lsan, to build the sanitizer runtime from C code - // When this variable is missing, those crates won't compile the C code, - // so we don't set this variable during stage0 where llvm-config is - // missing - // We also only build the runtimes when --enable-sanitizers (or its - // config.toml equivalent) is used - let llvm_config = builder.ensure(native::Llvm { - target: builder.config.build, - emscripten: false, - }); - cargo.env("LLVM_CONFIG", llvm_config); - } + // When doing a local rebuild we tell cargo that we're stage1 rather than + // stage0. This works fine if the local rust and being-built rust have the + // same view of what the default allocator is, but fails otherwise. Since + // we don't have a way to express an allocator preference yet, work + // around the issue in the case of a local rebuild with jemalloc disabled. + if compiler.stage == 0 && builder.local_rebuild && !builder.config.use_jemalloc { + features.push_str(" force_alloc_system"); + } - cargo.arg("--features").arg(features) - .arg("--manifest-path") - .arg(builder.src.join("src/libstd/Cargo.toml")); + if compiler.stage != 0 && builder.config.sanitizers { + // This variable is used by the sanitizer runtime crates, e.g. + // rustc_lsan, to build the sanitizer runtime from C code + // When this variable is missing, those crates won't compile the C code, + // so we don't set this variable during stage0 where llvm-config is + // missing + // We also only build the runtimes when --enable-sanitizers (or its + // config.toml equivalent) is used + let llvm_config = builder.ensure(native::Llvm { + target: builder.config.build, + emscripten: false, + }); + cargo.env("LLVM_CONFIG", llvm_config); + } - if let Some(target) = builder.config.target_config.get(&target) { - if let Some(ref jemalloc) = target.jemalloc { - cargo.env("JEMALLOC_OVERRIDE", jemalloc); - } + cargo.arg("--features").arg(features) + .arg("--manifest-path") + .arg(builder.src.join("src/libstd/Cargo.toml")); + + if let Some(target) = builder.config.target_config.get(&target) { + if let Some(ref jemalloc) = target.jemalloc { + cargo.env("JEMALLOC_OVERRIDE", jemalloc); } - if target.contains("musl") { - if let Some(p) = builder.musl_root(target) { - cargo.env("MUSL_ROOT", p); - } + } + if target.contains("musl") { + if let Some(p) = builder.musl_root(target) { + cargo.env("MUSL_ROOT", p); } } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +struct CoreLink { + pub compiler: Compiler, + pub target_compiler: Compiler, + pub target: Interned, +} + +impl Step for CoreLink { + type Output = (); + + fn should_run(run: ShouldRun) -> ShouldRun { + run.never() + } + + /// Link all libcore rlibs/dylibs into the sysroot location. + /// + /// Links those artifacts generated by `compiler` to a the `stage` compiler's + /// sysroot for the specified `host` and `target`. + /// + /// Note that this assumes that `compiler` has already generated the + /// libraries for `target`, and this method will find them in the relevant + /// output directory. + fn run(self, builder: &Builder) { + let compiler = self.compiler; + let target_compiler = self.target_compiler; + let target = self.target; + builder.info(&format!("Copying stage{} core from stage{} ({} -> {} / {})", + target_compiler.stage, + compiler.stage, + &compiler.host, + target_compiler.host, + target)); + let libdir = builder.sysroot_libdir(target_compiler, target); + add_to_sysroot(builder, &libdir, &libstd_stamp(builder, compiler, target)); + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] struct StdLink { pub compiler: Compiler, @@ -240,12 +307,6 @@ impl Step for StdLink { // for reason why the sanitizers are not built in stage0. copy_apple_sanitizer_dylibs(builder, &builder.native_dir(target), "osx", &libdir); } - - builder.ensure(tool::CleanTools { - compiler: target_compiler, - target, - cause: Mode::Std, - }); } } @@ -923,6 +984,7 @@ impl Step for Assemble { for stage in 0..min(target_compiler.stage, builder.config.keep_stage.unwrap()) { let target_compiler = builder.compiler(stage, target_compiler.host); let target = target_compiler.host; + builder.ensure(CoreLink { compiler, target_compiler, target }); builder.ensure(StdLink { compiler, target_compiler, target }); builder.ensure(TestLink { compiler, target_compiler, target }); builder.ensure(RustcLink { compiler, target_compiler, target }); diff --git a/src/liballoc_jemalloc/Cargo.toml b/src/liballoc_jemalloc/Cargo.toml index 7986d5dd2eb54..8f52cbb2ea400 100644 --- a/src/liballoc_jemalloc/Cargo.toml +++ b/src/liballoc_jemalloc/Cargo.toml @@ -12,9 +12,7 @@ test = false doc = false [dependencies] -core = { path = "../libcore" } libc = { path = "../rustc/libc_shim" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } [build-dependencies] build_helper = { path = "../build_helper" } diff --git a/src/liballoc_system/Cargo.toml b/src/liballoc_system/Cargo.toml index c34e2f203a837..cd4979e686544 100644 --- a/src/liballoc_system/Cargo.toml +++ b/src/liballoc_system/Cargo.toml @@ -10,9 +10,7 @@ test = false doc = false [dependencies] -core = { path = "../libcore" } libc = { path = "../rustc/libc_shim" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } # See comments in the source for what this dependency is [target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] diff --git a/src/libpanic_abort/Cargo.toml b/src/libpanic_abort/Cargo.toml index 633d273b3b93c..7596e74a810d8 100644 --- a/src/libpanic_abort/Cargo.toml +++ b/src/libpanic_abort/Cargo.toml @@ -10,6 +10,4 @@ bench = false doc = false [dependencies] -core = { path = "../libcore" } libc = { path = "../rustc/libc_shim" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } diff --git a/src/libpanic_unwind/Cargo.toml b/src/libpanic_unwind/Cargo.toml index 74aaa4d5ae3db..88469a43e8b7c 100644 --- a/src/libpanic_unwind/Cargo.toml +++ b/src/libpanic_unwind/Cargo.toml @@ -10,8 +10,5 @@ bench = false doc = false [dependencies] -alloc = { path = "../liballoc" } -core = { path = "../libcore" } libc = { path = "../rustc/libc_shim" } unwind = { path = "../libunwind" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } diff --git a/src/libprofiler_builtins/Cargo.toml b/src/libprofiler_builtins/Cargo.toml index 79192fbb6819c..c56962b4940ea 100644 --- a/src/libprofiler_builtins/Cargo.toml +++ b/src/libprofiler_builtins/Cargo.toml @@ -11,9 +11,5 @@ test = false bench = false doc = false -[dependencies] -core = { path = "../libcore" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } - [build-dependencies] cc = "1.0.1" diff --git a/src/librustc_asan/Cargo.toml b/src/librustc_asan/Cargo.toml index 34d8b75a5bfb3..fb735ea56efdb 100644 --- a/src/librustc_asan/Cargo.toml +++ b/src/librustc_asan/Cargo.toml @@ -14,7 +14,4 @@ build_helper = { path = "../build_helper" } cmake = "0.1.18" [dependencies] -alloc = { path = "../liballoc" } alloc_system = { path = "../liballoc_system" } -core = { path = "../libcore" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } diff --git a/src/librustc_lsan/Cargo.toml b/src/librustc_lsan/Cargo.toml index 9c19b53742654..e81c64111b10f 100644 --- a/src/librustc_lsan/Cargo.toml +++ b/src/librustc_lsan/Cargo.toml @@ -14,7 +14,4 @@ build_helper = { path = "../build_helper" } cmake = "0.1.18" [dependencies] -alloc = { path = "../liballoc" } alloc_system = { path = "../liballoc_system" } -core = { path = "../libcore" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } diff --git a/src/librustc_msan/Cargo.toml b/src/librustc_msan/Cargo.toml index 17ec2b96438ad..b95fd93f1bec8 100644 --- a/src/librustc_msan/Cargo.toml +++ b/src/librustc_msan/Cargo.toml @@ -14,7 +14,4 @@ build_helper = { path = "../build_helper" } cmake = "0.1.18" [dependencies] -alloc = { path = "../liballoc" } alloc_system = { path = "../liballoc_system" } -core = { path = "../libcore" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } diff --git a/src/librustc_tsan/Cargo.toml b/src/librustc_tsan/Cargo.toml index 8bb67c0bbac5f..29bf6033bf7a2 100644 --- a/src/librustc_tsan/Cargo.toml +++ b/src/librustc_tsan/Cargo.toml @@ -14,7 +14,4 @@ build_helper = { path = "../build_helper" } cmake = "0.1.18" [dependencies] -alloc = { path = "../liballoc" } alloc_system = { path = "../liballoc_system" } -core = { path = "../libcore" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 5a2dce5930a4b..dee008dfd3916 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -13,16 +13,12 @@ path = "lib.rs" crate-type = ["dylib", "rlib"] [dependencies] -alloc = { path = "../liballoc" } alloc_jemalloc = { path = "../liballoc_jemalloc", optional = true } alloc_system = { path = "../liballoc_system" } panic_unwind = { path = "../libpanic_unwind", optional = true } panic_abort = { path = "../libpanic_abort" } -core = { path = "../libcore" } libc = { path = "../rustc/libc_shim" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } profiler_builtins = { path = "../libprofiler_builtins", optional = true } -std_unicode = { path = "../libstd_unicode" } unwind = { path = "../libunwind" } [dev-dependencies] diff --git a/src/libunwind/Cargo.toml b/src/libunwind/Cargo.toml index 4760461df64e3..44a99b3a0cc48 100644 --- a/src/libunwind/Cargo.toml +++ b/src/libunwind/Cargo.toml @@ -12,6 +12,4 @@ bench = false doc = false [dependencies] -core = { path = "../libcore" } libc = { path = "../rustc/libc_shim" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } diff --git a/src/rustc/dlmalloc_shim/Cargo.toml b/src/rustc/dlmalloc_shim/Cargo.toml index b6f8550829fe0..7edbda009e894 100644 --- a/src/rustc/dlmalloc_shim/Cargo.toml +++ b/src/rustc/dlmalloc_shim/Cargo.toml @@ -8,7 +8,3 @@ path = "../../dlmalloc/src/lib.rs" test = false bench = false doc = false - -[dependencies] -core = { path = "../../libcore" } -compiler_builtins = { path = "../../rustc/compiler_builtins_shim" } diff --git a/src/rustc/libc_shim/Cargo.toml b/src/rustc/libc_shim/Cargo.toml index e77897d643313..09b2bed919a5c 100644 --- a/src/rustc/libc_shim/Cargo.toml +++ b/src/rustc/libc_shim/Cargo.toml @@ -10,28 +10,6 @@ test = false bench = false doc = false -[dependencies] -# Specify the path to libcore; at the time of writing, removing this shim in -# favor of using libc from git results in a compilation failure: -# -# Building stage0 std artifacts (x86_64-apple-darwin -> x86_64-apple-darwin) -# Compiling libc v0.0.0 (file:///Users/tamird/src/rust/src/rustc/libc_shim) -# error[E0463]: can't find crate for `core` -# -# error: aborting due to previous error -# -# error: Could not compile `libc`. -# -# Caused by: -# process didn't exit successfully: `/Users/tamird/src/rust/build/bootstrap/debug/rustc --crate-name libc src/rustc/libc_shim/../../liblibc/src/lib.rs --error-format json --crate-type lib --emit=dep-info,link -C opt-level=2 --cfg feature="default" --cfg feature="no_std" --cfg feature="stdbuild" -C metadata=d758f87058112d7d -C extra-filename=-d758f87058112d7d --out-dir /Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -L dependency=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/x86_64-apple-darwin/release/deps -L dependency=/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0-std/release/deps` (exit code: 101) -# thread 'main' panicked at 'command did not execute successfully: "/Users/tamird/src/rust/build/x86_64-apple-darwin/stage0/bin/cargo" "build" "-j" "4" "--target" "x86_64-apple-darwin" "--release" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/Users/tamird/src/rust/src/libstd/Cargo.toml" "--message-format" "json" -# expected success, got: exit code: 101', src/bootstrap/compile.rs:883:8 -# -# See https://github.com/rust-lang/rfcs/pull/1133. -core = { path = "../../libcore" } -compiler_builtins = { path = "../compiler_builtins_shim" } - - [features] # Certain parts of libc are conditionally compiled differently than when used # outside rustc. See https://github.com/rust-lang/libc/search?l=Rust&q=stdbuild&type=&utf8=%E2%9C%93. From 9653b802bddb6928d6024f194fefbfb0d6781990 Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 9 Jun 2018 14:33:23 +0200 Subject: [PATCH 3/6] Add libcore_stamp --- src/bootstrap/compile.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 258c394a2f98f..29448161b153f 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -115,7 +115,7 @@ impl Step for Std { &compiler.host, target)); run_cargo(builder, &mut core_cargo_invoc, - &libstd_stamp(builder, compiler, target), + &libcore_stamp(builder, compiler, target), false); builder.ensure(CoreLink { compiler: builder.compiler(compiler.stage, builder.config.build), @@ -262,7 +262,7 @@ impl Step for CoreLink { target_compiler.host, target)); let libdir = builder.sysroot_libdir(target_compiler, target); - add_to_sysroot(builder, &libdir, &libstd_stamp(builder, compiler, target)); + add_to_sysroot(builder, &libdir, &libcore_stamp(builder, compiler, target)); } } @@ -434,6 +434,7 @@ impl Step for Test { } let out_dir = builder.cargo_out(compiler, Mode::Test, target); + builder.clear_if_dirty(&out_dir, &libcore_stamp(builder, compiler, target)); builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target)); let mut cargo = builder.cargo(compiler, Mode::Test, target, "build"); test_cargo(builder, &compiler, target, &mut cargo); @@ -553,6 +554,7 @@ impl Step for Rustc { target: builder.config.build, }); let cargo_out = builder.cargo_out(compiler, Mode::Rustc, target); + builder.clear_if_dirty(&cargo_out, &libcore_stamp(builder, compiler, target)); builder.clear_if_dirty(&cargo_out, &libstd_stamp(builder, compiler, target)); builder.clear_if_dirty(&cargo_out, &libtest_stamp(builder, compiler, target)); @@ -853,6 +855,12 @@ fn copy_lld_to_sysroot(builder: &Builder, builder.copy(&lld_install_root.join("bin").join(&exe), &dst.join(&exe)); } +/// Cargo's output path for libcore in a given stage, compiled +/// by a particular compiler for the specified target. +pub fn libcore_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { + builder.cargo_out(compiler, Mode::Std, target).join(".libcore.stamp") +} + /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target. pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { From 5050a4451da6bcc058a7451b95953e583ece423c Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 9 Jun 2018 15:05:50 +0200 Subject: [PATCH 4/6] Unbreak x.py check --- src/bootstrap/check.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index b3ccb3cc3c926..5fe8443d7ea86 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -10,7 +10,8 @@ //! Implementation of compiling the compiler and standard library, in "check" mode. -use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot}; +use compile::{run_cargo, core_cargo, std_cargo, test_cargo, + rustc_cargo, rustc_cargo_env, add_to_sysroot}; use builder::{RunConfig, Builder, ShouldRun, Step}; use tool::{self, prepare_tool_cargo}; use {Compiler, Mode}; @@ -43,17 +44,25 @@ impl Step for Std { let out_dir = builder.stage_out(compiler, Mode::Std); builder.clear_if_dirty(&out_dir, &builder.rustc(compiler)); - let mut cargo = builder.cargo(compiler, Mode::Std, target, "check"); - std_cargo(builder, &compiler, target, &mut cargo); + let mut core_cargo_invoc = builder.cargo(compiler, Mode::Std, target, "check"); + core_cargo(builder, &compiler, target, &mut core_cargo_invoc); + let mut std_cargo_invoc = builder.cargo(compiler, Mode::Std, target, "check"); + std_cargo(builder, &compiler, target, &mut std_cargo_invoc); let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage)); + let libdir = builder.sysroot_libdir(compiler, target); + println!("Checking std artifacts ({} -> {})", &compiler.host, target); run_cargo(builder, - &mut cargo, + &mut core_cargo_invoc, + &libcore_stamp(builder, compiler, target), + true); + add_to_sysroot(&builder, &libdir, &libcore_stamp(builder, compiler, target)); + run_cargo(builder, + &mut std_cargo_invoc, &libstd_stamp(builder, compiler, target), true); - let libdir = builder.sysroot_libdir(compiler, target); add_to_sysroot(&builder, &libdir, &libstd_stamp(builder, compiler, target)); } } @@ -88,6 +97,7 @@ impl Step for Rustc { let target = self.target; let stage_out = builder.stage_out(compiler, Mode::Rustc); + builder.clear_if_dirty(&stage_out, &libcore_stamp(builder, compiler, target)); builder.clear_if_dirty(&stage_out, &libstd_stamp(builder, compiler, target)); builder.clear_if_dirty(&stage_out, &libtest_stamp(builder, compiler, target)); @@ -176,6 +186,7 @@ impl Step for Test { let target = self.target; let out_dir = builder.stage_out(compiler, Mode::Test); + builder.clear_if_dirty(&out_dir, &libcore_stamp(builder, compiler, target)); builder.clear_if_dirty(&out_dir, &libstd_stamp(builder, compiler, target)); let mut cargo = builder.cargo(compiler, Mode::Test, target, "check"); @@ -242,6 +253,12 @@ impl Step for Rustdoc { } } +/// Cargo's output path for the core library in a given stage, compiled +/// by a particular compiler for the specified target. +pub fn libcore_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { + builder.cargo_out(compiler, Mode::Std, target).join(".libcore-check.stamp") +} + /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target. pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { From 046a95dc956d33ecad1f98eb3f8ba999b4ee4961 Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 9 Jun 2018 20:42:56 +0200 Subject: [PATCH 5/6] Unbreak x.py doc Add CoreLink to Std::run() --- src/bootstrap/compile.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 29448161b153f..a3c5583e3c6e8 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -85,6 +85,12 @@ impl Step for Std { copy_musl_third_party_objects(builder, target, &libdir); } + builder.ensure(CoreLink { + compiler: from, + target_compiler: compiler, + target, + }); + builder.ensure(StdLink { compiler: from, target_compiler: compiler, From 57ca376d33a51bd7cf8239db2b70f0022a1e8e1d Mon Sep 17 00:00:00 2001 From: est31 Date: Sun, 10 Jun 2018 21:12:21 +0200 Subject: [PATCH 6/6] Add core crates to the should_run functions Removal of them as direct dependencies of the std crate makes this neccessary. --- src/bootstrap/check.rs | 4 ++++ src/bootstrap/compile.rs | 4 ++++ src/bootstrap/doc.rs | 7 ++++++- src/bootstrap/test.rs | 5 ++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 5fe8443d7ea86..3b1125cc491af 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -29,6 +29,10 @@ impl Step for Std { fn should_run(run: ShouldRun) -> ShouldRun { run.all_krates("std") + .path("src/libcore") + .path("src/liballoc") + .path("src/libstd_unicode") + .path("src/rustc/compiler_builtins_shim") } fn make_run(run: RunConfig) { diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index a3c5583e3c6e8..5a52ccdc631ca 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -50,6 +50,10 @@ impl Step for Std { fn should_run(run: ShouldRun) -> ShouldRun { run.all_krates("std") + .path("src/libcore") + .path("src/liballoc") + .path("src/libstd_unicode") + .path("src/rustc/compiler_builtins_shim") } fn make_run(run: RunConfig) { diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 19599b33ebe26..64946a50c9453 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -434,7 +434,12 @@ impl Step for Std { fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; - run.all_krates("std").default_condition(builder.config.docs) + run.all_krates("std") + .path("src/libcore") + .path("src/liballoc") + .path("src/libstd_unicode") + .path("src/rustc/compiler_builtins_shim") + .default_condition(builder.config.docs) } fn make_run(run: RunConfig) { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index a0b6222421d71..d4847c2bc6ae5 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1526,7 +1526,10 @@ impl Step for Crate { run = run.path(krate.local_path(&builder).to_str().unwrap()); } } - run + run.path("src/libcore") + .path("src/liballoc") + .path("src/libstd_unicode") + .path("src/rustc/compiler_builtins_shim") } fn make_run(run: RunConfig) {