Repository navigation
rust: exclude CARGO_TARGET_DIR and CARGO_BUILD_* from the hash key - #3050
Merged
Merged
Conversation
They configure Cargo; what they change for rustc arrives as hashed arguments. Hashing them gave each target directory its own cache.
art-shen
force-pushed
the
cargo-settings-out-of-key
branch
from
November 20, 2026 00:07
7eb9933 to
03eba07
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3050 +/- ##
==========================================
- Coverage 78.97% 78.96% -0.02%
==========================================
Files 75 75
Lines 46130 46159 +29
==========================================
+ Hits 36433 36449 +16
- Misses 9697 9710 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
Thanks for your PR |
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.
Problem: when
CARGO_TARGET_DIRdiffers between checkouts of a project, for example one target dir per git worktree, every crate misses the cache, even with basedirs covering all the checkouts. sccache puts everyCARGO_*env var except a few into the key, andCARGO_TARGET_DIRis one of them.CARGO_BUILD_*vars, e.g.CARGO_BUILD_BUILD_DIR, have the same effect.Change: leave
CARGO_TARGET_DIRandCARGO_BUILD_*out of the key, likeCARGO_BUILD_JOBSalready is.These vars configure Cargo. What they change for rustc reaches it as arguments (
--target,-C incremental, rustflags), and arguments are hashed. A crate that reads one withenv!still gets the value hashed through dep-info.test_generate_hash_keynow also setsCARGO_TARGET_DIRandCARGO_BUILD_BUILD_DIR.Tests:
cargo test --locked --lib --bins --tests. Locally,cache_hit_rateand twosccache_cargotests (proc_macro_in_another_target_dir,incremental_allowed_deps_cached) fail onmaintoo.