-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #100801 - Kobzol:track-pgo-profile-paths, r=michaelwoer…
…ister Track PGO profiles in depinfo This PR makes sure that PGO profiles (`-Cprofile-use` and `-Cprofile-sample-use`) are tracked in depinfo, so that when they change, the compilation session will be invalidated. This approach was discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Tracking.20PGO.20profile.20files.20in.20cargo). I tried it locally and it seems that the code is recompiled just with this change, and #100413 is not even needed. But it's possible that not everything required is recompiled, so we will probably want to land both changes. Another approach to implement this could be to store the PGO profiles in `sess.parse_sess.file_depinfo` when the session is being created, but then the paths would have to be converted to a string and then to a symbol, which seemed unnecessarily complicated. CC `@michaelwoerister` r? `@Eh2406`
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# needs-profiler-support | ||
# ignore-windows-gnu | ||
|
||
-include ../../run-make-fulldeps/tools.mk | ||
|
||
# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC` | ||
# instead of hardcoding them everywhere they're needed. | ||
ifeq ($(IS_MUSL_HOST),1) | ||
ADDITIONAL_ARGS := $(RUSTFLAGS) | ||
endif | ||
|
||
all: | ||
# Generate PGO profiles | ||
$(BARE_RUSTC) $(ADDITIONAL_ARGS) -Cprofile-generate=$(TMPDIR)/profiles --out-dir $(TMPDIR) main.rs | ||
$(TMPDIR)/main | ||
|
||
# Merge profiles | ||
"$(LLVM_BIN_DIR)/llvm-profdata" merge \ | ||
-o "$(TMPDIR)/merged.profdata" \ | ||
"$(TMPDIR)/profiles" || exit 1 | ||
|
||
# Use the profile | ||
$(RUSTC) -Cprofile-use=$(TMPDIR)/merged.profdata --emit dep-info main.rs | ||
|
||
# Check that profile file is in depinfo | ||
$(CGREP) "merged.profdata" < $(TMPDIR)/main.d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fn main() {} |