From fec36539159d9eb0a7948492d19933986e17698a Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Tue, 28 Jul 2026 15:52:16 +0100 Subject: [PATCH 01/11] Add "system" option to `override-allocator` setting This allows a per-target `override-allocator` to revert to the system allocator even if there is a global rule specifying a different allocator. Remap `jemalloc = false` to `override-allocator = "system"` instead of mapping it to "override-allocator is unset"; this restores the correct precedence behaviour of this setting. This also allows `Config::override_allocator()` to always resolve the directive to a definite value, rather than needing it to be wrapped in an `Option`, which simplifies some other code. Finally, print a more specific warning when `jemalloc` is set, telling users the appropriate setting to use for `override-allocator` depending on whether `jemalloc` is set to true or false. Fixes https://github.com/rust-lang/rust/issues/160084 --- src/bootstrap/src/core/build_steps/compile.rs | 2 +- src/bootstrap/src/core/build_steps/tool.rs | 11 +++-- src/bootstrap/src/core/config/config.rs | 44 ++++++++++--------- src/bootstrap/src/core/config/mod.rs | 9 +++- src/bootstrap/src/lib.rs | 9 ++-- 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 9ddcb32c2e45d..1aee78e1287fb 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1392,7 +1392,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS } // See also the "JEMALLOC_SYS_WITH_LG_PAGE" setting in the tool build step. - if let Some(OverrideAllocator::Jemalloc) = builder.config.override_allocator(target) + if builder.config.override_allocator(target) == OverrideAllocator::Jemalloc && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() { // Build jemalloc on AArch64 with support for page sizes up to 64K diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index d5c2ecf7e93f5..e80cbce56e290 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -241,7 +241,7 @@ pub fn prepare_tool_cargo( cargo.env("LZMA_API_STATIC", "1"); // See also the "JEMALLOC_SYS_WITH_LG_PAGE" setting in the compile build step. - if let Some(OverrideAllocator::Jemalloc) = builder.config.override_allocator(target) + if builder.config.override_allocator(target) == OverrideAllocator::Jemalloc && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() { // Build jemalloc on AArch64 with support for page sizes up to 64K @@ -767,7 +767,8 @@ impl CommandLineStep for Rustdoc { // to build rustdoc. // let mut extra_features = Vec::new(); - if let Some(allocator) = builder.config.override_allocator(target) { + let allocator = builder.config.override_allocator(target); + if allocator != OverrideAllocator::System { extra_features.push(allocator.feature_name().to_string()); } if !builder.config.rust_debug_logging { @@ -1585,7 +1586,8 @@ tool_rustc_extended!(Clippy { stable: true, add_bins_to_sysroot: ["clippy-driver"], add_features: |builder, target, features| { - if let Some(allocator) = builder.config.override_allocator(target) { + let allocator = builder.config.override_allocator(target); + if allocator != OverrideAllocator::System { features.push(allocator.feature_name().to_string()); } } @@ -1596,7 +1598,8 @@ tool_rustc_extended!(Miri { stable: false, add_bins_to_sysroot: ["miri"], add_features: |builder, target, features| { - if let Some(allocator) = builder.config.override_allocator(target) { + let allocator = builder.config.override_allocator(target); + if allocator != OverrideAllocator::System { features.push(allocator.feature_name().to_string()); } }, diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index b3ed7d4c6beb7..3125fb4d041d2 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1956,11 +1956,12 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to self.enabled_codegen_backends(target).first().unwrap() } - pub fn override_allocator(&self, target: TargetSelection) -> Option { + pub fn override_allocator(&self, target: TargetSelection) -> OverrideAllocator { self.target_config .get(&target) .and_then(|cfg| cfg.override_allocator) .or(self.override_allocator) + .unwrap_or(OverrideAllocator::System) } pub fn rpath_enabled(&self, target: TargetSelection) -> bool { @@ -2056,33 +2057,36 @@ impl AsRef for Config { /// Reconciles the deprecated `jemalloc` boolean option with the new /// `override-allocator` option. /// -/// Emits a warning if `jemalloc` is present and errors out if it is set but -/// `override-allocator` is not `jemalloc`. The allocator is overridden if -/// either option is set. +/// Emits a warning if `jemalloc` is set, and an error if *both* `jemalloc` and `override-allocator` are set. fn reconcile_jemalloc( jemalloc: Option, override_allocator: Option, section: &str, ) -> Option { - if let Some(jemalloc) = jemalloc { - println!( - "WARNING: The `{section}.jemalloc` option is deprecated. \ - Use `{section}.override-allocator` instead.", - ); - if jemalloc && override_allocator.is_some_and(|a| a != OverrideAllocator::Jemalloc) { - panic!( - "ERROR: `{section}.jemalloc` is set but `{section}.override-allocator` is \ - not `jemalloc` ({:?}). Remove the deprecated `jemalloc` option or set \ - `override-allocator = \"jemalloc\"`.", - override_allocator, + match (jemalloc, override_allocator) { + (None, None) => None, + (None, Some(allocator)) => Some(allocator), + (Some(true), None) => { + println!( + "WARNING: The `jemalloc` option is deprecated. \ + Please use `{section}.override-allocator = \"jemalloc\"` instead of `{section}.jemalloc = true`", + ); + Some(OverrideAllocator::Jemalloc) + } + (Some(false), None) => { + println!( + "WARNING: The `jemalloc` option is deprecated. \ + Please use `{section}.override-allocator = \"system\"` instead of `{section}.jemalloc = false`", ); + Some(OverrideAllocator::System) + } + _ => { + panic!( + "ERROR: `{section}.jemalloc` and `{section}.override-allocator` are both set. \ + Please remove the outdated `{section}.jemalloc` directive." + ) } } - override_allocator.or(if jemalloc == Some(true) { - Some(OverrideAllocator::Jemalloc) - } else { - None - }) } fn compute_src_directory(src_dir: Option, exec_ctx: &ExecutionContext) -> Option { diff --git a/src/bootstrap/src/core/config/mod.rs b/src/bootstrap/src/core/config/mod.rs index 8a198a0d9436f..8dafb477c49d7 100644 --- a/src/bootstrap/src/core/config/mod.rs +++ b/src/bootstrap/src/core/config/mod.rs @@ -253,12 +253,18 @@ impl<'de> Deserialize<'de> for CompilerBuiltins { #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum OverrideAllocator { + System, Jemalloc, } impl OverrideAllocator { pub fn feature_name(self) -> &'static str { match self { + OverrideAllocator::System => { + panic!( + "OverrideAllocator::feature_name() should not be called for System allocator" + ) + } OverrideAllocator::Jemalloc => "jemalloc", } } @@ -271,8 +277,9 @@ impl<'de> Deserialize<'de> for OverrideAllocator { { let name = String::deserialize(deserializer)?; match name.as_str() { + "system" => Ok(Self::System), "jemalloc" => Ok(Self::Jemalloc), - other => Err(serde::de::Error::unknown_variant(other, &["jemalloc"])), + other => Err(serde::de::Error::unknown_variant(other, &["system", "jemalloc"])), } } } diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 3babca128d471..c9c26f31a5a31 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -34,7 +34,9 @@ use utils::exec::ExecutionContext; use crate::core::builder; use crate::core::builder::Kind; -use crate::core::config::{BootstrapOverrideLld, DryRun, LlvmLibunwind, TargetSelection, flags}; +use crate::core::config::{ + BootstrapOverrideLld, DryRun, LlvmLibunwind, OverrideAllocator, TargetSelection, flags, +}; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{self, dir_is_empty, exe, libdir, set_file_times, split_debuginfo}; @@ -862,9 +864,8 @@ impl Build { crates.is_empty() || possible_features_by_crates.contains(feature) }; let mut features = vec![]; - if let Some(allocator) = self.config.override_allocator(target) - && check(allocator.feature_name()) - { + let allocator = self.config.override_allocator(target); + if allocator != OverrideAllocator::System && check(allocator.feature_name()) { features.push(allocator.feature_name()); } if (self.config.llvm_enabled(target) || kind == Kind::Check) && check("llvm") { From 21d574833c95b971a79c4bb1a8dd77e416f4a694 Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Wed, 29 Jul 2026 11:06:49 +0100 Subject: [PATCH 02/11] Update documentation about `override-allocator` setting --- bootstrap.example.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstrap.example.toml b/bootstrap.example.toml index a8bab85fda087..98516f3b121e9 100644 --- a/bootstrap.example.toml +++ b/bootstrap.example.toml @@ -866,8 +866,8 @@ #rust.override-allocator = "jemalloc" # Deprecated alias for `rust.override-allocator`. Setting this to `true` is -# equivalent to `rust.override-allocator = "jemalloc"`. If both are set, they -# must agree. +# equivalent to `rust.override-allocator = "jemalloc"`. Both cannot be set in the same section +# (`rust` or `target.[target]`) #rust.jemalloc = false # Run tests in various test suites with the "nll compare mode" in addition to From 45a08827aa5e44149d968d5a6aeda67ff2642934 Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Tue, 28 Jul 2026 20:08:21 +0100 Subject: [PATCH 03/11] Rename `override-allocator` setting to `allocator` as suggested by Kobzol --- INSTALL.md | 2 +- bootstrap.example.toml | 12 ++--- src/bootstrap/src/core/build_steps/compile.rs | 4 +- src/bootstrap/src/core/build_steps/tool.rs | 16 +++---- src/bootstrap/src/core/config/config.rs | 44 +++++++++---------- src/bootstrap/src/core/config/mod.rs | 14 +++--- src/bootstrap/src/core/config/toml/rust.rs | 8 ++-- src/bootstrap/src/core/config/toml/target.rs | 6 +-- src/bootstrap/src/lib.rs | 6 +-- src/ci/citool/tests/jobs.rs | 2 +- src/ci/citool/tests/test-jobs.yml | 4 +- .../dist-aarch64-linux/Dockerfile | 2 +- .../host-x86_64/dist-i686-linux/Dockerfile | 2 +- .../dist-loongarch64-linux/Dockerfile | 2 +- .../dist-loongarch64-musl/Dockerfile | 2 +- .../host-x86_64/dist-x86_64-linux/Dockerfile | 2 +- src/ci/github-actions/jobs.yml | 8 ++-- 17 files changed, 67 insertions(+), 69 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 0e3566af4b051..f075d91acf269 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -96,7 +96,7 @@ See [the rustc-dev-guide for more info][sysllvm]. --set llvm.libzstd=true \ --set llvm.ninja=false \ --set rust.debug-assertions=false \ - --set rust.override-allocator=jemalloc \ + --set rust.allocator=jemalloc \ --set rust.bootstrap-override-lld=true \ --set rust.lto=thin \ --set rust.codegen-units=1 diff --git a/bootstrap.example.toml b/bootstrap.example.toml index 98516f3b121e9..06f30e02edc1d 100644 --- a/bootstrap.example.toml +++ b/bootstrap.example.toml @@ -863,10 +863,10 @@ # This option is only tested on Linux and OSX. It can also be configured per-target in the # [target.] section. # Possible options: "jemalloc" -#rust.override-allocator = "jemalloc" +#rust.allocator = "jemalloc" -# Deprecated alias for `rust.override-allocator`. Setting this to `true` is -# equivalent to `rust.override-allocator = "jemalloc"`. Both cannot be set in the same section +# Deprecated alias for `rust.allocator`. Setting this to `true` is +# equivalent to `rust.allocator = "jemalloc"`. Both cannot be set in the same section # (`rust` or `target.[target]`) #rust.jemalloc = false @@ -1177,10 +1177,10 @@ #optimized-compiler-builtins = build.optimized-compiler-builtins (bool or path) # Link the compiler and LLVM against the specified allocator instead of the default libc allocator. -# This overrides the global `rust.override-allocator` option. See that option for more info. -#override-allocator = rust.override-allocator (string) +# This overrides the global `rust.allocator` option. See that option for more info. +#allocator = rust.allocator (string) -# Deprecated alias for `override-allocator`. See `rust.jemalloc` for more info. +# Deprecated alias for `allocator`. See `rust.jemalloc` for more info. #jemalloc = rust.jemalloc (bool) # The linker configuration that will *override* the default linker used for Linux diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 1aee78e1287fb..570af8256430f 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -28,7 +28,7 @@ use crate::core::builder::{ }; use crate::core::config::toml::target::DefaultLinuxLinkerOverride; use crate::core::config::{ - CompilerBuiltins, DebuginfoLevel, LlvmLibunwind, OverrideAllocator, RustcLto, TargetSelection, + Allocator, CompilerBuiltins, DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection, }; use crate::utils::build_stamp; use crate::utils::build_stamp::BuildStamp; @@ -1392,7 +1392,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS } // See also the "JEMALLOC_SYS_WITH_LG_PAGE" setting in the tool build step. - if builder.config.override_allocator(target) == OverrideAllocator::Jemalloc + if builder.config.allocator(target) == Allocator::Jemalloc && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() { // Build jemalloc on AArch64 with support for page sizes up to 64K diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index e80cbce56e290..514a19282bb91 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -21,7 +21,7 @@ use crate::core::builder::{ Builder, Cargo as CargoCommand, CommandLineStep, RunConfig, ShouldRun, Step, StepMetadata, apply_pgo, cargo_profile_var, }; -use crate::core::config::{DebuginfoLevel, OverrideAllocator, RustcLto, TargetSelection}; +use crate::core::config::{Allocator, DebuginfoLevel, RustcLto, TargetSelection}; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{add_dylib_path, exe, t}; use crate::{Compiler, FileType, Kind, Mode}; @@ -241,7 +241,7 @@ pub fn prepare_tool_cargo( cargo.env("LZMA_API_STATIC", "1"); // See also the "JEMALLOC_SYS_WITH_LG_PAGE" setting in the compile build step. - if builder.config.override_allocator(target) == OverrideAllocator::Jemalloc + if builder.config.allocator(target) == Allocator::Jemalloc && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() { // Build jemalloc on AArch64 with support for page sizes up to 64K @@ -767,8 +767,8 @@ impl CommandLineStep for Rustdoc { // to build rustdoc. // let mut extra_features = Vec::new(); - let allocator = builder.config.override_allocator(target); - if allocator != OverrideAllocator::System { + let allocator = builder.config.allocator(target); + if allocator != Allocator::System { extra_features.push(allocator.feature_name().to_string()); } if !builder.config.rust_debug_logging { @@ -1586,8 +1586,8 @@ tool_rustc_extended!(Clippy { stable: true, add_bins_to_sysroot: ["clippy-driver"], add_features: |builder, target, features| { - let allocator = builder.config.override_allocator(target); - if allocator != OverrideAllocator::System { + let allocator = builder.config.allocator(target); + if allocator != Allocator::System { features.push(allocator.feature_name().to_string()); } } @@ -1598,8 +1598,8 @@ tool_rustc_extended!(Miri { stable: false, add_bins_to_sysroot: ["miri"], add_features: |builder, target, features| { - let allocator = builder.config.override_allocator(target); - if allocator != OverrideAllocator::System { + let allocator = builder.config.allocator(target); + if allocator != Allocator::System { features.push(allocator.feature_name().to_string()); } }, diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 3125fb4d041d2..cfb52657382ff 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -49,8 +49,8 @@ use crate::core::config::toml::target::{ DefaultLinuxLinkerOverride, Target, TomlTarget, default_linux_linker_overrides, }; use crate::core::config::{ - CompilerBuiltins, CompressDebuginfo, DebuggerPath, DebuginfoLevel, DryRun, GccCiMode, - LlvmLibunwind, Merge, OverrideAllocator, ReplaceOpt, RustcLto, SplitDebuginfo, StringOrBool, + Allocator, CompilerBuiltins, CompressDebuginfo, DebuggerPath, DebuginfoLevel, DryRun, + GccCiMode, LlvmLibunwind, Merge, ReplaceOpt, RustcLto, SplitDebuginfo, StringOrBool, threads_from_config, }; use crate::core::download::{ @@ -249,7 +249,7 @@ pub struct Config { pub hosts: Vec, pub targets: Vec, pub local_rebuild: bool, - pub override_allocator: Option, + pub allocator: Option, pub control_flow_guard: bool, pub ehcont_guard: bool, @@ -590,7 +590,7 @@ impl Config { thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit, parallel_frontend_threads: rust_parallel_frontend_threads, remap_debuginfo: rust_remap_debuginfo, - override_allocator: rust_override_allocator, + allocator: rust_allocator, jemalloc: rust_jemalloc, test_compare_mode: rust_test_compare_mode, llvm_libunwind: rust_llvm_libunwind, @@ -970,7 +970,7 @@ impl Config { codegen_backends: target_codegen_backends, runner: target_runner, optimized_compiler_builtins: target_optimized_compiler_builtins, - override_allocator: target_override_allocator, + allocator: target_allocator, jemalloc: target_jemalloc, } = cfg; @@ -1047,9 +1047,9 @@ impl Config { target.rpath = target_rpath; target.rustflags = target_rustflags.unwrap_or_default(); target.optimized_compiler_builtins = target_optimized_compiler_builtins; - target.override_allocator = reconcile_jemalloc( + target.allocator = reconcile_jemalloc( target_jemalloc, - target_override_allocator, + target_allocator, &format!("target.{triple}"), ); if let Some(backends) = target_codegen_backends { @@ -1396,6 +1396,7 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to Config { // tidy-alphabetical-start + allocator: reconcile_jemalloc(rust_jemalloc, rust_allocator, "rust"), android_ndk: build_android_ndk, backtrace: rust_backtrace.unwrap_or(true), backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false), @@ -1521,7 +1522,6 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to on_fail: flags_on_fail, optimized_compiler_builtins, out, - override_allocator: reconcile_jemalloc(rust_jemalloc, rust_override_allocator, "rust"), patch_binaries_for_nix: build_patch_binaries_for_nix, path_modification_cache, paths, @@ -1956,12 +1956,12 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to self.enabled_codegen_backends(target).first().unwrap() } - pub fn override_allocator(&self, target: TargetSelection) -> OverrideAllocator { + pub fn allocator(&self, target: TargetSelection) -> Allocator { self.target_config .get(&target) - .and_then(|cfg| cfg.override_allocator) - .or(self.override_allocator) - .unwrap_or(OverrideAllocator::System) + .and_then(|cfg| cfg.allocator) + .or(self.allocator) + .unwrap_or(Allocator::System) } pub fn rpath_enabled(&self, target: TargetSelection) -> bool { @@ -2055,34 +2055,34 @@ impl AsRef for Config { } /// Reconciles the deprecated `jemalloc` boolean option with the new -/// `override-allocator` option. +/// `allocator` option. /// -/// Emits a warning if `jemalloc` is set, and an error if *both* `jemalloc` and `override-allocator` are set. +/// Emits a warning if `jemalloc` is set, and an error if *both* `jemalloc` and `allocator` are set. fn reconcile_jemalloc( jemalloc: Option, - override_allocator: Option, + allocator: Option, section: &str, -) -> Option { - match (jemalloc, override_allocator) { +) -> Option { + match (jemalloc, allocator) { (None, None) => None, (None, Some(allocator)) => Some(allocator), (Some(true), None) => { println!( "WARNING: The `jemalloc` option is deprecated. \ - Please use `{section}.override-allocator = \"jemalloc\"` instead of `{section}.jemalloc = true`", + Please use `{section}.allocator = \"jemalloc\"` instead of `{section}.jemalloc = true`", ); - Some(OverrideAllocator::Jemalloc) + Some(Allocator::Jemalloc) } (Some(false), None) => { println!( "WARNING: The `jemalloc` option is deprecated. \ - Please use `{section}.override-allocator = \"system\"` instead of `{section}.jemalloc = false`", + Please use `{section}.allocator = \"system\"` instead of `{section}.jemalloc = false`", ); - Some(OverrideAllocator::System) + Some(Allocator::System) } _ => { panic!( - "ERROR: `{section}.jemalloc` and `{section}.override-allocator` are both set. \ + "ERROR: `{section}.jemalloc` and `{section}.allocator` are both set. \ Please remove the outdated `{section}.jemalloc` directive." ) } diff --git a/src/bootstrap/src/core/config/mod.rs b/src/bootstrap/src/core/config/mod.rs index 8dafb477c49d7..740d134059575 100644 --- a/src/bootstrap/src/core/config/mod.rs +++ b/src/bootstrap/src/core/config/mod.rs @@ -252,25 +252,23 @@ impl<'de> Deserialize<'de> for CompilerBuiltins { } #[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum OverrideAllocator { +pub enum Allocator { System, Jemalloc, } -impl OverrideAllocator { +impl Allocator { pub fn feature_name(self) -> &'static str { match self { - OverrideAllocator::System => { - panic!( - "OverrideAllocator::feature_name() should not be called for System allocator" - ) + Allocator::System => { + panic!("Allocator::feature_name() should not be called for System allocator") } - OverrideAllocator::Jemalloc => "jemalloc", + Allocator::Jemalloc => "jemalloc", } } } -impl<'de> Deserialize<'de> for OverrideAllocator { +impl<'de> Deserialize<'de> for Allocator { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index f8f383ef18e73..92446cfcc4089 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer}; use crate::core::config::toml::TomlConfig; use crate::core::config::{ - CompressDebuginfo, DebuginfoLevel, Merge, OverrideAllocator, ReplaceOpt, StringOrBool, + Allocator, CompressDebuginfo, DebuginfoLevel, Merge, ReplaceOpt, StringOrBool, }; use crate::{BTreeSet, CodegenBackendKind, HashSet, PathBuf, TargetSelection, define_config, exit}; @@ -57,7 +57,7 @@ define_config! { verify_llvm_ir: Option = "verify-llvm-ir", thin_lto_import_instr_limit: Option = "thin-lto-import-instr-limit", remap_debuginfo: Option = "remap-debuginfo", - override_allocator: Option = "override-allocator", + allocator: Option = "allocator", // FIXME: Remove this option in Q1 2027 jemalloc: Option = "jemalloc", test_compare_mode: Option = "test-compare-mode", @@ -333,7 +333,7 @@ pub fn check_incompatible_options_for_ci_rustc( stack_protector, strip, jemalloc, - override_allocator, + allocator, rpath, channel, default_linker, @@ -403,7 +403,7 @@ pub fn check_incompatible_options_for_ci_rustc( err!(current_rust_config.llvm_tools, llvm_tools, "rust"); err!(current_rust_config.llvm_bitcode_linker, llvm_bitcode_linker, "rust"); err!(current_rust_config.jemalloc, jemalloc, "rust"); - err!(current_rust_config.override_allocator, override_allocator, "rust"); + err!(current_rust_config.allocator, allocator, "rust"); err!(current_rust_config.default_linker, default_linker, "rust"); err!(current_rust_config.stack_protector, stack_protector, "rust"); err!(current_rust_config.std_features, std_features, "rust"); diff --git a/src/bootstrap/src/core/config/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs index 5f12b1295bc2e..8e354060eceff 100644 --- a/src/bootstrap/src/core/config/toml/target.rs +++ b/src/bootstrap/src/core/config/toml/target.rs @@ -15,7 +15,7 @@ use serde::de::Error; use serde::{Deserialize, Deserializer}; use crate::core::config::{ - CompilerBuiltins, CompressDebuginfo, LlvmLibunwind, Merge, OverrideAllocator, ReplaceOpt, + Allocator, CompilerBuiltins, CompressDebuginfo, LlvmLibunwind, Merge, ReplaceOpt, SplitDebuginfo, StringOrBool, }; use crate::{CodegenBackendKind, HashSet, PathBuf, define_config, exit}; @@ -48,7 +48,7 @@ define_config! { codegen_backends: Option> = "codegen-backends", runner: Option = "runner", optimized_compiler_builtins: Option = "optimized-compiler-builtins", - override_allocator: Option = "override-allocator", + allocator: Option = "allocator", jemalloc: Option = "jemalloc", } } @@ -84,7 +84,7 @@ pub struct Target { pub no_std: bool, pub codegen_backends: Option>, pub optimized_compiler_builtins: Option, - pub override_allocator: Option, + pub allocator: Option, } impl Target { diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index c9c26f31a5a31..9cdd7016046a1 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -35,7 +35,7 @@ use utils::exec::ExecutionContext; use crate::core::builder; use crate::core::builder::Kind; use crate::core::config::{ - BootstrapOverrideLld, DryRun, LlvmLibunwind, OverrideAllocator, TargetSelection, flags, + Allocator, BootstrapOverrideLld, DryRun, LlvmLibunwind, TargetSelection, flags, }; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{self, dir_is_empty, exe, libdir, set_file_times, split_debuginfo}; @@ -864,8 +864,8 @@ impl Build { crates.is_empty() || possible_features_by_crates.contains(feature) }; let mut features = vec![]; - let allocator = self.config.override_allocator(target); - if allocator != OverrideAllocator::System && check(allocator.feature_name()) { + let allocator = self.config.allocator(target); + if allocator != Allocator::System && check(allocator.feature_name()) { features.push(allocator.feature_name()); } if (self.config.llvm_enabled(target) || kind == Kind::Check) && check("llvm") { diff --git a/src/ci/citool/tests/jobs.rs b/src/ci/citool/tests/jobs.rs index 3ab24b353fd76..be80777f4d66b 100644 --- a/src/ci/citool/tests/jobs.rs +++ b/src/ci/citool/tests/jobs.rs @@ -6,7 +6,7 @@ const TEST_JOBS_YML_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/tes fn auto_jobs() { let stdout = get_matrix("push", "commit", "refs/heads/automation/bors/auto"); insta::assert_snapshot!(stdout, @r#" - jobs=[{"name":"aarch64-gnu","full_name":"auto - aarch64-gnu","os":"ubuntu-22.04-arm","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"x86_64-gnu-llvm-18-1","full_name":"auto - x86_64-gnu-llvm-18-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DOCKER_SCRIPT":"stage_2_test_set1.sh","IMAGE":"x86_64-gnu-llvm-18","READ_ONLY_SRC":"0","RUST_BACKTRACE":1,"TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"aarch64-apple","full_name":"auto - aarch64-apple","os":"macos-15","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DEVELOPER_DIR":"/Applications/Xcode_26.2.app/Contents/Developer","MACOSX_DEPLOYMENT_TARGET":11.0,"MACOSX_STD_DEPLOYMENT_TARGET":11.0,"NO_DEBUG_ASSERTIONS":1,"NO_LLVM_ASSERTIONS":1,"NO_OVERFLOW_CHECKS":1,"RUSTC_RETRY_LINKER_ON_SEGFAULT":1,"RUST_CONFIGURE_ARGS":"--enable-sanitizers --enable-profiler --set rust.override-allocator=jemalloc","SCRIPT":"./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin","TOOLSTATE_PUBLISH":1}},{"name":"dist-i686-msvc","full_name":"auto - dist-i686-msvc","os":"windows-2022","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","CODEGEN_BACKENDS":"llvm,cranelift","DEPLOY_BUCKET":"rust-lang-ci2","DIST_REQUIRE_ALL_TOOLS":1,"RUST_CONFIGURE_ARGS":"--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler","SCRIPT":"python x.py dist bootstrap --include-default-paths","TOOLSTATE_PUBLISH":1}},{"name":"pr-check-1","full_name":"auto - pr-check-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"pr-check-2","full_name":"auto - pr-check-2","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"tidy","full_name":"auto - tidy","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true,"doc_url":"https://foo.bar"}] + jobs=[{"name":"aarch64-gnu","full_name":"auto - aarch64-gnu","os":"ubuntu-22.04-arm","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"x86_64-gnu-llvm-18-1","full_name":"auto - x86_64-gnu-llvm-18-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DOCKER_SCRIPT":"stage_2_test_set1.sh","IMAGE":"x86_64-gnu-llvm-18","READ_ONLY_SRC":"0","RUST_BACKTRACE":1,"TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"aarch64-apple","full_name":"auto - aarch64-apple","os":"macos-15","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DEVELOPER_DIR":"/Applications/Xcode_26.2.app/Contents/Developer","MACOSX_DEPLOYMENT_TARGET":11.0,"MACOSX_STD_DEPLOYMENT_TARGET":11.0,"NO_DEBUG_ASSERTIONS":1,"NO_LLVM_ASSERTIONS":1,"NO_OVERFLOW_CHECKS":1,"RUSTC_RETRY_LINKER_ON_SEGFAULT":1,"RUST_CONFIGURE_ARGS":"--enable-sanitizers --enable-profiler --set rust.allocator=jemalloc","SCRIPT":"./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin","TOOLSTATE_PUBLISH":1}},{"name":"dist-i686-msvc","full_name":"auto - dist-i686-msvc","os":"windows-2022","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","CODEGEN_BACKENDS":"llvm,cranelift","DEPLOY_BUCKET":"rust-lang-ci2","DIST_REQUIRE_ALL_TOOLS":1,"RUST_CONFIGURE_ARGS":"--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler","SCRIPT":"python x.py dist bootstrap --include-default-paths","TOOLSTATE_PUBLISH":1}},{"name":"pr-check-1","full_name":"auto - pr-check-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"pr-check-2","full_name":"auto - pr-check-2","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"tidy","full_name":"auto - tidy","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true,"doc_url":"https://foo.bar"}] run_type=auto "#); } diff --git a/src/ci/citool/tests/test-jobs.yml b/src/ci/citool/tests/test-jobs.yml index eb0ef8a9b4c02..109d475c0e1e2 100644 --- a/src/ci/citool/tests/test-jobs.yml +++ b/src/ci/citool/tests/test-jobs.yml @@ -28,7 +28,7 @@ runners: envs: env-x86_64-apple-tests: &env-x86_64-apple-tests SCRIPT: ./x.py check compiletest && ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc-html -- --exact - RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.override-allocator=jemalloc + RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.allocator=jemalloc RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 # Ensure that host tooling is tested on our minimum supported macOS version. MACOSX_DEPLOYMENT_TARGET: 10.12 @@ -110,7 +110,7 @@ auto: RUST_CONFIGURE_ARGS: >- --enable-sanitizers --enable-profiler - --set rust.override-allocator=jemalloc + --set rust.allocator=jemalloc RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else diff --git a/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile b/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile index 684e8cf9051fc..6fc935810ec88 100644 --- a/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile +++ b/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile @@ -89,7 +89,7 @@ ENV RUST_CONFIGURE_ARGS="--build=aarch64-unknown-linux-gnu \ --set llvm.libzstd=true \ --set llvm.ninja=false \ --set rust.debug-assertions=false \ - --set rust.override-allocator=jemalloc \ + --set rust.allocator=jemalloc \ --set rust.bootstrap-override-lld=true \ --set rust.lto=thin \ --set rust.codegen-units=1" diff --git a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile index 88f484d0e8643..da132f1dbade8 100644 --- a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile @@ -76,7 +76,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-full-tools \ --set target.i686-unknown-linux-gnu.linker=clang \ --build=i686-unknown-linux-gnu \ --set llvm.ninja=false \ - --set rust.override-allocator=jemalloc" + --set rust.allocator=jemalloc" ENV SCRIPT="python3 ../x.py dist --build $HOSTS --host $HOSTS --target $HOSTS" ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang diff --git a/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile index f037b6faa563c..04448ce4c4a72 100644 --- a/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile @@ -51,7 +51,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-extended \ --enable-profiler \ --enable-sanitizers \ --disable-docs \ - --set rust.override-allocator=jemalloc \ + --set rust.allocator=jemalloc \ --set rust.lto=thin \ --set rust.codegen-units=1" diff --git a/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile b/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile index 2b77249c494c8..b1da97d2dd34d 100644 --- a/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile @@ -33,7 +33,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-extended \ --enable-profiler \ --enable-sanitizers \ --disable-docs \ - --set rust.override-allocator=jemalloc \ + --set rust.allocator=jemalloc \ --set rust.lto=thin \ --set rust.codegen-units=1 \ --set target.loongarch64-unknown-linux-musl.crt-static=false \ diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile index 2fa936056233f..b3f51cfe816db 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile @@ -90,7 +90,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-full-tools \ --set llvm.thin-lto=true \ --set llvm.ninja=false \ --set llvm.libzstd=true \ - --set rust.override-allocator=jemalloc \ + --set rust.allocator=jemalloc \ --set rust.bootstrap-override-lld=true \ --set rust.lto=thin \ --set rust.codegen-units=1" diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index e6e3c1acd853b..cbff1be9d2af5 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -497,7 +497,7 @@ auto: --enable-sanitizers --enable-profiler --disable-docs - --set rust.override-allocator=jemalloc + --set rust.allocator=jemalloc --set llvm.link-shared=true --set rust.lto=thin --set rust.codegen-units=1 @@ -532,7 +532,7 @@ auto: RUST_CONFIGURE_ARGS: >- --enable-sanitizers --enable-profiler - --set rust.override-allocator=jemalloc + --set rust.allocator=jemalloc --set target.aarch64-apple-ios-macabi.sanitizers=false --set target.x86_64-apple-ios-macabi.sanitizers=false --set target.aarch64-apple-tvos.profiler=false @@ -557,7 +557,7 @@ auto: --enable-full-tools --enable-sanitizers --enable-profiler - --set rust.override-allocator=jemalloc + --set rust.allocator=jemalloc --set llvm.link-shared=true --set rust.lto=thin --set rust.codegen-units=1 @@ -578,7 +578,7 @@ auto: RUST_CONFIGURE_ARGS: >- --enable-sanitizers --enable-profiler - --set rust.override-allocator=jemalloc + --set rust.allocator=jemalloc DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else # supports the hardware, so only need to test it there. From 7bfabd97cbd3a16ee454161918a815a92bd0b913 Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Wed, 29 Jul 2026 11:18:17 +0100 Subject: [PATCH 04/11] Rename `rust.allocator` setting to `build.allocator` --- INSTALL.md | 2 +- bootstrap.example.toml | 20 +++++++++---------- src/bootstrap/src/core/config/config.rs | 16 ++++++++------- src/bootstrap/src/core/config/toml/build.rs | 3 ++- src/bootstrap/src/core/config/toml/rust.rs | 7 +------ src/ci/citool/tests/jobs.rs | 2 +- src/ci/citool/tests/test-jobs.yml | 4 ++-- .../dist-aarch64-linux/Dockerfile | 2 +- .../host-x86_64/dist-i686-linux/Dockerfile | 2 +- .../dist-loongarch64-linux/Dockerfile | 2 +- .../dist-loongarch64-musl/Dockerfile | 2 +- .../host-x86_64/dist-x86_64-linux/Dockerfile | 2 +- src/ci/github-actions/jobs.yml | 8 ++++---- 13 files changed, 35 insertions(+), 37 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index f075d91acf269..066422a57eb09 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -96,7 +96,7 @@ See [the rustc-dev-guide for more info][sysllvm]. --set llvm.libzstd=true \ --set llvm.ninja=false \ --set rust.debug-assertions=false \ - --set rust.allocator=jemalloc \ + --set build.allocator=jemalloc \ --set rust.bootstrap-override-lld=true \ --set rust.lto=thin \ --set rust.codegen-units=1 diff --git a/bootstrap.example.toml b/bootstrap.example.toml index 06f30e02edc1d..4da9a7bd28859 100644 --- a/bootstrap.example.toml +++ b/bootstrap.example.toml @@ -544,6 +544,12 @@ # For example, exclude = ["tests/ui", "src/tools/tidy"]. #build.exclude = [] +# Link the compiler and LLVM against the specified allocator instead of the default libc allocator. +# This option is only tested on Linux and OSX. It can also be configured per-target in the +# [target.] section. +# Possible options: "jemalloc" +#build.allocator = "jemalloc" + # ============================================================================= # General install configuration options # ============================================================================= @@ -859,14 +865,8 @@ # Useful for reproducible builds. Generally only set for releases #rust.remap-debuginfo = false -# Link the compiler and LLVM against the specified allocator instead of the default libc allocator. -# This option is only tested on Linux and OSX. It can also be configured per-target in the -# [target.] section. -# Possible options: "jemalloc" -#rust.allocator = "jemalloc" - -# Deprecated alias for `rust.allocator`. Setting this to `true` is -# equivalent to `rust.allocator = "jemalloc"`. Both cannot be set in the same section +# Deprecated alias for `build.allocator`. Setting this to `true` is +# equivalent to `build.allocator = "jemalloc"`. Both cannot be set in the same section # (`rust` or `target.[target]`) #rust.jemalloc = false @@ -1177,8 +1177,8 @@ #optimized-compiler-builtins = build.optimized-compiler-builtins (bool or path) # Link the compiler and LLVM against the specified allocator instead of the default libc allocator. -# This overrides the global `rust.allocator` option. See that option for more info. -#allocator = rust.allocator (string) +# This overrides the global `build.allocator` option. See that option for more info. +#allocator = build.allocator (string) # Deprecated alias for `allocator`. See `rust.jemalloc` for more info. #jemalloc = rust.jemalloc (bool) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index cfb52657382ff..81a425fba1cab 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -538,6 +538,7 @@ impl Config { exclude: build_exclude, compiletest_allow_stage0: build_compiletest_allow_stage0, sde: build_sde, + allocator: build_allocator, } = toml_build.unwrap_or_default(); let Install { @@ -590,7 +591,6 @@ impl Config { thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit, parallel_frontend_threads: rust_parallel_frontend_threads, remap_debuginfo: rust_remap_debuginfo, - allocator: rust_allocator, jemalloc: rust_jemalloc, test_compare_mode: rust_test_compare_mode, llvm_libunwind: rust_llvm_libunwind, @@ -1051,6 +1051,7 @@ impl Config { target_jemalloc, target_allocator, &format!("target.{triple}"), + &format!("target.{triple}"), ); if let Some(backends) = target_codegen_backends { target.codegen_backends = @@ -1396,7 +1397,7 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to Config { // tidy-alphabetical-start - allocator: reconcile_jemalloc(rust_jemalloc, rust_allocator, "rust"), + allocator: reconcile_jemalloc(rust_jemalloc, build_allocator, "rust", "build"), android_ndk: build_android_ndk, backtrace: rust_backtrace.unwrap_or(true), backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false), @@ -2061,7 +2062,8 @@ impl AsRef for Config { fn reconcile_jemalloc( jemalloc: Option, allocator: Option, - section: &str, + jemalloc_section: &str, + allocator_section: &str, ) -> Option { match (jemalloc, allocator) { (None, None) => None, @@ -2069,21 +2071,21 @@ fn reconcile_jemalloc( (Some(true), None) => { println!( "WARNING: The `jemalloc` option is deprecated. \ - Please use `{section}.allocator = \"jemalloc\"` instead of `{section}.jemalloc = true`", + Please use `{allocator_section}.allocator = \"jemalloc\"` instead of `{jemalloc_section}.jemalloc = true`", ); Some(Allocator::Jemalloc) } (Some(false), None) => { println!( "WARNING: The `jemalloc` option is deprecated. \ - Please use `{section}.allocator = \"system\"` instead of `{section}.jemalloc = false`", + Please use `{allocator_section}.allocator = \"system\"` instead of `{jemalloc_section}.jemalloc = false`", ); Some(Allocator::System) } _ => { panic!( - "ERROR: `{section}.jemalloc` and `{section}.allocator` are both set. \ - Please remove the outdated `{section}.jemalloc` directive." + "ERROR: `{jemalloc_section}.jemalloc` and `{allocator_section}.allocator` are both set. \ + Please remove the outdated `{jemalloc_section}.jemalloc` directive." ) } } diff --git a/src/bootstrap/src/core/config/toml/build.rs b/src/bootstrap/src/core/config/toml/build.rs index 666bb229e8af8..265dde78e08eb 100644 --- a/src/bootstrap/src/core/config/toml/build.rs +++ b/src/bootstrap/src/core/config/toml/build.rs @@ -11,7 +11,7 @@ use std::collections::HashMap; use serde::{Deserialize, Deserializer}; use crate::core::config::toml::ReplaceOpt; -use crate::core::config::{CompilerBuiltins, DebuggerPath, Merge, StringOrBool}; +use crate::core::config::{Allocator, CompilerBuiltins, DebuggerPath, Merge, StringOrBool}; use crate::{HashSet, PathBuf, define_config, exit}; define_config! { @@ -77,6 +77,7 @@ define_config! { exclude: Option> = "exclude", record_failed_tests_path: Option = "record_failed_tests_path", sde: Option = "sde", + allocator: Option = "allocator", } } diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index 92446cfcc4089..2fba87a0d16f8 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -5,9 +5,7 @@ use build_helper::ci::CiEnv; use serde::{Deserialize, Deserializer}; use crate::core::config::toml::TomlConfig; -use crate::core::config::{ - Allocator, CompressDebuginfo, DebuginfoLevel, Merge, ReplaceOpt, StringOrBool, -}; +use crate::core::config::{CompressDebuginfo, DebuginfoLevel, Merge, ReplaceOpt, StringOrBool}; use crate::{BTreeSet, CodegenBackendKind, HashSet, PathBuf, TargetSelection, define_config, exit}; define_config! { @@ -57,7 +55,6 @@ define_config! { verify_llvm_ir: Option = "verify-llvm-ir", thin_lto_import_instr_limit: Option = "thin-lto-import-instr-limit", remap_debuginfo: Option = "remap-debuginfo", - allocator: Option = "allocator", // FIXME: Remove this option in Q1 2027 jemalloc: Option = "jemalloc", test_compare_mode: Option = "test-compare-mode", @@ -333,7 +330,6 @@ pub fn check_incompatible_options_for_ci_rustc( stack_protector, strip, jemalloc, - allocator, rpath, channel, default_linker, @@ -403,7 +399,6 @@ pub fn check_incompatible_options_for_ci_rustc( err!(current_rust_config.llvm_tools, llvm_tools, "rust"); err!(current_rust_config.llvm_bitcode_linker, llvm_bitcode_linker, "rust"); err!(current_rust_config.jemalloc, jemalloc, "rust"); - err!(current_rust_config.allocator, allocator, "rust"); err!(current_rust_config.default_linker, default_linker, "rust"); err!(current_rust_config.stack_protector, stack_protector, "rust"); err!(current_rust_config.std_features, std_features, "rust"); diff --git a/src/ci/citool/tests/jobs.rs b/src/ci/citool/tests/jobs.rs index be80777f4d66b..683c76f52e9ea 100644 --- a/src/ci/citool/tests/jobs.rs +++ b/src/ci/citool/tests/jobs.rs @@ -6,7 +6,7 @@ const TEST_JOBS_YML_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/tes fn auto_jobs() { let stdout = get_matrix("push", "commit", "refs/heads/automation/bors/auto"); insta::assert_snapshot!(stdout, @r#" - jobs=[{"name":"aarch64-gnu","full_name":"auto - aarch64-gnu","os":"ubuntu-22.04-arm","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"x86_64-gnu-llvm-18-1","full_name":"auto - x86_64-gnu-llvm-18-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DOCKER_SCRIPT":"stage_2_test_set1.sh","IMAGE":"x86_64-gnu-llvm-18","READ_ONLY_SRC":"0","RUST_BACKTRACE":1,"TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"aarch64-apple","full_name":"auto - aarch64-apple","os":"macos-15","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DEVELOPER_DIR":"/Applications/Xcode_26.2.app/Contents/Developer","MACOSX_DEPLOYMENT_TARGET":11.0,"MACOSX_STD_DEPLOYMENT_TARGET":11.0,"NO_DEBUG_ASSERTIONS":1,"NO_LLVM_ASSERTIONS":1,"NO_OVERFLOW_CHECKS":1,"RUSTC_RETRY_LINKER_ON_SEGFAULT":1,"RUST_CONFIGURE_ARGS":"--enable-sanitizers --enable-profiler --set rust.allocator=jemalloc","SCRIPT":"./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin","TOOLSTATE_PUBLISH":1}},{"name":"dist-i686-msvc","full_name":"auto - dist-i686-msvc","os":"windows-2022","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","CODEGEN_BACKENDS":"llvm,cranelift","DEPLOY_BUCKET":"rust-lang-ci2","DIST_REQUIRE_ALL_TOOLS":1,"RUST_CONFIGURE_ARGS":"--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler","SCRIPT":"python x.py dist bootstrap --include-default-paths","TOOLSTATE_PUBLISH":1}},{"name":"pr-check-1","full_name":"auto - pr-check-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"pr-check-2","full_name":"auto - pr-check-2","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"tidy","full_name":"auto - tidy","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true,"doc_url":"https://foo.bar"}] + jobs=[{"name":"aarch64-gnu","full_name":"auto - aarch64-gnu","os":"ubuntu-22.04-arm","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"x86_64-gnu-llvm-18-1","full_name":"auto - x86_64-gnu-llvm-18-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DOCKER_SCRIPT":"stage_2_test_set1.sh","IMAGE":"x86_64-gnu-llvm-18","READ_ONLY_SRC":"0","RUST_BACKTRACE":1,"TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"aarch64-apple","full_name":"auto - aarch64-apple","os":"macos-15","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DEVELOPER_DIR":"/Applications/Xcode_26.2.app/Contents/Developer","MACOSX_DEPLOYMENT_TARGET":11.0,"MACOSX_STD_DEPLOYMENT_TARGET":11.0,"NO_DEBUG_ASSERTIONS":1,"NO_LLVM_ASSERTIONS":1,"NO_OVERFLOW_CHECKS":1,"RUSTC_RETRY_LINKER_ON_SEGFAULT":1,"RUST_CONFIGURE_ARGS":"--enable-sanitizers --enable-profiler --set build.allocator=jemalloc","SCRIPT":"./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin","TOOLSTATE_PUBLISH":1}},{"name":"dist-i686-msvc","full_name":"auto - dist-i686-msvc","os":"windows-2022","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","CODEGEN_BACKENDS":"llvm,cranelift","DEPLOY_BUCKET":"rust-lang-ci2","DIST_REQUIRE_ALL_TOOLS":1,"RUST_CONFIGURE_ARGS":"--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler","SCRIPT":"python x.py dist bootstrap --include-default-paths","TOOLSTATE_PUBLISH":1}},{"name":"pr-check-1","full_name":"auto - pr-check-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"pr-check-2","full_name":"auto - pr-check-2","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"tidy","full_name":"auto - tidy","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true,"doc_url":"https://foo.bar"}] run_type=auto "#); } diff --git a/src/ci/citool/tests/test-jobs.yml b/src/ci/citool/tests/test-jobs.yml index 109d475c0e1e2..4a249cb1e92b5 100644 --- a/src/ci/citool/tests/test-jobs.yml +++ b/src/ci/citool/tests/test-jobs.yml @@ -28,7 +28,7 @@ runners: envs: env-x86_64-apple-tests: &env-x86_64-apple-tests SCRIPT: ./x.py check compiletest && ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc-html -- --exact - RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.allocator=jemalloc + RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set build.allocator=jemalloc RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 # Ensure that host tooling is tested on our minimum supported macOS version. MACOSX_DEPLOYMENT_TARGET: 10.12 @@ -110,7 +110,7 @@ auto: RUST_CONFIGURE_ARGS: >- --enable-sanitizers --enable-profiler - --set rust.allocator=jemalloc + --set build.allocator=jemalloc RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else diff --git a/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile b/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile index 6fc935810ec88..1e205aa72a450 100644 --- a/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile +++ b/src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile @@ -89,7 +89,7 @@ ENV RUST_CONFIGURE_ARGS="--build=aarch64-unknown-linux-gnu \ --set llvm.libzstd=true \ --set llvm.ninja=false \ --set rust.debug-assertions=false \ - --set rust.allocator=jemalloc \ + --set build.allocator=jemalloc \ --set rust.bootstrap-override-lld=true \ --set rust.lto=thin \ --set rust.codegen-units=1" diff --git a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile index da132f1dbade8..63b12ad646a25 100644 --- a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile @@ -76,7 +76,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-full-tools \ --set target.i686-unknown-linux-gnu.linker=clang \ --build=i686-unknown-linux-gnu \ --set llvm.ninja=false \ - --set rust.allocator=jemalloc" + --set build.allocator=jemalloc" ENV SCRIPT="python3 ../x.py dist --build $HOSTS --host $HOSTS --target $HOSTS" ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang diff --git a/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile index 04448ce4c4a72..f60167b94d071 100644 --- a/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile @@ -51,7 +51,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-extended \ --enable-profiler \ --enable-sanitizers \ --disable-docs \ - --set rust.allocator=jemalloc \ + --set build.allocator=jemalloc \ --set rust.lto=thin \ --set rust.codegen-units=1" diff --git a/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile b/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile index b1da97d2dd34d..8fdfe7f78b100 100644 --- a/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile @@ -33,7 +33,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-extended \ --enable-profiler \ --enable-sanitizers \ --disable-docs \ - --set rust.allocator=jemalloc \ + --set build.allocator=jemalloc \ --set rust.lto=thin \ --set rust.codegen-units=1 \ --set target.loongarch64-unknown-linux-musl.crt-static=false \ diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile index b3f51cfe816db..2db64b8f5c7c1 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile @@ -90,7 +90,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-full-tools \ --set llvm.thin-lto=true \ --set llvm.ninja=false \ --set llvm.libzstd=true \ - --set rust.allocator=jemalloc \ + --set build.allocator=jemalloc \ --set rust.bootstrap-override-lld=true \ --set rust.lto=thin \ --set rust.codegen-units=1" diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index cbff1be9d2af5..9b76b7a6cb628 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -497,7 +497,7 @@ auto: --enable-sanitizers --enable-profiler --disable-docs - --set rust.allocator=jemalloc + --set build.allocator=jemalloc --set llvm.link-shared=true --set rust.lto=thin --set rust.codegen-units=1 @@ -532,7 +532,7 @@ auto: RUST_CONFIGURE_ARGS: >- --enable-sanitizers --enable-profiler - --set rust.allocator=jemalloc + --set build.allocator=jemalloc --set target.aarch64-apple-ios-macabi.sanitizers=false --set target.x86_64-apple-ios-macabi.sanitizers=false --set target.aarch64-apple-tvos.profiler=false @@ -557,7 +557,7 @@ auto: --enable-full-tools --enable-sanitizers --enable-profiler - --set rust.allocator=jemalloc + --set build.allocator=jemalloc --set llvm.link-shared=true --set rust.lto=thin --set rust.codegen-units=1 @@ -578,7 +578,7 @@ auto: RUST_CONFIGURE_ARGS: >- --enable-sanitizers --enable-profiler - --set rust.allocator=jemalloc + --set build.allocator=jemalloc DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else # supports the hardware, so only need to test it there. From b3ea12f1e9d746273a54b1c313b7b6688ddc3ef8 Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Wed, 29 Jul 2026 11:31:10 +0100 Subject: [PATCH 05/11] Add `override-allocator` changes to change tracker --- src/bootstrap/src/utils/change_tracker.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 8892832037ee2..9abd8c2519ba3 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -661,6 +661,11 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Warning, summary: "Obsolete option `build.compiletest-use-stage0-libtest` has no effect and has been removed.", }, + ChangeInfo { + change_id: 160100, + severity: ChangeSeverity::Warning, + summary: "The `override-allocator` option has been renamed: The global setting is now `build.allocator` and the per-target setting is `target..allocator`. It can now be set to 'system' to explicitly request the system allocator.", + }, ChangeInfo { change_id: 160142, severity: ChangeSeverity::Warning, From 10b0ec6290ba1a39d5f01bf60d86567ef41c8dd5 Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Wed, 29 Jul 2026 12:16:36 +0100 Subject: [PATCH 06/11] Fix list of options for `build.allocator` in bootstrap.example.toml --- bootstrap.example.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.example.toml b/bootstrap.example.toml index 4da9a7bd28859..3251b0870774d 100644 --- a/bootstrap.example.toml +++ b/bootstrap.example.toml @@ -547,7 +547,7 @@ # Link the compiler and LLVM against the specified allocator instead of the default libc allocator. # This option is only tested on Linux and OSX. It can also be configured per-target in the # [target.] section. -# Possible options: "jemalloc" +# Possible options: "system" (default), "jemalloc" #build.allocator = "jemalloc" # ============================================================================= From 91d43b498d2d88802fc5900cf55e93fe7e32a078 Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Thu, 30 Jul 2026 13:40:30 +0100 Subject: [PATCH 07/11] Return Option<&str> from Allocator::feature_name() --- src/bootstrap/src/core/build_steps/tool.rs | 15 ++++++--------- src/bootstrap/src/core/config/mod.rs | 8 +++----- src/bootstrap/src/lib.rs | 12 ++++++------ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 514a19282bb91..1941566e2a0a2 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -767,9 +767,8 @@ impl CommandLineStep for Rustdoc { // to build rustdoc. // let mut extra_features = Vec::new(); - let allocator = builder.config.allocator(target); - if allocator != Allocator::System { - extra_features.push(allocator.feature_name().to_string()); + if let Some(allocator_feature_name) = builder.config.allocator(target).feature_name() { + extra_features.push(allocator_feature_name.to_string()); } if !builder.config.rust_debug_logging { extra_features.push("max_level_info".to_string()) @@ -1586,9 +1585,8 @@ tool_rustc_extended!(Clippy { stable: true, add_bins_to_sysroot: ["clippy-driver"], add_features: |builder, target, features| { - let allocator = builder.config.allocator(target); - if allocator != Allocator::System { - features.push(allocator.feature_name().to_string()); + if let Some(allocator_feature_name) = builder.config.allocator(target).feature_name() { + features.push(allocator_feature_name.to_string()); } } }); @@ -1598,9 +1596,8 @@ tool_rustc_extended!(Miri { stable: false, add_bins_to_sysroot: ["miri"], add_features: |builder, target, features| { - let allocator = builder.config.allocator(target); - if allocator != Allocator::System { - features.push(allocator.feature_name().to_string()); + if let Some(allocator_feature_name) = builder.config.allocator(target).feature_name() { + features.push(allocator_feature_name.to_string()); } }, // Always compile also tests when building miri. Otherwise feature unification can cause rebuilds between building and testing miri. diff --git a/src/bootstrap/src/core/config/mod.rs b/src/bootstrap/src/core/config/mod.rs index 740d134059575..6a3ab55f71aad 100644 --- a/src/bootstrap/src/core/config/mod.rs +++ b/src/bootstrap/src/core/config/mod.rs @@ -258,12 +258,10 @@ pub enum Allocator { } impl Allocator { - pub fn feature_name(self) -> &'static str { + pub fn feature_name(self) -> Option<&'static str> { match self { - Allocator::System => { - panic!("Allocator::feature_name() should not be called for System allocator") - } - Allocator::Jemalloc => "jemalloc", + Allocator::System => None, + Allocator::Jemalloc => Some("jemalloc"), } } } diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 9cdd7016046a1..7d119247b3bac 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -34,9 +34,7 @@ use utils::exec::ExecutionContext; use crate::core::builder; use crate::core::builder::Kind; -use crate::core::config::{ - Allocator, BootstrapOverrideLld, DryRun, LlvmLibunwind, TargetSelection, flags, -}; +use crate::core::config::{BootstrapOverrideLld, DryRun, LlvmLibunwind, TargetSelection, flags}; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{self, dir_is_empty, exe, libdir, set_file_times, split_debuginfo}; @@ -864,9 +862,11 @@ impl Build { crates.is_empty() || possible_features_by_crates.contains(feature) }; let mut features = vec![]; - let allocator = self.config.allocator(target); - if allocator != Allocator::System && check(allocator.feature_name()) { - features.push(allocator.feature_name()); + + if let Some(allocator_feature_name) = self.config.allocator(target).feature_name() + && check(allocator_feature_name) + { + features.push(allocator_feature_name); } if (self.config.llvm_enabled(target) || kind == Kind::Check) && check("llvm") { features.push("llvm"); From 17b48c388f96b9e8a64158f333dc60ae2b324a60 Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Thu, 30 Jul 2026 13:56:39 +0100 Subject: [PATCH 08/11] Check `allocator` and `jemalloc` settings when deciding whether we can download rustc from CI --- src/bootstrap/src/core/config/toml/rust.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index 2fba87a0d16f8..2080764a21207 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -294,6 +294,10 @@ pub fn check_incompatible_options_for_ci_rustc( ci_config_toml.build.as_ref().and_then(|b| b.optimized_compiler_builtins.clone()); err!(current_optimized_compiler_builtins, optimized_compiler_builtins, "build"); + let current_allocator = current_config_toml.build.as_ref().and_then(|b| b.allocator); + let allocator = ci_config_toml.build.as_ref().and_then(|b| b.allocator); + err!(current_allocator, allocator, "build"); + // We always build the in-tree compiler on cross targets, so we only care // about the host target here. let host_str = host.to_string(); @@ -310,6 +314,9 @@ pub fn check_incompatible_options_for_ci_rustc( let optimized_compiler_builtins = &ci_cfg.optimized_compiler_builtins; err!(current_cfg.optimized_compiler_builtins, optimized_compiler_builtins, "build"); + + err!(current_cfg.allocator, &ci_cfg.allocator, "build"); + err!(current_cfg.jemalloc, &ci_cfg.jemalloc, "build"); } let (Some(current_rust_config), Some(ci_rust_config)) = From dc5fca07dff906e7ab7765fa6e253457d8a25792 Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Thu, 30 Jul 2026 14:00:53 +0100 Subject: [PATCH 09/11] Fix warning message when local config and CI config differ in the `build.` section --- src/bootstrap/src/core/config/toml/rust.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index 2080764a21207..c8a8db28c773a 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -310,13 +310,17 @@ pub fn check_incompatible_options_for_ci_rustc( ))?; let profiler = &ci_cfg.profiler; - err!(current_cfg.profiler, profiler, "build"); + err!(current_cfg.profiler, profiler, format!("target.{host_str}")); let optimized_compiler_builtins = &ci_cfg.optimized_compiler_builtins; - err!(current_cfg.optimized_compiler_builtins, optimized_compiler_builtins, "build"); - - err!(current_cfg.allocator, &ci_cfg.allocator, "build"); - err!(current_cfg.jemalloc, &ci_cfg.jemalloc, "build"); + err!( + current_cfg.optimized_compiler_builtins, + optimized_compiler_builtins, + format!("target.{host_str}") + ); + + err!(current_cfg.allocator, &ci_cfg.allocator, format!("target.{host_str}")); + err!(current_cfg.jemalloc, &ci_cfg.jemalloc, format!("target.{host_str}")); } let (Some(current_rust_config), Some(ci_rust_config)) = From 0ca10495041b6518bfa87d56e4c12730e9dea28b Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Thu, 30 Jul 2026 14:03:10 +0100 Subject: [PATCH 10/11] Update download-ci-llvm-stamp --- src/bootstrap/download-ci-llvm-stamp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/download-ci-llvm-stamp b/src/bootstrap/download-ci-llvm-stamp index ba6dcfc761c5a..2ebc3066f1fac 100644 --- a/src/bootstrap/download-ci-llvm-stamp +++ b/src/bootstrap/download-ci-llvm-stamp @@ -1,4 +1,4 @@ Change this file to make users of the `download-ci-llvm` configuration download a new version of LLVM from CI, even if the LLVM submodule hasn’t changed. -Last change is for: https://github.com/rust-lang/rust/pull/158766 +Last change is for: https://github.com/rust-lang/rust/pull/160100 From 9dd4861800f743e7961f7eb749cc556050ea1cab Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Fri, 31 Jul 2026 10:44:40 +0100 Subject: [PATCH 11/11] Move ChangeInfo to the right place --- src/bootstrap/src/utils/change_tracker.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 9abd8c2519ba3..25c0963aa4191 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -662,13 +662,13 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ summary: "Obsolete option `build.compiletest-use-stage0-libtest` has no effect and has been removed.", }, ChangeInfo { - change_id: 160100, + change_id: 160142, severity: ChangeSeverity::Warning, - summary: "The `override-allocator` option has been renamed: The global setting is now `build.allocator` and the per-target setting is `target..allocator`. It can now be set to 'system' to explicitly request the system allocator.", + summary: "The `rust.use-lld` option has been removed. Use `rust.bootstrap-override-lld` instead.", }, ChangeInfo { - change_id: 160142, + change_id: 160100, severity: ChangeSeverity::Warning, - summary: "The `rust.use-lld` option has been removed. Use `rust.bootstrap-override-lld` instead.", + summary: "The `override-allocator` option has been renamed: The global setting is now `build.allocator` and the per-target setting is `target..allocator`. It can now be set to 'system' to explicitly request the system allocator.", }, ];