File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed
src/tools/rust-analyzer/xtask/src Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -145,12 +145,12 @@ fn install_server(sh: &Shell, opts: ServerOpt) -> anyhow::Result<()> {
145145 ) ;
146146
147147 if let Some ( train_crate) = opts. pgo {
148+ let target = detect_target ( sh) ;
148149 let build_cmd = cmd ! (
149150 sh,
150- "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --profile={profile} --locked --features force-always-assert {features...}"
151+ "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target} -- profile={profile} --locked --features force-always-assert {features...}"
151152 ) ;
152153
153- let target = detect_target ( sh) ;
154154 let profile = crate :: pgo:: gather_pgo_profile ( sh, build_cmd, & target, train_crate) ?;
155155 install_cmd = crate :: pgo:: apply_pgo_to_cmd ( install_cmd, & profile) ;
156156 }
Original file line number Diff line number Diff line change @@ -53,14 +53,23 @@ pub(crate) fn gather_pgo_profile<'a>(
5353
5454 // Merge profiles into a single file
5555 let merged_profile = pgo_dir. join ( "merged.profdata" ) ;
56- let profile_files = std:: fs:: read_dir ( pgo_dir) ?. filter_map ( |entry| {
57- let entry = entry. ok ( ) ?;
58- if entry. path ( ) . extension ( ) == Some ( OsStr :: new ( "profraw" ) ) {
59- Some ( entry. path ( ) . to_str ( ) . unwrap ( ) . to_owned ( ) )
60- } else {
61- None
62- }
63- } ) ;
56+ let profile_files = std:: fs:: read_dir ( pgo_dir) ?
57+ . filter_map ( |entry| {
58+ let entry = entry. ok ( ) ?;
59+ if entry. path ( ) . extension ( ) == Some ( OsStr :: new ( "profraw" ) ) {
60+ Some ( entry. path ( ) . to_str ( ) . unwrap ( ) . to_owned ( ) )
61+ } else {
62+ None
63+ }
64+ } )
65+ . collect :: < Vec < _ > > ( ) ;
66+
67+ if profile_files. is_empty ( ) {
68+ anyhow:: bail!(
69+ "rust-analyzer analysis-stats produced no pgo files. This is a bug in rust-analyzer; please file an issue."
70+ ) ;
71+ }
72+
6473 cmd ! ( sh, "{llvm_profdata} merge {profile_files...} -o {merged_profile}" ) . run ( ) . context (
6574 "cannot merge PGO profiles. Do you have the rustup `llvm-tools` component installed?" ,
6675 ) ?;
You can’t perform that action at this time.
0 commit comments