Try to build LLVM without LTO

This commit is contained in:
Jakub Beránek 2023-07-16 10:44:32 +02:00 committed by Jakub Beránek
parent ffb9b61294
commit 9c373e3e5b
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
5 changed files with 31 additions and 1 deletions

View file

@ -41,6 +41,10 @@ impl Environment for LinuxEnvironment {
true
}
fn supports_shared_llvm(&self) -> bool {
true
}
fn executable_extension(&self) -> &'static str {
""
}

View file

@ -60,6 +60,8 @@ pub trait Environment {
fn supports_bolt(&self) -> bool;
fn supports_shared_llvm(&self) -> bool;
/// What is the extension of binary executables in this environment?
fn executable_extension(&self) -> &'static str;

View file

@ -65,6 +65,10 @@ impl Environment for WindowsEnvironment {
false
}
fn supports_shared_llvm(&self) -> bool {
false
}
fn executable_extension(&self) -> &'static str {
".exe"
}

View file

@ -139,6 +139,16 @@ impl Bootstrap {
self
}
pub fn without_llvm_lto(mut self) -> Self {
self.cmd = self
.cmd
.arg("--set")
.arg("llvm.thin-lto=false")
.arg("--set")
.arg("llvm.link-shared=true");
self
}
pub fn rustc_pgo_optimize(mut self, profile: &RustcPGOProfile) -> Self {
self.cmd = self.cmd.arg("--rust-profile-use").arg(profile.0.as_str());
self

View file

@ -38,7 +38,17 @@ fn execute_pipeline(
let rustc_profile_dir_root = env.opt_artifacts().join("rustc-pgo");
stage.section("Build PGO instrumented rustc and LLVM", |section| {
Bootstrap::build(env).rustc_pgo_instrument(&rustc_profile_dir_root).run(section)
let mut builder = Bootstrap::build(env).rustc_pgo_instrument(&rustc_profile_dir_root);
if env.supports_shared_llvm() {
// This first LLVM that we build will be thrown away after this stage, and it
// doesn't really need LTO. Without LTO, it builds in ~1 minute thanks to sccache,
// with LTO it takes almost 10 minutes. It makes the followup Rustc PGO
// instrumented/optimized build a bit slower, but it seems to be worth it.
builder = builder.without_llvm_lto();
}
builder.run(section)
})?;
let profile = stage