Limits of Spack Build Cache Reuse When Compiler Version Changes
0 reputation · 24 Mar 2022, 14:53 UTC
0 reputation · 24 Mar 2022, 14:53 UTC
Spack’s build cache stores pre‑built packages using a key that hashes the full spec, target architecture, and the complete compiler string (version and flags). The goal is to evaluate whether the cache can safely treat patch‑level changes in the compiler version as compatible, thereby increasing hit rates without violating ABI guarantees.
Currently the cache invalidates on any change to the compiler string, and the policy for what constitutes a ‘compatible’ compiler remains an open discussion in the community. This conservatism avoids silent mis‑links but may lead to unnecessary rebuilds when only minor compiler updates are applied. Should Spack relax the compiler hash to ignore patch‑level revisions? What objective criteria could define a compatible compiler version? How would adjusting the hash affect cache hit rates and the reproducibility of builds?
34775 reputation · 24 Mar 2022, 22:40 UTC
Spack’s build‑cache key is built from the full compiler spec string (e.g., gcc@11.3.0 or gcc@11.3.1). Because the string is hashed verbatim, any change to the patch level produces a new key and forces a rebuild. The policy is intentionally conservative to preserve bit‑for‑bit reproducibility and avoid silent ABI mismatches.
spack spec --cache-only, binary mirrors) rely on the full spec hash.Spack’s designers chose a strict hash to avoid the risk of linking against binaries that were built with different code‑generation or library assumptions. A patch‑level change can alter exception handling, inlining decisions, or even the layout of standard library types. Treating such changes as equivalent could silently break user programs.
Removing the patch component would increase hit rates only if the same patch exists in the mirror, which is uncommon. More importantly, it would break reproducibility guarantees: two users on slightly different patch levels would see identical binaries, but those binaries might not be interchangeable.
spack spec --cache-only package@1.2.3 %gcc@11.3.0
spack spec --cache-only package@1.2.3 %gcc@11.3.1
Do you mainly want to reduce rebuild frequency, or have you observed runtime failures after a compiler update? Knowing that will help decide whether a local key normalizer is appropriate or if you should keep the conservative policy.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.