Introduction
sccache is a compiler caching daemon that intercepts compilation commands and returns cached results when inputs have not changed. It extends ccache concepts to support Rust, cloud storage backends, and distributed team sharing.
What sccache Does
- Caches C, C++, Rust, and CUDA compilation outputs based on input hashing
- Supports local disk, Amazon S3, Google Cloud Storage, Azure Blob, Redis, and Memcached as cache backends
- Acts as a drop-in
RUSTC_WRAPPERfor Rust projects orCC/CXXwrapper for C/C++ - Runs as a local daemon that multiple build processes connect to
- Provides cache hit statistics and storage usage reporting via
sccache --show-stats
Architecture Overview
sccache runs a local server process that listens for compilation requests. When a compiler invocation arrives, it hashes the preprocessed source, compiler flags, and compiler version to produce a cache key. If the key exists in the configured backend, the cached artifact is returned immediately. Otherwise, the compilation runs normally and the output is stored. The daemon handles concurrent requests and manages backend connections.
Self-Hosting & Configuration
- Install via
cargo install sccache, Homebrew, or download prebuilt binaries - Configure the storage backend in
~/.config/sccache/configor via environment variables - Set
SCCACHE_BUCKETandAWS_ACCESS_KEY_IDfor S3 backend - For Rust, set
RUSTC_WRAPPER=sccachein your shell profile or.cargo/config.toml - For C/C++, set
CMAKE_C_COMPILER_LAUNCHER=sccachein CMake projects
Key Features
- Cloud-backed caching means CI runs benefit from caches built by other developers or jobs
- Supports preprocessing-based and content-based hashing modes for accuracy
- Handles multiple compiler toolchains (GCC, Clang, MSVC, rustc, nvcc) simultaneously
- Read-only mode allows CI workers to pull from cache without write permissions
- Integrates with GitHub Actions, GitLab CI, and other CI systems via environment variables
Comparison with Similar Tools
- ccache — local-only by default; sccache natively supports cloud storage backends
- Bazel remote cache — build-system-specific; sccache works with any compiler
- Turbo Cache — JavaScript/monorepo focused; sccache targets native compilation
- buildcache — similar concept; sccache has broader backend support and Rust integration
- cachepot — sccache fork with extra features; sccache has larger community and Mozilla backing
FAQ
Q: How much build time does sccache save? A: On cache hits, compilation is essentially instant (milliseconds). Typical projects see 50-90% of compilations cached after the first build.
Q: Does it work with incremental compilation in Rust? A: sccache disables Rust incremental compilation because cached full builds are faster than partial incremental ones.
Q: Can multiple developers share the same cache? A: Yes. Point all team members at the same S3 bucket or Redis instance for shared caching.
Q: Does it support distributed compilation like distcc? A: sccache has experimental distributed compilation support but is primarily a caching tool, not a build farm.