1
Fork 0

Refactor rustc-perf building

This commit is contained in:
Jakub Beránek 2023-09-13 18:11:34 +02:00
parent 11f9283da9
commit 6c718b5b8a
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
2 changed files with 13 additions and 11 deletions

View file

@ -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")

View file

@ -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.