Skip to content

Commit 9c863c2

Browse files
Auto merge of #146039 - Mark-Simulacrum:fix-bolt-path, r=<try>
Use absolute path to llvm-bolt rather than PATH
2 parents 523d399 + 199d2d4 commit 9c863c2

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ 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+
}
123+
124+
pub fn merge_fdata(&self) -> Utf8PathBuf {
125+
self.host_llvm_dir().join(format!("bin/merge-fdata{}", executable_extension()))
126+
}
119127
}
120128

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ fn execute_pipeline(
329329

330330
// FIXME(kobzol): try gather profiles together, at once for LLVM and rustc
331331
// Instrument the libraries and gather profiles
332-
let llvm_profile = with_bolt_instrumented(&llvm_lib, |llvm_profile_dir| {
332+
let llvm_profile = with_bolt_instrumented(env, &llvm_lib, |llvm_profile_dir| {
333333
stage.section("Gather profiles", |_| {
334334
gather_bolt_profiles(env, "LLVM", llvm_benchmarks(env), llvm_profile_dir)
335335
})
@@ -354,7 +354,7 @@ fn execute_pipeline(
354354
log::info!("Optimizing {rustc_lib} with BOLT");
355355

356356
// Instrument it and gather profiles
357-
let rustc_profile = with_bolt_instrumented(&rustc_lib, |rustc_profile_dir| {
357+
let rustc_profile = with_bolt_instrumented(env, &rustc_lib, |rustc_profile_dir| {
358358
stage.section("Gather profiles", |_| {
359359
gather_bolt_profiles(env, "rustc", rustc_benchmarks(env), rustc_profile_dir)
360360
})

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ pub fn gather_bolt_profiles(
195195
let profiles: Vec<_> =
196196
glob::glob(&format!("{profile_prefix}*"))?.collect::<Result<Vec<_>, _>>()?;
197197

198-
let mut merge_args = vec!["merge-fdata"];
198+
let fdata = env.merge_fdata();
199+
let mut merge_args = vec![fdata.as_str()];
199200
merge_args.extend(profiles.iter().map(|p| p.to_str().unwrap()));
200201

201202
with_log_group("Merging BOLT profiles", || {

0 commit comments

Comments
 (0)