docs/Caching.md
To know if the storage contains the artifact we need, we are computing some hashes to make sure the input is the same.
Because the configuration and environment matter, the hash computation takes a few parameters into account.
We generate a blake3 digest for each file compiled. In parallel, we also take into account in the hash:
See https://github.com/mozilla/sccache/blob/8567bbe2ba493153e76177c1f9a6f98cc7ba419f/src/compiler/rust.rs#L122 for the full list
For C/C++, the hash is generated with a blake3 digest of the preprocessed
file (-E with gcc/clang). For compilations that specify multiple -arch flags,
these flags are rewritten to their corresponding preprocessor defines to allow
pre-processing the file (e.g -arch x86_64 is rewritten to -D__X86_64__=1),
this can be enabled by setting the environment variable
SCCACHE_CACHE_MULTIARCH but is disabled by default as it may not work in all
cases.
We also take into account in the hash:
In "preprocessor cache mode", explained in the local doc, an extra key is computed to cache the preprocessor output itself. It is very close to the C/C++ compiler one, but with additional elements:
Note that some compiler options can disable preprocessor cache mode. As of this
writing, only -Xpreprocessor and -Wp,* do.