Rollup merge of #78354 - 12101111:rustbuild_profiler, r=Mark-Simulacrum

Support enable/disable sanitizers/profiler per target

This PR add options under `[target.*]` of `config.toml` which can enable or disable sanitizers/profiler runtime for corresponding target.
If these options are empty, the global options under `[build]` will take effect.

Fix #78329
This commit is contained in:
Jonas Schievink
2020-11-11 20:58:56 +01:00
committed by GitHub
9 changed files with 55 additions and 17 deletions

View File

@@ -541,7 +541,7 @@ impl Build {
/// Gets the space-separated set of activated features for the standard
/// library.
fn std_features(&self) -> String {
fn std_features(&self, target: TargetSelection) -> String {
let mut features = "panic-unwind".to_string();
match self.config.llvm_libunwind.unwrap_or_default() {
@@ -552,7 +552,7 @@ impl Build {
if self.config.backtrace {
features.push_str(" backtrace");
}
if self.config.profiler {
if self.config.profiler_enabled(target) {
features.push_str(" profiler");
}
features
@@ -1115,7 +1115,7 @@ impl Build {
/// Returns a Vec of all the dependencies of the given root crate,
/// including transitive dependencies and the root itself. Only includes
/// "local" crates (those in the local source tree, not from a registry).
fn in_tree_crates(&self, root: &str) -> Vec<&Crate> {
fn in_tree_crates(&self, root: &str, target: Option<TargetSelection>) -> Vec<&Crate> {
let mut ret = Vec::new();
let mut list = vec![INTERNER.intern_str(root)];
let mut visited = HashSet::new();
@@ -1136,7 +1136,10 @@ impl Build {
// metadata::build.
if visited.insert(dep)
&& dep != "build_helper"
&& (dep != "profiler_builtins" || self.config.profiler)
&& (dep != "profiler_builtins"
|| target
.map(|t| self.config.profiler_enabled(t))
.unwrap_or(self.config.any_profiler_enabled()))
&& (dep != "rustc_codegen_llvm" || self.config.llvm_enabled())
{
list.push(*dep);