Skip to content

Commit fc5ac40

Browse files
committed
Rename jemalloc bootstrap options to override-allocator
1 parent 3655153 commit fc5ac40

28 files changed

Lines changed: 62 additions & 51 deletions

File tree

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ See [the rustc-dev-guide for more info][sysllvm].
9696
--set llvm.libzstd=true \
9797
--set llvm.ninja=false \
9898
--set rust.debug-assertions=false \
99-
--set rust.jemalloc \
99+
--set rust.override-allocator \
100100
--set rust.bootstrap-override-lld=true \
101101
--set rust.lto=thin \
102102
--set rust.codegen-units=1

bootstrap.example.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@
848848
# Link the compiler and LLVM against `jemalloc` instead of the default libc allocator.
849849
# This option is only tested on Linux and OSX. It can also be configured per-target in the
850850
# [target.<tuple>] section.
851-
#rust.jemalloc = false
851+
#rust.override-allocator = false
852852

853853
# Run tests in various test suites with the "nll compare mode" in addition to
854854
# running the tests in normal mode. Largely only used on CI and during local
@@ -1121,8 +1121,8 @@
11211121
#optimized-compiler-builtins = build.optimized-compiler-builtins (bool or path)
11221122

11231123
# Link the compiler and LLVM against `jemalloc` instead of the default libc allocator.
1124-
# This overrides the global `rust.jemalloc` option. See that option for more info.
1125-
#jemalloc = rust.jemalloc (bool)
1124+
# This overrides the global `rust.override-allocator` option. See that option for more info.
1125+
#override-allocator = rust.override-allocator (bool)
11261126

11271127
# The linker configuration that will *override* the default linker used for Linux
11281128
# targets in the built compiler.

compiler/rustc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ features = ['override_allocator_on_supported_platforms']
3535
[features]
3636
# tidy-alphabetical-start
3737
check_only = ['rustc_driver_impl/check_only']
38-
jemalloc = ['dep:tikv-jemalloc-sys']
38+
override_allocator = ['dep:tikv-jemalloc-sys']
3939
llvm = ['rustc_driver_impl/llvm']
4040
llvm_enzyme = ['rustc_driver_impl/llvm_enzyme']
4141
llvm_offload = ['rustc_driver_impl/llvm_offload']

compiler/rustc/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use std::process::ExitCode;
3737
// to compare their performance, see
3838
// https://github.com/rust-lang/rust/commit/b90cfc887c31c3e7a9e6d462e2464db1fe506175#diff-43914724af6e464c1da2171e4a9b6c7e607d5bc1203fa95c0ab85be4122605ef
3939
// for an example of how to do so.
40-
#[cfg(feature = "jemalloc")]
40+
#[cfg(feature = "override_allocator")]
4141
use tikv_jemalloc_sys as _;
4242

4343
fn main() -> ExitCode {

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,9 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
14111411
}
14121412

14131413
// See also the "JEMALLOC_SYS_WITH_LG_PAGE" setting in the tool build step.
1414-
if builder.config.jemalloc(target) && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() {
1414+
if builder.config.override_allocator(target)
1415+
&& env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none()
1416+
{
14151417
// Build jemalloc on AArch64 with support for page sizes up to 64K
14161418
// See: https://github.com/rust-lang/rust/pull/135081
14171419
if target.starts_with("aarch64") {

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ pub fn prepare_tool_cargo(
229229
cargo.env("LZMA_API_STATIC", "1");
230230

231231
// See also the "JEMALLOC_SYS_WITH_LG_PAGE" setting in the compile build step.
232-
if builder.config.jemalloc(target) && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() {
232+
if builder.config.override_allocator(target)
233+
&& env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none()
234+
{
233235
// Build jemalloc on AArch64 with support for page sizes up to 64K
234236
// See: https://github.com/rust-lang/rust/pull/135081
235237
if target.starts_with("aarch64") {
@@ -752,8 +754,8 @@ impl Step for Rustdoc {
752754
// to build rustdoc.
753755
//
754756
let mut extra_features = Vec::new();
755-
if builder.config.jemalloc(target) {
756-
extra_features.push("jemalloc".to_string());
757+
if builder.config.override_allocator(target) {
758+
extra_features.push("override_allocator".to_string());
757759
}
758760

759761
let compilers = RustcPrivateCompilers::from_target_compiler(builder, target_compiler);
@@ -1576,8 +1578,8 @@ tool_rustc_extended!(Clippy {
15761578
stable: true,
15771579
add_bins_to_sysroot: ["clippy-driver"],
15781580
add_features: |builder, target, features| {
1579-
if builder.config.jemalloc(target) {
1580-
features.push("jemalloc".to_string());
1581+
if builder.config.override_allocator(target) {
1582+
features.push("override_allocator".to_string());
15811583
}
15821584
}
15831585
});
@@ -1587,8 +1589,8 @@ tool_rustc_extended!(Miri {
15871589
stable: false,
15881590
add_bins_to_sysroot: ["miri"],
15891591
add_features: |builder, target, features| {
1590-
if builder.config.jemalloc(target) {
1591-
features.push("jemalloc".to_string());
1592+
if builder.config.override_allocator(target) {
1593+
features.push("override_allocator".to_string());
15921594
}
15931595
},
15941596
// Always compile also tests when building miri. Otherwise feature unification can cause rebuilds between building and testing miri.

src/bootstrap/src/core/config/config.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub struct Config {
242242
pub hosts: Vec<TargetSelection>,
243243
pub targets: Vec<TargetSelection>,
244244
pub local_rebuild: bool,
245-
pub jemalloc: bool,
245+
pub override_allocator: bool,
246246
pub control_flow_guard: bool,
247247
pub ehcont_guard: bool,
248248

@@ -570,7 +570,7 @@ impl Config {
570570
thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit,
571571
parallel_frontend_threads: rust_parallel_frontend_threads,
572572
remap_debuginfo: rust_remap_debuginfo,
573-
jemalloc: rust_jemalloc,
573+
override_allocator: rust_override_allocator,
574574
test_compare_mode: rust_test_compare_mode,
575575
llvm_libunwind: rust_llvm_libunwind,
576576
control_flow_guard: rust_control_flow_guard,
@@ -900,7 +900,7 @@ impl Config {
900900
codegen_backends: target_codegen_backends,
901901
runner: target_runner,
902902
optimized_compiler_builtins: target_optimized_compiler_builtins,
903-
jemalloc: target_jemalloc,
903+
override_allocator: target_override_allocator,
904904
} = cfg;
905905

906906
let mut target = Target::from_triple(&triple);
@@ -976,7 +976,7 @@ impl Config {
976976
target.rpath = target_rpath;
977977
target.rustflags = target_rustflags.unwrap_or_default();
978978
target.optimized_compiler_builtins = target_optimized_compiler_builtins;
979-
target.jemalloc = target_jemalloc;
979+
target.override_allocator = target_override_allocator;
980980
if let Some(backends) = target_codegen_backends {
981981
target.codegen_backends =
982982
Some(parse_codegen_backends(backends, &format!("target.{triple}")))
@@ -1365,7 +1365,7 @@ impl Config {
13651365
initial_rustdoc,
13661366
initial_rustfmt,
13671367
initial_sysroot,
1368-
jemalloc: rust_jemalloc.unwrap_or(false),
1368+
override_allocator: rust_override_allocator.unwrap_or(false),
13691369
jobs: Some(threads_from_config(flags_jobs.or(build_jobs).unwrap_or(0))),
13701370
json_output: flags_json_output,
13711371
keep_stage: flags_keep_stage,
@@ -1858,8 +1858,11 @@ impl Config {
18581858
self.enabled_codegen_backends(target).first().unwrap()
18591859
}
18601860

1861-
pub fn jemalloc(&self, target: TargetSelection) -> bool {
1862-
self.target_config.get(&target).and_then(|cfg| cfg.jemalloc).unwrap_or(self.jemalloc)
1861+
pub fn override_allocator(&self, target: TargetSelection) -> bool {
1862+
self.target_config
1863+
.get(&target)
1864+
.and_then(|cfg| cfg.override_allocator)
1865+
.unwrap_or(self.override_allocator)
18631866
}
18641867

18651868
pub fn rpath_enabled(&self, target: TargetSelection) -> bool {

src/bootstrap/src/core/config/toml/rust.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ define_config! {
5555
verify_llvm_ir: Option<bool> = "verify-llvm-ir",
5656
thin_lto_import_instr_limit: Option<u32> = "thin-lto-import-instr-limit",
5757
remap_debuginfo: Option<bool> = "remap-debuginfo",
58-
jemalloc: Option<bool> = "jemalloc",
58+
override_allocator: Option<bool> = "override-allocator",
5959
test_compare_mode: Option<bool> = "test-compare-mode",
6060
llvm_libunwind: Option<String> = "llvm-libunwind",
6161
control_flow_guard: Option<bool> = "control-flow-guard",
@@ -325,7 +325,7 @@ pub fn check_incompatible_options_for_ci_rustc(
325325
llvm_bitcode_linker,
326326
stack_protector,
327327
strip,
328-
jemalloc,
328+
override_allocator,
329329
rpath,
330330
channel,
331331
default_linker,
@@ -394,7 +394,7 @@ pub fn check_incompatible_options_for_ci_rustc(
394394
err!(current_rust_config.strip, strip, "rust");
395395
err!(current_rust_config.llvm_tools, llvm_tools, "rust");
396396
err!(current_rust_config.llvm_bitcode_linker, llvm_bitcode_linker, "rust");
397-
err!(current_rust_config.jemalloc, jemalloc, "rust");
397+
err!(current_rust_config.override_allocator, override_allocator, "rust");
398398
err!(current_rust_config.default_linker, default_linker, "rust");
399399
err!(current_rust_config.stack_protector, stack_protector, "rust");
400400
err!(current_rust_config.std_features, std_features, "rust");

src/bootstrap/src/core/config/toml/target.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ define_config! {
4747
codegen_backends: Option<Vec<String>> = "codegen-backends",
4848
runner: Option<String> = "runner",
4949
optimized_compiler_builtins: Option<CompilerBuiltins> = "optimized-compiler-builtins",
50-
jemalloc: Option<bool> = "jemalloc",
50+
override_allocator: Option<bool> = "override-allocator",
5151
}
5252
}
5353

@@ -81,7 +81,7 @@ pub struct Target {
8181
pub no_std: bool,
8282
pub codegen_backends: Option<Vec<CodegenBackendKind>>,
8383
pub optimized_compiler_builtins: Option<CompilerBuiltins>,
84-
pub jemalloc: Option<bool>,
84+
pub override_allocator: Option<bool>,
8585
}
8686

8787
impl Target {

src/bootstrap/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,8 @@ impl Build {
863863
crates.is_empty() || possible_features_by_crates.contains(feature)
864864
};
865865
let mut features = vec![];
866-
if self.config.jemalloc(target) && check("jemalloc") {
867-
features.push("jemalloc");
866+
if self.config.override_allocator(target) && check("override_allocator") {
867+
features.push("override_allocator");
868868
}
869869
if (self.config.llvm_enabled(target) || kind == Kind::Check) && check("llvm") {
870870
features.push("llvm");

0 commit comments

Comments
 (0)