Skip to content

Commit 70d2372

Browse files
committedJan 16, 2017
Expose a feature to force use of alloc_system, teach rustbuild
This fixes jemalloc-less local rebuilds, where we tell cargo that we're actually stage1
1 parent b0c52c5 commit 70d2372

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed
 

‎src/bootstrap/compile.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,16 @@ pub fn std(build: &Build, target: &str, compiler: &Compiler) {
4242
let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
4343
build.clear_if_dirty(&out_dir, &build.compiler_path(compiler));
4444
let mut cargo = build.cargo(compiler, Mode::Libstd, target, "build");
45-
cargo.arg("--features").arg(build.std_features())
45+
let mut features = build.std_features();
46+
// When doing a local rebuild we tell cargo that we're stage1 rather than
47+
// stage0. This works fine if the local rust and being-built rust have the
48+
// same view of what the default allocator is, but fails otherwise. Since
49+
// we don't have a way to express an allocator preference yet, work
50+
// around the issue in the case of a local rebuild with jemalloc disabled.
51+
if compiler.stage == 0 && build.local_rebuild && !build.config.use_jemalloc {
52+
features.push_str(" force_alloc_system");
53+
}
54+
cargo.arg("--features").arg(features)
4655
.arg("--manifest-path")
4756
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"));
4857

‎src/libstd/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ gcc = "0.3.27"
3131
backtrace = []
3232
debug-jemalloc = ["alloc_jemalloc/debug"]
3333
jemalloc = ["alloc_jemalloc"]
34+
force_alloc_system = []
3435
panic-unwind = ["panic_unwind"]

‎src/libstd/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,10 @@
219219
// Tell the compiler to link to either panic_abort or panic_unwind
220220
#![needs_panic_runtime]
221221

222-
// Always use alloc_system during stage0 since jemalloc might be unavailable or
223-
// disabled (Issue #30592)
224-
#![cfg_attr(stage0, feature(alloc_system))]
222+
// Always use alloc_system during stage0 since we don't know if the alloc_*
223+
// crate the stage0 compiler will pick by default is available (most
224+
// obviously, if the user has disabled jemalloc in `./configure`).
225+
#![cfg_attr(any(stage0, feature = "force_alloc_system"), feature(alloc_system))]
225226

226227
// Turn warnings into errors, but only after stage0, where it can be useful for
227228
// code to emit warnings during language transitions
@@ -333,7 +334,7 @@ extern crate libc;
333334
// We always need an unwinder currently for backtraces
334335
extern crate unwind;
335336

336-
#[cfg(stage0)]
337+
#[cfg(any(stage0, feature = "force_alloc_system"))]
337338
extern crate alloc_system;
338339

339340
// compiler-rt intrinsics

‎src/rustc/std_shim/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ core = { path = "../../libcore" }
3838
backtrace = ["std/backtrace"]
3939
debug-jemalloc = ["std/debug-jemalloc"]
4040
jemalloc = ["std/jemalloc"]
41+
force_alloc_system = ["std/force_alloc_system"]
4142
panic-unwind = ["std/panic-unwind"]

0 commit comments

Comments
 (0)
Please sign in to comment.