mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
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
This commit is contained in:
parent
b0c52c587f
commit
70d2372ada
@ -42,7 +42,16 @@ pub fn std(build: &Build, target: &str, compiler: &Compiler) {
|
|||||||
let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
|
let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
|
||||||
build.clear_if_dirty(&out_dir, &build.compiler_path(compiler));
|
build.clear_if_dirty(&out_dir, &build.compiler_path(compiler));
|
||||||
let mut cargo = build.cargo(compiler, Mode::Libstd, target, "build");
|
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("--manifest-path")
|
||||||
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"));
|
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"));
|
||||||
|
|
||||||
|
@ -31,4 +31,5 @@ gcc = "0.3.27"
|
|||||||
backtrace = []
|
backtrace = []
|
||||||
debug-jemalloc = ["alloc_jemalloc/debug"]
|
debug-jemalloc = ["alloc_jemalloc/debug"]
|
||||||
jemalloc = ["alloc_jemalloc"]
|
jemalloc = ["alloc_jemalloc"]
|
||||||
|
force_alloc_system = []
|
||||||
panic-unwind = ["panic_unwind"]
|
panic-unwind = ["panic_unwind"]
|
||||||
|
@ -219,9 +219,10 @@
|
|||||||
// Tell the compiler to link to either panic_abort or panic_unwind
|
// Tell the compiler to link to either panic_abort or panic_unwind
|
||||||
#![needs_panic_runtime]
|
#![needs_panic_runtime]
|
||||||
|
|
||||||
// Always use alloc_system during stage0 since jemalloc might be unavailable or
|
// Always use alloc_system during stage0 since we don't know if the alloc_*
|
||||||
// disabled (Issue #30592)
|
// crate the stage0 compiler will pick by default is available (most
|
||||||
#![cfg_attr(stage0, feature(alloc_system))]
|
// 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
|
// Turn warnings into errors, but only after stage0, where it can be useful for
|
||||||
// code to emit warnings during language transitions
|
// code to emit warnings during language transitions
|
||||||
@ -333,7 +334,7 @@ extern crate libc;
|
|||||||
// We always need an unwinder currently for backtraces
|
// We always need an unwinder currently for backtraces
|
||||||
extern crate unwind;
|
extern crate unwind;
|
||||||
|
|
||||||
#[cfg(stage0)]
|
#[cfg(any(stage0, feature = "force_alloc_system"))]
|
||||||
extern crate alloc_system;
|
extern crate alloc_system;
|
||||||
|
|
||||||
// compiler-rt intrinsics
|
// compiler-rt intrinsics
|
||||||
|
@ -38,4 +38,5 @@ core = { path = "../../libcore" }
|
|||||||
backtrace = ["std/backtrace"]
|
backtrace = ["std/backtrace"]
|
||||||
debug-jemalloc = ["std/debug-jemalloc"]
|
debug-jemalloc = ["std/debug-jemalloc"]
|
||||||
jemalloc = ["std/jemalloc"]
|
jemalloc = ["std/jemalloc"]
|
||||||
|
force_alloc_system = ["std/force_alloc_system"]
|
||||||
panic-unwind = ["std/panic-unwind"]
|
panic-unwind = ["std/panic-unwind"]
|
||||||
|
Loading…
Reference in New Issue
Block a user