From 6c718b5b8a98ba756c69e8a2019131c6a514e64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Wed, 13 Sep 2023 18:11:34 +0200 Subject: [PATCH] Refactor rustc-perf building --- src/tools/opt-dist/src/environment.rs | 6 ++++++ src/tools/opt-dist/src/main.rs | 18 +++++++----------- 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, + /// Directory containing a pre-built rustc-perf checkout. + prebuilt_rustc_perf: Option, use_bolt: bool, shared_llvm: bool, } @@ -67,6 +69,10 @@ impl Environment { .join(format!("rustc{}", executable_extension())) } + pub fn prebuilt_rustc_perf(&self) -> Option { + 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)> .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)> .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)> "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)> ]) .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.