Use absolute path to llvm-bolt, merge-fdata 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.
This commit is contained in:
parent
e95db591a4
commit
199d2d4615
4 changed files with 15 additions and 5 deletions
|
|
@ -9,6 +9,7 @@ use crate::utils::io::copy_file;
|
|||
/// Instruments an artifact at the given `path` (in-place) with BOLT and then calls `func`.
|
||||
/// After this function finishes, the original file will be restored.
|
||||
pub fn with_bolt_instrumented<F: FnOnce(&Utf8Path) -> anyhow::Result<R>, R>(
|
||||
env: &Environment,
|
||||
path: &Utf8Path,
|
||||
func: F,
|
||||
) -> anyhow::Result<R> {
|
||||
|
|
@ -26,7 +27,7 @@ pub fn with_bolt_instrumented<F: FnOnce(&Utf8Path) -> anyhow::Result<R>, R>(
|
|||
let profile_prefix = Utf8Path::from_path(&profile_prefix).unwrap();
|
||||
|
||||
// Instrument the original file with BOLT, saving the result into `instrumented_path`
|
||||
cmd(&["llvm-bolt"])
|
||||
cmd(&[env.llvm_bolt().as_str()])
|
||||
.arg("-instrument")
|
||||
.arg(path)
|
||||
.arg(&format!("--instrumentation-file={profile_prefix}"))
|
||||
|
|
@ -61,7 +62,7 @@ pub fn bolt_optimize(
|
|||
let split_strategy =
|
||||
if env.host_tuple().starts_with("aarch64") { "profile2" } else { "cdsplit" };
|
||||
|
||||
cmd(&["llvm-bolt"])
|
||||
cmd(&[env.llvm_bolt().as_str()])
|
||||
.arg(temp_path.display())
|
||||
.arg("-data")
|
||||
.arg(&profile.0)
|
||||
|
|
|
|||
|
|
@ -116,6 +116,14 @@ impl Environment {
|
|||
pub fn stage0(&self) -> Utf8PathBuf {
|
||||
self.stage0_root.clone().unwrap_or_else(|| self.build_artifacts().join("stage0"))
|
||||
}
|
||||
|
||||
pub fn llvm_bolt(&self) -> Utf8PathBuf {
|
||||
self.host_llvm_dir().join(format!("bin/llvm-bolt{}", executable_extension()))
|
||||
}
|
||||
|
||||
pub fn merge_fdata(&self) -> Utf8PathBuf {
|
||||
self.host_llvm_dir().join(format!("bin/merge-fdata{}", executable_extension()))
|
||||
}
|
||||
}
|
||||
|
||||
/// What is the extension of binary executables on this platform?
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ fn execute_pipeline(
|
|||
|
||||
// FIXME(kobzol): try gather profiles together, at once for LLVM and rustc
|
||||
// Instrument the libraries and gather profiles
|
||||
let llvm_profile = with_bolt_instrumented(&llvm_lib, |llvm_profile_dir| {
|
||||
let llvm_profile = with_bolt_instrumented(env, &llvm_lib, |llvm_profile_dir| {
|
||||
stage.section("Gather profiles", |_| {
|
||||
gather_bolt_profiles(env, "LLVM", llvm_benchmarks(env), llvm_profile_dir)
|
||||
})
|
||||
|
|
@ -354,7 +354,7 @@ fn execute_pipeline(
|
|||
log::info!("Optimizing {rustc_lib} with BOLT");
|
||||
|
||||
// Instrument it and gather profiles
|
||||
let rustc_profile = with_bolt_instrumented(&rustc_lib, |rustc_profile_dir| {
|
||||
let rustc_profile = with_bolt_instrumented(env, &rustc_lib, |rustc_profile_dir| {
|
||||
stage.section("Gather profiles", |_| {
|
||||
gather_bolt_profiles(env, "rustc", rustc_benchmarks(env), rustc_profile_dir)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -195,7 +195,8 @@ pub fn gather_bolt_profiles(
|
|||
let profiles: Vec<_> =
|
||||
glob::glob(&format!("{profile_prefix}*"))?.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
let mut merge_args = vec!["merge-fdata"];
|
||||
let fdata = env.merge_fdata();
|
||||
let mut merge_args = vec![fdata.as_str()];
|
||||
merge_args.extend(profiles.iter().map(|p| p.to_str().unwrap()));
|
||||
|
||||
with_log_group("Merging BOLT profiles", || {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue