Skip to content

Commit 3b857a5

Browse files
authored
Rollup merge of rust-lang#79155 - 12101111:fix-profiler-config, r=Mark-Simulacrum
fix handling the default config for profiler and sanitizers rust-lang#78354 don't handle the case that user don't add any target-specific config in `[target.*]` of `config.toml`: ```toml changelog-seen = 2 [llvm] link-shared = true [build] sanitizers = true profiler = true [install] [rust] [dist] ``` The previes code handle the default config in `Config::prase()`: ```rust target.sanitizers = cfg.sanitizers.unwrap_or(build.sanitizers.unwrap_or_default()); target.profiler = cfg.profiler.unwrap_or(build.profiler.unwrap_or_default()); config.target_config.insert(TargetSelection::from_user(&triple), target); ``` In this case, `toml.target` don't contain any target, so the above code won't execute. Instead, a default `Target` is insert in https://github.com/rust-lang/rust/blob/c919f490bbcd2b29b74016101f7ec71aaa24bdbb/src/bootstrap/sanity.rs#L162-L166 The default value for `bool` is false, hence the issue in rust-lang#79124 This fix change the type of `sanitizers` and `profiler` to `Option<bool>`, so the default value is `None`, and fallback config is handled in `Config::sanitizers_enabled` and `Config::profiler_enabled` fix rust-lang#79124 cc `@Mark-Simulacrum` `@richkadel`
2 parents 5c7d530 + 36972b0 commit 3b857a5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/bootstrap/config.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ pub struct Target {
280280
pub ranlib: Option<PathBuf>,
281281
pub linker: Option<PathBuf>,
282282
pub ndk: Option<PathBuf>,
283-
pub sanitizers: bool,
284-
pub profiler: bool,
283+
pub sanitizers: Option<bool>,
284+
pub profiler: Option<bool>,
285285
pub crt_static: Option<bool>,
286286
pub musl_root: Option<PathBuf>,
287287
pub musl_libdir: Option<PathBuf>,
@@ -896,8 +896,8 @@ impl Config {
896896
target.musl_libdir = cfg.musl_libdir.map(PathBuf::from);
897897
target.wasi_root = cfg.wasi_root.map(PathBuf::from);
898898
target.qemu_rootfs = cfg.qemu_rootfs.map(PathBuf::from);
899-
target.sanitizers = cfg.sanitizers.unwrap_or(build.sanitizers.unwrap_or_default());
900-
target.profiler = cfg.profiler.unwrap_or(build.profiler.unwrap_or_default());
899+
target.sanitizers = cfg.sanitizers;
900+
target.profiler = cfg.profiler;
901901

902902
config.target_config.insert(TargetSelection::from_user(&triple), target);
903903
}
@@ -1008,19 +1008,19 @@ impl Config {
10081008
}
10091009

10101010
pub fn sanitizers_enabled(&self, target: TargetSelection) -> bool {
1011-
self.target_config.get(&target).map(|t| t.sanitizers).unwrap_or(self.sanitizers)
1011+
self.target_config.get(&target).map(|t| t.sanitizers).flatten().unwrap_or(self.sanitizers)
10121012
}
10131013

10141014
pub fn any_sanitizers_enabled(&self) -> bool {
1015-
self.target_config.values().any(|t| t.sanitizers) || self.sanitizers
1015+
self.target_config.values().any(|t| t.sanitizers == Some(true)) || self.sanitizers
10161016
}
10171017

10181018
pub fn profiler_enabled(&self, target: TargetSelection) -> bool {
1019-
self.target_config.get(&target).map(|t| t.profiler).unwrap_or(self.profiler)
1019+
self.target_config.get(&target).map(|t| t.profiler).flatten().unwrap_or(self.profiler)
10201020
}
10211021

10221022
pub fn any_profiler_enabled(&self) -> bool {
1023-
self.target_config.values().any(|t| t.profiler) || self.profiler
1023+
self.target_config.values().any(|t| t.profiler == Some(true)) || self.profiler
10241024
}
10251025

10261026
pub fn llvm_enabled(&self) -> bool {

0 commit comments

Comments
 (0)