diff options
| author | bors <bors@rust-lang.org> | 2017-01-21 03:26:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-21 03:26:37 +0000 |
| commit | 633f38ae99b657f70e2aba135318178abc9fee16 (patch) | |
| tree | 0131b807f53c9fcb750437daebe1f4227726dff5 | |
| parent | aedb49cbc9977fee56bb51a20980b380aca53659 (diff) | |
| parent | 70d2372adaf48bb24f8b829417229149bd103e4a (diff) | |
| download | rust-633f38ae99b657f70e2aba135318178abc9fee16.tar.gz rust-633f38ae99b657f70e2aba135318178abc9fee16.zip | |
Auto merge of #39086 - aidanhs:aphs-local-rebuild-no-jemalloc, r=alexcrichton
Make rustbuild force_alloc_system rather than relying on stage0 This 'fixes' jemalloc-less local rebuilds, where we tell cargo that we're actually stage1 (this only fixes the rustbuild path, since I wasn't enthusiastic to dive into the makefiles). There should be one effect from this PR: `--enable-local-rebuild --disable-jemalloc` will successfully build a stage0 std (rather than erroring). Ideally I think it'd be nice to specify an allocator preference in Cargo.toml/cargo command line (used when an allocator must be picked i.e. dylibs, not rlibs), but since that's not possible we can make do with a force_alloc_system feature. Sadly this locks you into a single allocator in the build libstd, making any eventual implementation of #38575 not quite right in this edge case, but clearly not many people exercise the combination of these two flags. This PR is also a substitute for #37975 I think. The crucial difference is that the feature name here is distinct from the jemalloc feature (reused in the previous PR) - we don't want someone to be forced into alloc_system just for disabling jemalloc! Fixes #39054 r? @alexcrichton
| -rw-r--r-- | src/bootstrap/compile.rs | 11 | ||||
| -rw-r--r-- | src/libstd/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 9 | ||||
| -rw-r--r-- | src/rustc/std_shim/Cargo.toml | 1 |
4 files changed, 17 insertions, 5 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 079f93e7331..7bc11d88eba 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -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")); diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index fcf84cb7169..8146e7fb1ed 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -31,4 +31,5 @@ gcc = "0.3.27" backtrace = [] debug-jemalloc = ["alloc_jemalloc/debug"] jemalloc = ["alloc_jemalloc"] +force_alloc_system = [] panic-unwind = ["panic_unwind"] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 521b938acfb..37632ac76f2 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -219,9 +219,10 @@ // 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 @@ -333,7 +334,7 @@ extern crate libc; // 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 diff --git a/src/rustc/std_shim/Cargo.toml b/src/rustc/std_shim/Cargo.toml index 1fa91772435..7260a844073 100644 --- a/src/rustc/std_shim/Cargo.toml +++ b/src/rustc/std_shim/Cargo.toml @@ -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"] |
