diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-11-19 16:26:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-19 16:26:40 +0100 |
| commit | 3b857a5a3aa49b3ec1f69ad0e62812e7ae26d7b9 (patch) | |
| tree | 77813221e7ff6906dd35514e4545cf733f8ba46e | |
| parent | 5c7d530b5ec520073f7388519f39033a7b342eef (diff) | |
| parent | 36972b0d63ad4af65bb7bef6a05df4e1c726fbf0 (diff) | |
| download | rust-3b857a5a3aa49b3ec1f69ad0e62812e7ae26d7b9.tar.gz rust-3b857a5a3aa49b3ec1f69ad0e62812e7ae26d7b9.zip | |
Rollup merge of #79155 - 12101111:fix-profiler-config, r=Mark-Simulacrum
fix handling the default config for profiler and sanitizers #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 #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 #79124 cc `@Mark-Simulacrum` `@richkadel`
| -rw-r--r-- | src/bootstrap/config.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 94319a6d1e9..2c2efaa9eb4 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -280,8 +280,8 @@ pub struct Target { pub ranlib: Option<PathBuf>, pub linker: Option<PathBuf>, pub ndk: Option<PathBuf>, - pub sanitizers: bool, - pub profiler: bool, + pub sanitizers: Option<bool>, + pub profiler: Option<bool>, pub crt_static: Option<bool>, pub musl_root: Option<PathBuf>, pub musl_libdir: Option<PathBuf>, @@ -896,8 +896,8 @@ impl Config { target.musl_libdir = cfg.musl_libdir.map(PathBuf::from); target.wasi_root = cfg.wasi_root.map(PathBuf::from); target.qemu_rootfs = cfg.qemu_rootfs.map(PathBuf::from); - target.sanitizers = cfg.sanitizers.unwrap_or(build.sanitizers.unwrap_or_default()); - target.profiler = cfg.profiler.unwrap_or(build.profiler.unwrap_or_default()); + target.sanitizers = cfg.sanitizers; + target.profiler = cfg.profiler; config.target_config.insert(TargetSelection::from_user(&triple), target); } @@ -1008,19 +1008,19 @@ impl Config { } pub fn sanitizers_enabled(&self, target: TargetSelection) -> bool { - self.target_config.get(&target).map(|t| t.sanitizers).unwrap_or(self.sanitizers) + self.target_config.get(&target).map(|t| t.sanitizers).flatten().unwrap_or(self.sanitizers) } pub fn any_sanitizers_enabled(&self) -> bool { - self.target_config.values().any(|t| t.sanitizers) || self.sanitizers + self.target_config.values().any(|t| t.sanitizers == Some(true)) || self.sanitizers } pub fn profiler_enabled(&self, target: TargetSelection) -> bool { - self.target_config.get(&target).map(|t| t.profiler).unwrap_or(self.profiler) + self.target_config.get(&target).map(|t| t.profiler).flatten().unwrap_or(self.profiler) } pub fn any_profiler_enabled(&self) -> bool { - self.target_config.values().any(|t| t.profiler) || self.profiler + self.target_config.values().any(|t| t.profiler == Some(true)) || self.profiler } pub fn llvm_enabled(&self) -> bool { |
