Skip to content

Commit 6c718b5

Browse files
committed
Refactor rustc-perf building
1 parent 11f9283 commit 6c718b5

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/tools/opt-dist/src/environment.rs

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub struct Environment {
1717
host_llvm_dir: Utf8PathBuf,
1818
/// List of test paths that should be skipped when testing the optimized artifacts.
1919
skipped_tests: Vec<String>,
20+
/// Directory containing a pre-built rustc-perf checkout.
21+
prebuilt_rustc_perf: Option<Utf8PathBuf>,
2022
use_bolt: bool,
2123
shared_llvm: bool,
2224
}
@@ -67,6 +69,10 @@ impl Environment {
6769
.join(format!("rustc{}", executable_extension()))
6870
}
6971

72+
pub fn prebuilt_rustc_perf(&self) -> Option<Utf8PathBuf> {
73+
self.prebuilt_rustc_perf.clone()
74+
}
75+
7076
/// Path to the built rustc-perf benchmark suite.
7177
pub fn rustc_perf_dir(&self) -> Utf8PathBuf {
7278
self.artifact_dir.join("rustc-perf")

src/tools/opt-dist/src/main.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
121121
.use_bolt(use_bolt)
122122
.skipped_tests(skipped_tests)
123123
.build()?;
124-
with_log_group("Building rustc-perf", || {
125-
Ok::<(), anyhow::Error>(download_rustc_perf(&env)?)
126-
})?;
127124

128125
(env, shared.build_args)
129126
}
@@ -139,17 +136,15 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
139136
.host_llvm_dir(Utf8PathBuf::from("/rustroot"))
140137
.artifact_dir(Utf8PathBuf::from("/tmp/tmp-multistage/opt-artifacts"))
141138
.build_dir(checkout_dir.join("obj"))
139+
// /tmp/rustc-perf comes from the x64 dist Dockerfile
140+
.prebuilt_rustc_perf(Some(Utf8PathBuf::from("/tmp/rustc-perf")))
142141
.shared_llvm(true)
143142
.use_bolt(true)
144143
.skipped_tests(vec![
145144
// Fails because of linker errors, as of June 2023.
146145
"tests/ui/process/nofile-limit.rs".to_string(),
147146
])
148147
.build()?;
149-
// /tmp/rustc-perf comes from the x64 dist Dockerfile
150-
with_log_group("Building rustc-perf", || {
151-
Ok::<(), anyhow::Error>(copy_rustc_perf(&env, Utf8Path::new("/tmp/rustc-perf"))?)
152-
})?;
153148

154149
(env, shared.build_args)
155150
}
@@ -173,10 +168,6 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
173168
])
174169
.build()?;
175170

176-
with_log_group("Building rustc-perf", || {
177-
Ok::<(), anyhow::Error>(download_rustc_perf(&env)?)
178-
})?;
179-
180171
(env, shared.build_args)
181172
}
182173
};
@@ -190,6 +181,11 @@ fn execute_pipeline(
190181
) -> anyhow::Result<()> {
191182
reset_directory(&env.artifact_dir())?;
192183

184+
with_log_group("Building rustc-perf", || match env.prebuilt_rustc_perf() {
185+
Some(dir) => copy_rustc_perf(env, &dir),
186+
None => download_rustc_perf(env),
187+
})?;
188+
193189
// Stage 1: Build PGO instrumented rustc
194190
// We use a normal build of LLVM, because gathering PGO profiles for LLVM and `rustc` at the
195191
// same time can cause issues, because the host and in-tree LLVM versions can diverge.

0 commit comments

Comments
 (0)