-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(fingerprint): Don't throwaway the cache on RUSTFLAGS changes #14830
base: master
Are you sure you want to change the base?
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
…e hashes For now, they should result in the same data.
|
f709c73
to
2af218d
Compare
FWIW, I think this should resolve an issue in the Hubris build system. Currently we bypass Cargo's dirtiness checks for building deps in certain circumstances (to get maximum reuse of objects despite small controlled changes to Haven't tested it yet though. |
26ced7e
to
536ae6e
Compare
dep_c_extra_filename_hashes.hash(&mut c_extra_filename_hasher); | ||
// Avoid trashing the caches on RUSTFLAGS changing via `c_extra_filename` | ||
// | ||
// Limited to `c_extra_filename` to help with reproducible build / PGO issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should (probably) avoid the PGO problems, since the symbols won't change. However, this could still cause problems with reproducible builds if the rlib filename somehow leaks into the resulting binary (I don't have a reason to think it does, but it seems risky).
I believe this does because the filenames of object files show up as the codegen unit names in dwarf debug info (and probably PDB?). I suspect that everything else in the binary will be the same, but builds differing only in extra-filename are likely to still produce different binaries.
Have we checked if it doesn't affect PGO?
We would like to check if anything is leaking rlib filename in debug info files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea how to go about that? I have no experience with PGO and we have no tests focusing on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do some experiments this week and see if we can have tests written down!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Posted #14859
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test passes with this PR for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed that this breaks reproducible builds with --remap-path-prefix
flag. rlib names are leaked to .dwp
and object files on Linux.
Step to reproduce
cargo new foo && cd foo
cargo add unicode-indent
-
// src/main.rs fn main() { unicode_ident::is_xid_start('-'); }
cargo b --config 'profile.dev.split-debuginfo="packed"'
readelf -wi target/debug/deps/foo-2fa7d8fb1eafd428 | rg DW_AT_GNU_dwo_name
and observed both-C extra-filename
forfoo
andunicode_ident
were leaked. They were leaked to.dwp
file as well.
Although rustc
is not truly reproducible under certain circumstances (for example rust-lang/rust#117652), this change could hurt reproducibility for any use of remap-path-related flags. The -Ztrim-paths
flag might improve the situation a bit, as it reduces the need for users to pass --remap-path-prefix
. However, it does not change the fact that reproducibility is broken I feel like. See also #6966.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For most rustflags, changing them changes the binary anyway. Remap is special in that it takes a build-specific value and removes it, making builds more reproducible.
16ce931
to
c762927
Compare
### What does this PR try to resolve? This is a regression test to prevent issues like #7416. The test only run on Linux, as other platforms have different requirements for PGO, or emit different PGO function missing warnings. ### How should we test and review this PR? Not sure how brittle it is. We can optionally run it only on Cargo's CI? cc #14830
What does this PR try to resolve?
Fixes #8716
This splits
-C metdata
and-C extra-filename
and addsRUSTFLAGS
to-C extra-filename
in the hope that we can still make PGO and reproducible builds work while caching artifacts per RUSTFLAGS used.How should we test and review this PR?
Additional information