Skip to content

Commit ef50c49

Browse files
Use absolute path to llvm-bolt rather than PATH
This unconditionally uses the provided LLVM toolchain's BOLT. I'm not sure that makes sense, but since we don't build BOLT as part of Rust's build of LLVM today, it's probably the right option for now. This avoids breaking the build on not being able to find the llvm-bolt executable.
1 parent e95db59 commit ef50c49

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::utils::io::copy_file;
99
/// Instruments an artifact at the given `path` (in-place) with BOLT and then calls `func`.
1010
/// After this function finishes, the original file will be restored.
1111
pub fn with_bolt_instrumented<F: FnOnce(&Utf8Path) -> anyhow::Result<R>, R>(
12+
env: &Environment,
1213
path: &Utf8Path,
1314
func: F,
1415
) -> anyhow::Result<R> {
@@ -26,7 +27,7 @@ pub fn with_bolt_instrumented<F: FnOnce(&Utf8Path) -> anyhow::Result<R>, R>(
2627
let profile_prefix = Utf8Path::from_path(&profile_prefix).unwrap();
2728

2829
// Instrument the original file with BOLT, saving the result into `instrumented_path`
29-
cmd(&["llvm-bolt"])
30+
cmd(&[env.llvm_bolt().as_str()])
3031
.arg("-instrument")
3132
.arg(path)
3233
.arg(&format!("--instrumentation-file={profile_prefix}"))
@@ -61,7 +62,7 @@ pub fn bolt_optimize(
6162
let split_strategy =
6263
if env.host_tuple().starts_with("aarch64") { "profile2" } else { "cdsplit" };
6364

64-
cmd(&["llvm-bolt"])
65+
cmd(&[env.llvm_bolt().as_str()])
6566
.arg(temp_path.display())
6667
.arg("-data")
6768
.arg(&profile.0)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ impl Environment {
116116
pub fn stage0(&self) -> Utf8PathBuf {
117117
self.stage0_root.clone().unwrap_or_else(|| self.build_artifacts().join("stage0"))
118118
}
119+
120+
pub fn llvm_bolt(&self) -> Utf8PathBuf {
121+
self.host_llvm_dir().join(format!("bin/llvm-bolt{}", executable_extension()))
122+
}
119123
}
120124

121125
/// What is the extension of binary executables on this platform?

0 commit comments

Comments
 (0)