about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-08-13 20:22:36 +0000
committerbors <bors@rust-lang.org>2023-08-13 20:22:36 +0000
commit1b198b3a196442e14fb06978166ab46a4618d131 (patch)
tree80397ea664eddc1c886a8e7f2e30fafa4b8ef511 /src
parentebbd7154a713a282e4b39da5107cdae2bf2efcb4 (diff)
parentbe6cda1eca4d15f22cc983cf2ae5e4b72e5e6ea8 (diff)
downloadrust-1b198b3a196442e14fb06978166ab46a4618d131.tar.gz
rust-1b198b3a196442e14fb06978166ab46a4618d131.zip
Auto merge of #114786 - GuillaumeGomez:rollup-0cos5gn, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #94667 (Add `Iterator::map_windows`)
 - #114069 (Allow using external builds of the compiler-rt profile lib)
 - #114354 (coverage: Store BCB counter info externally, not directly in the BCB graph)
 - #114625 (CI: use smaller machines in PR runs)
 - #114777 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/compile.rs4
-rw-r--r--src/bootstrap/config.rs30
-rw-r--r--src/ci/github-actions/ci.yml4
3 files changed, 30 insertions, 8 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 5517246c209..9c68e5a78d8 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -325,6 +325,10 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
         cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
     }
 
+    if let Some(path) = builder.config.profiler_path(target) {
+        cargo.env("LLVM_PROFILER_RT_LIB", path);
+    }
+
     // Determine if we're going to compile in optimized C intrinsics to
     // the `compiler-builtins` crate. These intrinsics live in LLVM's
     // `compiler-rt` repository, but our `src/llvm-project` submodule isn't
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 830c1a3b846..4821d20a898 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -534,7 +534,7 @@ pub struct Target {
     pub linker: Option<PathBuf>,
     pub ndk: Option<PathBuf>,
     pub sanitizers: Option<bool>,
-    pub profiler: Option<bool>,
+    pub profiler: Option<StringOrBool>,
     pub rpath: Option<bool>,
     pub crt_static: Option<bool>,
     pub musl_root: Option<PathBuf>,
@@ -863,9 +863,9 @@ define_config! {
     }
 }
 
-#[derive(Debug, Deserialize)]
+#[derive(Clone, Debug, Deserialize)]
 #[serde(untagged)]
-enum StringOrBool {
+pub enum StringOrBool {
     String(String),
     Bool(bool),
 }
@@ -876,6 +876,12 @@ impl Default for StringOrBool {
     }
 }
 
+impl StringOrBool {
+    fn is_string_or_true(&self) -> bool {
+        matches!(self, Self::String(_) | Self::Bool(true))
+    }
+}
+
 #[derive(Clone, Debug, PartialEq, Eq)]
 pub enum RustOptimize {
     String(String),
@@ -1038,7 +1044,7 @@ define_config! {
         llvm_libunwind: Option<String> = "llvm-libunwind",
         android_ndk: Option<String> = "android-ndk",
         sanitizers: Option<bool> = "sanitizers",
-        profiler: Option<bool> = "profiler",
+        profiler: Option<StringOrBool> = "profiler",
         rpath: Option<bool> = "rpath",
         crt_static: Option<bool> = "crt-static",
         musl_root: Option<String> = "musl-root",
@@ -1957,12 +1963,24 @@ impl Config {
         self.target_config.values().any(|t| t.sanitizers == Some(true)) || self.sanitizers
     }
 
+    pub fn profiler_path(&self, target: TargetSelection) -> Option<&str> {
+        match self.target_config.get(&target)?.profiler.as_ref()? {
+            StringOrBool::String(s) => Some(s),
+            StringOrBool::Bool(_) => None,
+        }
+    }
+
     pub fn profiler_enabled(&self, target: TargetSelection) -> bool {
-        self.target_config.get(&target).map(|t| t.profiler).flatten().unwrap_or(self.profiler)
+        self.target_config
+            .get(&target)
+            .and_then(|t| t.profiler.as_ref())
+            .map(StringOrBool::is_string_or_true)
+            .unwrap_or(self.profiler)
     }
 
     pub fn any_profiler_enabled(&self) -> bool {
-        self.target_config.values().any(|t| t.profiler == Some(true)) || self.profiler
+        self.target_config.values().any(|t| matches!(&t.profiler, Some(p) if p.is_string_or_true()))
+            || self.profiler
     }
 
     pub fn rpath_enabled(&self, target: TargetSelection) -> bool {
diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml
index f900a5eb576..2cc0bfd9db9 100644
--- a/src/ci/github-actions/ci.yml
+++ b/src/ci/github-actions/ci.yml
@@ -316,10 +316,10 @@ jobs:
       matrix:
         include:
           - name: mingw-check
-            <<: *job-linux-16c
+            <<: *job-linux-4c
 
           - name: mingw-check-tidy
-            <<: *job-linux-16c
+            <<: *job-linux-4c
 
           - name: x86_64-gnu-llvm-15
             <<: *job-linux-16c