From 36972b0d63ad4af65bb7bef6a05df4e1c726fbf0 Mon Sep 17 00:00:00 2001 From: 12101111 Date: Wed, 18 Nov 2020 10:33:07 +0800 Subject: [PATCH] fix handling the default config for profiler and sanitizers --- src/bootstrap/config.rs | 16 ++++++++-------- 1 file 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, pub linker: Option, pub ndk: Option, - pub sanitizers: bool, - pub profiler: bool, + pub sanitizers: Option, + pub profiler: Option, pub crt_static: Option, pub musl_root: Option, pub musl_libdir: Option, @@ -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 {