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:
|
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 results
CARGO_REGISTRY_* – same as CARGO_REGISTRIES_* (random tokens, redundant with package IDs)
CARGO_TARGET_DIR – already included in the file paths
CARGO_BUILD_BUILD_DIR
CARGO_BUILD_TARGET_DIR
CARGO_HTTP_* – no effect on the outputs
CARGO_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?
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:sccache/src/compiler/rust.rs
Lines 1517 to 1530 in d4ae480
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 eithersccacheis not properly capturing the config set viaconfig.tomlor 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?