Wire SCCACHE_BASEDIRS into Rust hash key
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7.7k
- Forks
- 748
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 21
Description
Problem
SCCACHE_BASEDIRS was done by https://github.com/mozilla/sccache/pull/2521. Pretty impressive!
However, that only deals with C compiler. Rust compiler wasn't covered.
In Rust, the most popular build tool Cargo by default using absolute paths everywhere. Such as
- Absolute source paths of registry dependencies and local crates are included in the
--externand-Lflags. - If you are moving
CARGO_HOMEaround, the path will change. See https://github.com/rust-lang/cargo/issues/10915 - There is not
RUSTLINKFLAGS, while one of the most common absolute path pattern in rustflags are linker flags. See https://github.com/rust-lang/cargo/issues/4349. -Ztrim-pathsmight be a way to partially fix this (as part of fixing the artifaict content hash), but that would also introduce more--remap-path-prefix=…, which will contain more aboslute paths. (See https://github.com/rust-lang/cargo/issues/12137)
I think at least we need to implement a basic support to eliminate some of the most common absolute paths from the cache key, like --remap-path-prefix=/abs/path, -Clinker=/abs/path, -Clin-arge=something,/abs/path, and others.
Drawback
SCCACHE_BASEDIRS only normalize paths for cache keys not the real compiler invocations. That means embedded path in binaries are shared across different build root.
This might be a user problem, as they can fix it via prefix-map flag, like -fdebug-prefix-map, -ffile-prefix-map, -fmacro-prefix-map in C compiler and --remap-path-prefix in rustc.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing SCCACHE_BASEDIRS path normalization used for C compiler cache keys, then inspect how Rust compiler arguments are represented and hashed. Add focused coverage for the listed Rust path forms; done means those paths normalize in cache keys while the actual compiler invocation remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100