]> git.lizzy.rs Git - rust.git/commitdiff
Expose a feature to force use of alloc_system, teach rustbuild
authorAidan Hobson Sayers <aidanhs@cantab.net>
Sun, 15 Jan 2017 22:33:58 +0000 (22:33 +0000)
committerAidan Hobson Sayers <aidanhs@cantab.net>
Mon, 16 Jan 2017 03:06:45 +0000 (03:06 +0000)
This fixes jemalloc-less local rebuilds, where we tell cargo that
we're actually stage1

src/bootstrap/compile.rs
src/libstd/Cargo.toml
src/libstd/lib.rs
src/rustc/std_shim/Cargo.toml

index 0eeb799672cf200a5406aae656cad80ec16a71fa..2464c9782780631bb0e4886ffd6ff930a88cb9d1 100644 (file)
@@ -42,7 +42,16 @@ pub fn std(build: &Build, target: &str, compiler: &Compiler) {
     let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
     build.clear_if_dirty(&out_dir, &build.compiler_path(compiler));
     let mut cargo = build.cargo(compiler, Mode::Libstd, target, "build");
-    cargo.arg("--features").arg(build.std_features())
+    let mut features = build.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 && build.local_rebuild && !build.config.use_jemalloc {
+        features.push_str(" force_alloc_system");
+    }
+    cargo.arg("--features").arg(features)
          .arg("--manifest-path")
          .arg(build.src.join("src/rustc/std_shim/Cargo.toml"));
 
index fcf84cb716917ea51b70e7efc1bee89b54a557b2..8146e7fb1edaf4a5b0a413d781a06dbd7d7b943b 100644 (file)
@@ -31,4 +31,5 @@ gcc = "0.3.27"
 backtrace = []
 debug-jemalloc = ["alloc_jemalloc/debug"]
 jemalloc = ["alloc_jemalloc"]
+force_alloc_system = []
 panic-unwind = ["panic_unwind"]
index 521b938acfb7ec82c5d36e12b9fb644856218dc4..37632ac76f2dbab5c2e04793a892f7aad619fd9c 100644 (file)
 // Tell the compiler to link to either panic_abort or panic_unwind
 #![needs_panic_runtime]
 
-// Always use alloc_system during stage0 since jemalloc might be unavailable or
-// disabled (Issue #30592)
-#![cfg_attr(stage0, feature(alloc_system))]
+// Always use alloc_system during stage0 since we don't know if the alloc_*
+// crate the stage0 compiler will pick by default is available (most
+// obviously, if the user has disabled jemalloc in `./configure`).
+#![cfg_attr(any(stage0, feature = "force_alloc_system"), feature(alloc_system))]
 
 // Turn warnings into errors, but only after stage0, where it can be useful for
 // code to emit warnings during language transitions
 // We always need an unwinder currently for backtraces
 extern crate unwind;
 
-#[cfg(stage0)]
+#[cfg(any(stage0, feature = "force_alloc_system"))]
 extern crate alloc_system;
 
 // compiler-rt intrinsics
index 1fa917724353628ce1e981c6b2d61186016de45f..7260a8440734d9ea0f64a47167d06126dc76160d 100644 (file)
@@ -38,4 +38,5 @@ core = { path = "../../libcore" }
 backtrace = ["std/backtrace"]
 debug-jemalloc = ["std/debug-jemalloc"]
 jemalloc = ["std/jemalloc"]
+force_alloc_system = ["std/force_alloc_system"]
 panic-unwind = ["std/panic-unwind"]