Skip to content

Commit 6e00231

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 1079c5e commit 6e00231

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ impl Bootstrap {
189189
self
190190
}
191191

192+
/// Rebuild rustc in case of statically linked LLVM
193+
pub fn rustc_rebuild(mut self) -> Self {
194+
self.cmd = self.cmd.arg("--keep-stage").arg("0");
195+
self
196+
}
197+
192198
pub fn run(self, timer: &mut TimerSection) -> anyhow::Result<()> {
193199
self.cmd.run()?;
194200
let metrics = load_metrics(&self.metrics_path)?;

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,14 @@ fn execute_pipeline(
363363

364364
let mut dist = Bootstrap::dist(env, &dist_args)
365365
.llvm_pgo_optimize(llvm_pgo_profile.as_ref())
366-
.rustc_pgo_optimize(&rustc_pgo_profile)
367-
.avoid_rustc_rebuild();
366+
.rustc_pgo_optimize(&rustc_pgo_profile);
367+
368+
// if LLVM is not built we'll have PGO optimized rustc
369+
dist = if env.supports_shared_llvm() || !env.build_llvm() {
370+
dist.avoid_rustc_rebuild()
371+
} else {
372+
dist.rustc_rebuild()
373+
};
368374

369375
for bolt_profile in bolt_profiles {
370376
dist = dist.with_bolt_profile(bolt_profile);

0 commit comments

Comments
 (0)