Skip to content

Commit 238be98

Browse files
committed
Don't rebuild LLVM for bolt optimization
1 parent a64ef7d commit 238be98

File tree

8 files changed

+61
-370
lines changed

8 files changed

+61
-370
lines changed

src/bootstrap/bolt.rs

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/bootstrap/config.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ pub struct Config {
172172
pub llvm_profile_use: Option<String>,
173173
pub llvm_profile_generate: bool,
174174
pub llvm_libunwind_default: Option<LlvmLibunwind>,
175-
pub llvm_bolt_profile_generate: bool,
176-
pub llvm_bolt_profile_use: Option<String>,
177175

178176
pub build: TargetSelection,
179177
pub hosts: Vec<TargetSelection>,
@@ -869,15 +867,6 @@ impl Config {
869867
}
870868
config.llvm_profile_use = flags.llvm_profile_use;
871869
config.llvm_profile_generate = flags.llvm_profile_generate;
872-
config.llvm_bolt_profile_generate = flags.llvm_bolt_profile_generate;
873-
config.llvm_bolt_profile_use = flags.llvm_bolt_profile_use;
874-
875-
if config.llvm_bolt_profile_generate && config.llvm_bolt_profile_use.is_some() {
876-
eprintln!(
877-
"Cannot use both `llvm_bolt_profile_generate` and `llvm_bolt_profile_use` at the same time"
878-
);
879-
crate::detail_exit(1);
880-
}
881870

882871
// Infer the rest of the configuration.
883872

src/bootstrap/dist.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,10 +2220,6 @@ impl Step for ReproducibleArtifacts {
22202220
tarball.add_file(path, ".", 0o644);
22212221
added_anything = true;
22222222
}
2223-
if let Some(path) = builder.config.llvm_bolt_profile_use.as_ref() {
2224-
tarball.add_file(path, ".", 0o644);
2225-
added_anything = true;
2226-
}
22272223
if added_anything { Some(tarball.generate()) } else { None }
22282224
}
22292225
}

src/bootstrap/flags.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ pub struct Flags {
7878
//
7979
// llvm_out/build/profiles/ is the location this writes to.
8080
pub llvm_profile_generate: bool,
81-
pub llvm_bolt_profile_generate: bool,
82-
pub llvm_bolt_profile_use: Option<String>,
8381
}
8482

8583
#[derive(Debug)]
@@ -259,8 +257,6 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
259257
opts.optmulti("D", "", "deny certain clippy lints", "OPT");
260258
opts.optmulti("W", "", "warn about certain clippy lints", "OPT");
261259
opts.optmulti("F", "", "forbid certain clippy lints", "OPT");
262-
opts.optflag("", "llvm-bolt-profile-generate", "generate BOLT profile for LLVM build");
263-
opts.optopt("", "llvm-bolt-profile-use", "use BOLT profile for LLVM build", "PROFILE");
264260

265261
// We can't use getopt to parse the options until we have completed specifying which
266262
// options are valid, but under the current implementation, some options are conditional on
@@ -704,8 +700,6 @@ Arguments:
704700
rust_profile_generate: matches.opt_str("rust-profile-generate"),
705701
llvm_profile_use: matches.opt_str("llvm-profile-use"),
706702
llvm_profile_generate: matches.opt_present("llvm-profile-generate"),
707-
llvm_bolt_profile_generate: matches.opt_present("llvm-bolt-profile-generate"),
708-
llvm_bolt_profile_use: matches.opt_str("llvm-bolt-profile-use"),
709703
}
710704
}
711705
}

src/bootstrap/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ use crate::util::{
125125
exe, libdir, mtime, output, run, run_suppressed, symlink_dir, try_run_suppressed,
126126
};
127127

128-
mod bolt;
129128
mod builder;
130129
mod cache;
131130
mod cc_detect;

src/bootstrap/native.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::io;
1616
use std::path::{Path, PathBuf};
1717
use std::process::Command;
1818

19-
use crate::bolt::{instrument_with_bolt_inplace, optimize_library_with_bolt_inplace};
2019
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
2120
use crate::channel;
2221
use crate::config::{Config, TargetSelection};
@@ -345,12 +344,6 @@ impl Step for Llvm {
345344
if let Some(path) = builder.config.llvm_profile_use.as_ref() {
346345
cfg.define("LLVM_PROFDATA_FILE", &path);
347346
}
348-
if builder.config.llvm_bolt_profile_generate
349-
|| builder.config.llvm_bolt_profile_use.is_some()
350-
{
351-
// Relocations are required for BOLT to work.
352-
ldflags.push_all("-Wl,-q");
353-
}
354347

355348
// Disable zstd to avoid a dependency on libzstd.so.
356349
cfg.define("LLVM_ENABLE_ZSTD", "OFF");
@@ -520,34 +513,12 @@ impl Step for Llvm {
520513
}
521514
}
522515

523-
// After LLVM is built, we modify (instrument or optimize) the libLLVM.so library file
524-
// in place. This is fine, because currently we do not support incrementally rebuilding
525-
// LLVM after a configuration change, so to rebuild it the build files have to be removed,
526-
// which will also remove these modified files.
527-
if builder.config.llvm_bolt_profile_generate {
528-
instrument_with_bolt_inplace(&get_built_llvm_lib_path(&res.llvm_config));
529-
}
530-
if let Some(path) = &builder.config.llvm_bolt_profile_use {
531-
optimize_library_with_bolt_inplace(
532-
&get_built_llvm_lib_path(&res.llvm_config),
533-
&Path::new(path),
534-
);
535-
}
536-
537516
t!(stamp.write());
538517

539518
res
540519
}
541520
}
542521

543-
/// Returns path to a built LLVM library (libLLVM.so).
544-
/// Assumes that we have built LLVM into a single library file.
545-
fn get_built_llvm_lib_path(llvm_config_path: &Path) -> PathBuf {
546-
let mut cmd = Command::new(llvm_config_path);
547-
cmd.arg("--libfiles");
548-
PathBuf::from(output(&mut cmd).trim())
549-
}
550-
551522
fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
552523
if !builder.config.llvm_version_check {
553524
return;

0 commit comments

Comments
 (0)