about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2023-09-13 18:11:34 +0200
committerJakub Beránek <berykubik@gmail.com>2023-09-13 18:11:34 +0200
commit6c718b5b8a98ba756c69e8a2019131c6a514e64d (patch)
tree89b43a1304ed95dd505fa7708fd394705d1e0296
parent11f9283da91ca4ab7fb634f3f586156f699007c4 (diff)
downloadrust-6c718b5b8a98ba756c69e8a2019131c6a514e64d.tar.gz
rust-6c718b5b8a98ba756c69e8a2019131c6a514e64d.zip
Refactor rustc-perf building
-rw-r--r--src/tools/opt-dist/src/environment.rs6
-rw-r--r--src/tools/opt-dist/src/main.rs18
2 files changed, 13 insertions, 11 deletions
diff --git a/src/tools/opt-dist/src/environment.rs b/src/tools/opt-dist/src/environment.rs
index ed43f469c5e..f7b5c176375 100644
--- a/src/tools/opt-dist/src/environment.rs
+++ b/src/tools/opt-dist/src/environment.rs
@@ -17,6 +17,8 @@ pub struct Environment {
     host_llvm_dir: Utf8PathBuf,
     /// List of test paths that should be skipped when testing the optimized artifacts.
     skipped_tests: Vec<String>,
+    /// Directory containing a pre-built rustc-perf checkout.
+    prebuilt_rustc_perf: Option<Utf8PathBuf>,
     use_bolt: bool,
     shared_llvm: bool,
 }
@@ -67,6 +69,10 @@ impl Environment {
             .join(format!("rustc{}", executable_extension()))
     }
 
+    pub fn prebuilt_rustc_perf(&self) -> Option<Utf8PathBuf> {
+        self.prebuilt_rustc_perf.clone()
+    }
+
     /// Path to the built rustc-perf benchmark suite.
     pub fn rustc_perf_dir(&self) -> Utf8PathBuf {
         self.artifact_dir.join("rustc-perf")
diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs
index b5e123360f8..978e2dfa4e8 100644
--- a/src/tools/opt-dist/src/main.rs
+++ b/src/tools/opt-dist/src/main.rs
@@ -121,9 +121,6 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
                 .use_bolt(use_bolt)
                 .skipped_tests(skipped_tests)
                 .build()?;
-            with_log_group("Building rustc-perf", || {
-                Ok::<(), anyhow::Error>(download_rustc_perf(&env)?)
-            })?;
 
             (env, shared.build_args)
         }
@@ -139,6 +136,8 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
                 .host_llvm_dir(Utf8PathBuf::from("/rustroot"))
                 .artifact_dir(Utf8PathBuf::from("/tmp/tmp-multistage/opt-artifacts"))
                 .build_dir(checkout_dir.join("obj"))
+                // /tmp/rustc-perf comes from the x64 dist Dockerfile
+                .prebuilt_rustc_perf(Some(Utf8PathBuf::from("/tmp/rustc-perf")))
                 .shared_llvm(true)
                 .use_bolt(true)
                 .skipped_tests(vec![
@@ -146,10 +145,6 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
                     "tests/ui/process/nofile-limit.rs".to_string(),
                 ])
                 .build()?;
-            // /tmp/rustc-perf comes from the x64 dist Dockerfile
-            with_log_group("Building rustc-perf", || {
-                Ok::<(), anyhow::Error>(copy_rustc_perf(&env, Utf8Path::new("/tmp/rustc-perf"))?)
-            })?;
 
             (env, shared.build_args)
         }
@@ -173,10 +168,6 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
                 ])
                 .build()?;
 
-            with_log_group("Building rustc-perf", || {
-                Ok::<(), anyhow::Error>(download_rustc_perf(&env)?)
-            })?;
-
             (env, shared.build_args)
         }
     };
@@ -190,6 +181,11 @@ fn execute_pipeline(
 ) -> anyhow::Result<()> {
     reset_directory(&env.artifact_dir())?;
 
+    with_log_group("Building rustc-perf", || match env.prebuilt_rustc_perf() {
+        Some(dir) => copy_rustc_perf(env, &dir),
+        None => download_rustc_perf(env),
+    })?;
+
     // Stage 1: Build PGO instrumented rustc
     // We use a normal build of LLVM, because gathering PGO profiles for LLVM and `rustc` at the
     // same time can cause issues, because the host and in-tree LLVM versions can diverge.