Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #20804 from itsjunetime/run_correct_pgo_r-a
Build rust-analyzer with `--target` for install/pgo xtask
Chayim Refael Friedman 6 months ago
parent 11e29a4 · parent 359a91e · commit 1941dfe
-rw-r--r--xtask/src/install.rs4
-rw-r--r--xtask/src/pgo.rs25
2 files changed, 19 insertions, 10 deletions
diff --git a/xtask/src/install.rs b/xtask/src/install.rs
index f0cc445dfa..b794f53e76 100644
--- a/xtask/src/install.rs
+++ b/xtask/src/install.rs
@@ -145,12 +145,12 @@ fn install_server(sh: &Shell, opts: ServerOpt) -> anyhow::Result<()> {
);
if let Some(train_crate) = opts.pgo {
+ let target = detect_target(sh);
let build_cmd = cmd!(
sh,
- "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --profile={profile} --locked --features force-always-assert {features...}"
+ "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target} --profile={profile} --locked --features force-always-assert {features...}"
);
- let target = detect_target(sh);
let profile = crate::pgo::gather_pgo_profile(sh, build_cmd, &target, train_crate)?;
install_cmd = crate::pgo::apply_pgo_to_cmd(install_cmd, &profile);
}
diff --git a/xtask/src/pgo.rs b/xtask/src/pgo.rs
index 7f7b3311d9..0c6f499811 100644
--- a/xtask/src/pgo.rs
+++ b/xtask/src/pgo.rs
@@ -53,14 +53,23 @@ pub(crate) fn gather_pgo_profile<'a>(
// Merge profiles into a single file
let merged_profile = pgo_dir.join("merged.profdata");
- let profile_files = std::fs::read_dir(pgo_dir)?.filter_map(|entry| {
- let entry = entry.ok()?;
- if entry.path().extension() == Some(OsStr::new("profraw")) {
- Some(entry.path().to_str().unwrap().to_owned())
- } else {
- None
- }
- });
+ let profile_files = std::fs::read_dir(pgo_dir)?
+ .filter_map(|entry| {
+ let entry = entry.ok()?;
+ if entry.path().extension() == Some(OsStr::new("profraw")) {
+ Some(entry.path().to_str().unwrap().to_owned())
+ } else {
+ None
+ }
+ })
+ .collect::<Vec<_>>();
+
+ if profile_files.is_empty() {
+ anyhow::bail!(
+ "rust-analyzer analysis-stats produced no pgo files. This is a bug in rust-analyzer; please file an issue."
+ );
+ }
+
cmd!(sh, "{llvm_profdata} merge {profile_files...} -o {merged_profile}").run().context(
"cannot merge PGO profiles. Do you have the rustup `llvm-tools` component installed?",
)?;