Skip to content

Commit 8d3a40a

Browse files
committed
opt-dist: rebuild rustc when doing static LLVM builds
when building LLVM it's obvious that in case of shared build rustc doesn't need to be recompiled, but with static builds it would be better to compile rustc again to ensure we linked proper library. maybe I didn't understand the pipeline correctly, but it was strange for me to see that in Stage 5 LLVM is built while rustc is not
1 parent d2baa49 commit 8d3a40a

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ impl Bootstrap {
185185
self
186186
}
187187

188+
/// In case of statically linked rustc rebuild it to ensure that proper one is linked
189+
pub fn rustc_rebuild(mut self) -> Self {
190+
self.cmd = self.cmd.arg("--keep-stage").arg("0").arg("--keep-stage-std").arg("1");
191+
self
192+
}
193+
188194
pub fn run(self, timer: &mut TimerSection) -> anyhow::Result<()> {
189195
self.cmd.run()?;
190196
let metrics = load_metrics(&self.metrics_path)?;

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,15 @@ fn execute_pipeline(
262262
let llvm_profile_dir_root = env.artifact_dir().join("llvm-pgo");
263263

264264
stage.section("Build PGO instrumented LLVM", |section| {
265-
Bootstrap::build(env)
266-
.llvm_pgo_instrument(&llvm_profile_dir_root)
267-
.avoid_rustc_rebuild()
268-
.run(section)
265+
let mut build = Bootstrap::build(env).llvm_pgo_instrument(&llvm_profile_dir_root);
266+
267+
build = if env.supports_shared_llvm() {
268+
build.avoid_rustc_rebuild()
269+
} else {
270+
build.rustc_rebuild()
271+
};
272+
273+
build.run(section)
269274
})?;
270275

271276
let profile = stage
@@ -343,8 +348,10 @@ fn execute_pipeline(
343348

344349
let mut dist = Bootstrap::dist(env, &dist_args)
345350
.llvm_pgo_optimize(&llvm_pgo_profile)
346-
.rustc_pgo_optimize(&rustc_pgo_profile)
347-
.avoid_rustc_rebuild();
351+
.rustc_pgo_optimize(&rustc_pgo_profile);
352+
353+
dist =
354+
if env.supports_shared_llvm() { dist.avoid_rustc_rebuild() } else { dist.rustc_rebuild() };
348355

349356
for bolt_profile in bolt_profiles {
350357
dist = dist.with_bolt_profile(bolt_profile);

0 commit comments

Comments
 (0)