Repository navigation
rust: add support for SCCACHE_BASEDIRS when hashing - #2918
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2918 +/- ##
==========================================
- Coverage 78.15% 75.35% -2.81%
==========================================
Files 74 74
Lines 43324 43737 +413
==========================================
- Hits 33861 32957 -904
- Misses 9463 10780 +1317 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sylvestre
reviewed
Oct 19, 2026
sylvestre
reviewed
Oct 19, 2026
sylvestre
reviewed
Oct 19, 2026
ghoulspa
force-pushed
the
basedirs-rust
branch
from
October 19, 2026 21:00
7bbd885 to
994db6a
Compare
sylvestre
reviewed
Oct 20, 2026
ghoulspa
force-pushed
the
basedirs-rust
branch
from
October 21, 2026 09:17
994db6a to
708c151
Compare
rustc escapes backslashes, newlines and carriage returns in them. Keys change once for crates whose env-deps contain one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The cwd, the arguments, the CARGO_* variables and the env-dep values are hashed with the basedirs stripped, so a crate built from another checkout listed in SCCACHE_BASEDIRS is a hit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ghoulspa
force-pushed
the
basedirs-rust
branch
from
October 28, 2026 14:25
708c151 to
e19d4d6
Compare
Collaborator
|
Thanks for your PR |
pamarcos
added a commit
to pamarcos/sccache
that referenced
this pull request
Nov 3, 2026
Adopt upstream's local dep-info generation and remove the cached-output rewrite hook. Keep literal environment dependencies, remap destinations, and unremapped source identities in Rust cache keys. Restrict normalization around procedural macros and partial remap scopes. Advance the Rust cache-key version to avoid reusing unsafe entries. Add executable regressions comparing cached and fresh builds across checkouts, alongside a safe cache-hit control. Document the supported cases and conservative Cargo limitations. Related: mozilla#2918 Related: mozilla#2894
katout
added a commit
to katout/sccache
that referenced
this pull request
Nov 11, 2026
Since mozilla#2918, with SCCACHE_BASEDIRS the values of env-deps (the variables a crate reads with `env!` or `option_env!`) are hashed with the basedirs stripped. A crate that bakes `env!("CARGO_MANIFEST_DIR")` into its outputs can then get a hit from another checkout and use that checkout's path. SCCACHE_BASEDIRS_VERBATIM_ENV_DEPS, a comma-separated list read from the compile's environment, names env-deps whose values are hashed verbatim, so only crates that read them are keyed per checkout. The variable and the names it lists are matched ignoring ASCII case on Windows, where rustc lists the name as written in `env!`. An empty or non-UTF-8 value is ignored, and without basedirs nothing is looked up, so default keys are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
sylvestre
pushed a commit
that referenced
this pull request
Nov 14, 2026
Since #2918, with SCCACHE_BASEDIRS the values of env-deps (the variables a crate reads with `env!` or `option_env!`) are hashed with the basedirs stripped. A crate that bakes `env!("CARGO_MANIFEST_DIR")` into its outputs can then get a hit from another checkout and use that checkout's path. SCCACHE_BASEDIRS_VERBATIM_ENV_DEPS, a comma-separated list read from the compile's environment, names env-deps whose values are hashed verbatim, so only crates that read them are keyed per checkout. The variable and the names it lists are matched ignoring ASCII case on Windows, where rustc lists the name as written in `env!`. An empty or non-UTF-8 value is ignored, and without basedirs nothing is looked up, so default keys are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
The Rust implementation of the hasher doesn't respect
SCCACHE_BASEDIRScurrently. This PR adds support for the basedirs during the hashing process, by stripping the basedir from the working directory, the arguments, theCARGO_*variables and the env-dep values.Not respecting basedirs causes issues when using crates that use
OUT_DIR, such as serde, which miss the cache in every new checkout. Path dependency crates also miss the cache because ofCARGO_MANIFEST_DIRand the working directory, and every crate that depends on them misses as well, so this fixes that too. This also fixes env-dep values by unescaping them, since rustc doubles their backslashes and the strip wouldn't match otherwise.This change to the env-dep parser may cause new misses on Windows, once per crate, for anyone whose env-deps contain backslashes, such as serde's
OUT_DIR. For all other cache keys there will be no changes, except where you use the new basedirs support.We also added unit tests which check that the hash keys match when basedirs are in use and differ when they aren't, plus a few edge cases, and an integration test that builds with cargo from two checkouts.
Fixes #2870