Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix handling the default config for profiler and sanitizers #79155

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 {
Expand Down