-
Notifications
You must be signed in to change notification settings - Fork 623
Description
sccache treats CARGO_ env vars specially, and includes them in the hash. However, there are variable that are irrelevant for the output, but can break caching:
Lines 1517 to 1530 in d4ae480
| if !var.starts_with("CARGO_") { | |
| continue; | |
| } | |
| // CARGO_MAKEFLAGS will have jobserver info which is extremely non-cacheable. | |
| // CARGO_REGISTRIES_*_TOKEN contains non-cacheable secrets. | |
| // Registry override config doesn't need to be hashed, because deps' package IDs | |
| // already uniquely identify the relevant registries. | |
| // CARGO_BUILD_JOBS only affects Cargo's parallelism, not rustc output. | |
| if var == "CARGO_MAKEFLAGS" | |
| || var.starts_with("CARGO_REGISTRIES_") | |
| || var == "CARGO_BUILD_JOBS" | |
| { | |
| continue; |
and there's lot more to exclude:
CARGO_BUILD_JOBS– concurrency does not affect resultsCARGO_REGISTRY_*– same asCARGO_REGISTRIES_*(random tokens, redundant with package IDs)CARGO_TARGET_DIR– already included in the file pathsCARGO_BUILD_BUILD_DIRCARGO_BUILD_TARGET_DIRCARGO_HTTP_*– no effect on the outputsCARGO_NET_*CARGO_TERM_*CARGO_ALIAS_*CARGO_CACHE_AUTO_CLEAN_FREQUENCY"
and I'm wondering what even is needed to be included?
The problem is that CARGO_ env vars that modify config are only one of multiple ways of modifying Cargo's config. So either sccache is not properly capturing the config set via config.toml or CLI flags, or the config overrides via env vars are redundant. I think they are redundant, as long as the rlib metadata hash is included, and possibly extra-filename set by Cargo. If Cargo's hash put in the rlib filenames is good enough for Cargo, it should be good enough for sccache?