diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-02-17 17:06:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-17 17:06:13 +0100 |
| commit | 10cc816cef0819140efb75d2cd8024c2510ca445 (patch) | |
| tree | 4bfd3a4b6f3f2a3ae110db8f99ce5dcafa419de4 /src/bootstrap | |
| parent | 8d72b7cb42dff4355b14e7f67a25e61e5edd888a (diff) | |
| parent | a71de77ae9459e4f05ceb8695fce793b0ac00319 (diff) | |
| download | rust-10cc816cef0819140efb75d2cd8024c2510ca445.tar.gz rust-10cc816cef0819140efb75d2cd8024c2510ca445.zip | |
Rollup merge of #137170 - ferrocene:pa-target-jemalloc, r=Kobzol
Allow configuring jemalloc per target In Ferrocene we're trying to switch from `./configure` to a predefined `config.toml` file. One of the limitations of doing that is the `rust.jemalloc` configuration option, which we need to conditionally disable based on the target. This PR adds a `target.$tuple.jemalloc` option to override `rust.jemalloc` to make that possible.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/core/build_steps/compile.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/tool.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/core/config/config.rs | 10 | ||||
| -rw-r--r-- | src/bootstrap/src/lib.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/change_tracker.rs | 5 |
5 files changed, 18 insertions, 3 deletions
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index c62c36390ea..aa08dd7e424 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1341,7 +1341,7 @@ pub fn rustc_cargo_env( // Build jemalloc on AArch64 with support for page sizes up to 64K // See: https://github.com/rust-lang/rust/pull/135081 - if builder.config.jemalloc + if builder.config.jemalloc(target) && target.starts_with("aarch64") && env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none() { diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index a54db9d7815..75bfff34086 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -654,7 +654,7 @@ impl Step for Rustdoc { // to build rustdoc. // let mut features = Vec::new(); - if builder.config.jemalloc { + if builder.config.jemalloc(target) { features.push("jemalloc".to_string()); } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index d27a8b155df..64a510240f8 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -325,6 +325,9 @@ pub struct Config { pub hosts: Vec<TargetSelection>, pub targets: Vec<TargetSelection>, pub local_rebuild: bool, + #[cfg(not(test))] + jemalloc: bool, + #[cfg(test)] pub jemalloc: bool, pub control_flow_guard: bool, pub ehcont_guard: bool, @@ -643,6 +646,7 @@ pub struct Target { pub no_std: bool, pub codegen_backends: Option<Vec<String>>, pub optimized_compiler_builtins: Option<bool>, + pub jemalloc: Option<bool>, } impl Target { @@ -1234,6 +1238,7 @@ define_config! { codegen_backends: Option<Vec<String>> = "codegen-backends", runner: Option<String> = "runner", optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins", + jemalloc: Option<bool> = "jemalloc", } } @@ -2161,6 +2166,7 @@ impl Config { target.profiler = cfg.profiler; target.rpath = cfg.rpath; target.optimized_compiler_builtins = cfg.optimized_compiler_builtins; + target.jemalloc = cfg.jemalloc; if let Some(ref backends) = cfg.codegen_backends { let available_backends = ["llvm", "cranelift", "gcc"]; @@ -2726,6 +2732,10 @@ impl Config { .unwrap_or(&self.rust_codegen_backends) } + pub fn jemalloc(&self, target: TargetSelection) -> bool { + self.target_config.get(&target).and_then(|cfg| cfg.jemalloc).unwrap_or(self.jemalloc) + } + pub fn default_codegen_backend(&self, target: TargetSelection) -> Option<String> { self.codegen_backends(target).first().cloned() } diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index a1ec13aeaa3..dfaf0418d9a 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -688,7 +688,7 @@ impl Build { crates.is_empty() || possible_features_by_crates.contains(feature) }; let mut features = vec![]; - if self.config.jemalloc && check("jemalloc") { + if self.config.jemalloc(target) && check("jemalloc") { features.push("jemalloc"); } if (self.config.llvm_enabled(target) || kind == Kind::Check) && check("llvm") { diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 9b23cf1843e..f215c3f6d0b 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -350,4 +350,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Info, summary: "The llvm.ccache option has moved to build.ccache. llvm.ccache is now deprecated.", }, + ChangeInfo { + change_id: 137170, + severity: ChangeSeverity::Info, + summary: "It is now possible to configure `jemalloc` for each target", + }, ]; |
