Remap the exec root out of build script rustflags - #4202
Open
cpcwood wants to merge 2 commits into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
cpcwood
force-pushed
the
fix/build-script-remap-path-prefix
branch
2 times, most recently
from
August 4, 2026 09:19
0a713a3 to
666ce19
Compare
Build scripts that invoke rustc themselves, such as rustix's feature probe, receive CARGO_ENCODED_RUSTFLAGS and forward it verbatim. Without --remap-path-prefix the exec root is folded into whatever they emit into OUT_DIR, and because that directory is hashed into the cache key of every dependent crate, identical sources built at two different absolute paths produce different cache keys for the whole subtree. construct_arguments already applies this remapping to every rustc invocation rules_rust constructs directly. Build scripts reach rustc indirectly, through the environment, so they did not inherit it.
cpcwood
force-pushed
the
fix/build-script-remap-path-prefix
branch
from
August 4, 2026 09:21
666ce19 to
5f3b621
Compare
UebelAndre
requested changes
Aug 4, 2026
UebelAndre
left a comment
Collaborator
There was a problem hiding this comment.
Thanks! I had jut one question 😄
UebelAndre
self-requested a review
August 19, 2026 15:41
UebelAndre
enabled auto-merge
August 25, 2026 20:23
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 25, 2026
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.
Fixes issue: #4201
Build scripts that invoke
rustcthemselves bake the exec root into their output, becausecargo_build_scriptdoes not include--remap-path-prefixin theCARGO_ENCODED_RUSTFLAGSit passes to them.rustix'sbuild.rsfeature probe pipes source torustcon stdin, so the working directory is the only path input rustc has, and it folds that into the--emit=metadataoutput written to$OUT_DIR. That is a declared build-script output, hashed into the cache key of every dependent crate, so the same source built at two different absolute paths produces different cache keys for the whole dependent chain.construct_arguments()already applies--remap-path-prefixto every rustc invocation the ruleset constructs, "For determinism to help with build distribution and such". Build scripts reach rustc throughCARGO_ENCODED_RUSTFLAGSrather thanconstruct_arguments(), so they never inherited it.rustdocis the only other exception and is documented as one.Reproduction, with a Bazel-free minimal check and a four-workspace Bazel proof: https://github.com/cpcwood/bazel-rules-rust-rustix-cache-bust-demo
Verified on
aarch64-darwinandubuntu-latest. Hash values are platform-specific.