fix: -Cmetadata includes whether extra rustflags is same as host#14432
Merged
bors merged 2 commits intorust-lang:masterfrom Aug 21, 2024
Merged
fix: -Cmetadata includes whether extra rustflags is same as host#14432bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
Conversation
Collaborator
c877f48 to
0776730
Compare
See rust-lang/cargo 14253
0776730 to
1b68942
Compare
epage
reviewed
Aug 21, 2024
Comment on lines
+659
to
+668
| let target_configs_are_different = unit.rustflags != host_info.rustflags | ||
| || unit.rustdocflags != host_info.rustdocflags | ||
| || bcx | ||
| .target_data | ||
| .target_config(CompileKind::Host) | ||
| .links_overrides | ||
| != unit.links_overrides; |
Contributor
There was a problem hiding this comment.
This feels a bit brittle. If we don't remember to update this with anything else that is different but not in metadata already, we'll see this problem again.
The only thoughts I had are
- Putting this question in the unit or host info to answer
- Hashing
unit.kind.is_host() && !bcx.gctx.target_applies_to_host().unwrap_or_default()
Note: answering this is more important for long term reliability and stabilization. This doesn't need to block fixing people who are using the unstable feature
epage
approved these changes
Aug 21, 2024
Contributor
epage
left a comment
There was a problem hiding this comment.
Feel free to r= me when ready
`-Ztarget-applies-to-host --config target-applies-to-host=false` make it possible to build two units for the same output directory with different rustflags (one with artifact/target rustflags, one with none/host rust flags). Those flags aren't included in the `-Cmetadata` hash which is used to disambiguate different versions of crates, resulting in a conflict. The actual error being produced appears to be the result of two invocations of `rustc` racing and clobbering each other. While we don't hash RUSTFLAGS because it may contain absolute paths that hurts reproducibility, we track whether a unit's RUSTFLAGS is from host config, so that we can generate a different metadata hash for runtime and compile-time units.
1b68942 to
d12c716
Compare
Member
Author
|
Removed the comment and added a note above the hack. Thanks people. Going to merge this. @bors r=epage |
Contributor
Contributor
Contributor
|
☀️ Test successful - checks-actions |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Aug 22, 2024
Update cargo 12 commits in ba8b39413c74d08494f94a7542fe79aa636e1661..8f40fc59fb0c8df91c97405785197f3c630304ea 2024-08-16 22:48:57 +0000 to 2024-08-21 22:37:06 +0000 - Tests rely on absence of RUST_BACKTRACE (rust-lang/cargo#14441) - fix: -Cmetadata includes whether extra rustflags is same as host (rust-lang/cargo#14432) - [mdman] Normalize newlines when rendering options (rust-lang/cargo#14428) - fix: doctest respects Cargo's color options (rust-lang/cargo#14425) - Be more permissive while packaging unpublishable crates. (rust-lang/cargo#14408) - fix: Limiting pre-release match semantics to use only on `OptVersionReq::Req` (rust-lang/cargo#14412) - test: add a regression test for Issue 14409 (rust-lang/cargo#14430) - chore: update label trigger for Command-info (rust-lang/cargo#14422) - doc: add lockfile-path unstable doc section (rust-lang/cargo#14423) - doc: update lockfile-path tracking issue (rust-lang/cargo#14424) - fix: remove list owners feature of info subcommand (rust-lang/cargo#14418) - Lockfile path tests (follow-up) (rust-lang/cargo#14417)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR try to resolve?
Fixes #14253
The root cause is described in #14253 (comment):
While we don't hash RUSTFLAGS because it may contain absolute paths that
hurts reproducibility, we track whether a unit's RUSTFLAGS is from host
config, so that we can generate a different metadata hash for runtime
and compile-time units.
How should we test and review this PR?
This hack is only enabled when
target-applies-to-host=falseand when compile kind is the host platform, so the shouldn't affect any stable behavior.Additional information
cc @gmorenz
I found time working on this PR before my travel. Feel free to cherry pick and create a new PR if this is not correct.