Skip to content

cmake: wire up fastcache-cc / sccache / ccache compiler-cache selection - #125

Merged
Yaraslaut merged 1 commit into
masterfrom
add-fastcache-compile-cache
Aug 18, 2026
Merged

cmake: wire up fastcache-cc / sccache / ccache compiler-cache selection#125
Yaraslaut merged 1 commit into
masterfrom
add-fastcache-compile-cache

Conversation

@Yaraslaut

@Yaraslaut Yaraslaut commented Aug 18, 2026

Copy link
Copy Markdown
Member

Vendors cmake/CompileCache.cmake from LASTRADA-Software/fastcached — a self-contained module with no dependency on that project, meant to be dropped into any CMake project's cmake/ directory (see cmake/portable/README.md there).

What it does

Selects a compiler-cache launcher in preference order, wired via CMAKE_<LANG>_COMPILER_LAUNCHER:

  1. fastcache-cc — used only when a fastcached daemon actually answers. This is verified end-to-end at configure time by compiling a throwaway translation unit through the launcher and requiring a reported HIT/MISS, not just presence on PATH (a launcher that can't reach its daemon still compiles fine, silently paying a failed connect per TU otherwise). Address defaults to 127.0.0.1:6674, overridable via FASTCACHE_ADDR.
  2. sccache — used when fastcache-cc is unavailable/unconfigured.
  3. ccache — the local fallback.
  4. None — silently disables caching if nothing above applies, or if -DUSE_COMPILER_CACHE=OFF.

include(cmake/CompileCache.cmake) is placed right after compiler_options.cmake, before the FetchContent-fetched glaze dependency, so that gets cached too.

Why fastcache-cc is preferred over sccache

fastcache-cc isn't just "another sccache" — when it's selected, the compile cache is served over fastcached's own dedicated 0xFC binary wire protocol (CompileCacheWire/CompileCacheHandler), purpose-built for this job: canonicalize-on-store / serve-canonical-on-fetch, cohort-based leading-key prefetch, and a framing that lets a rejection be a reply instead of a silent connection drop. sccache talks a generic key/value protocol against whatever backend (Redis, S3, ...) it's pointed at — it works, but it isn't using our protocol. We want our own protocol used whenever a fastcached daemon is available, and this preference order is how that's expressed: try fastcache-cc first, fall back only when it can't be used.

Both launchers are portable across checkout paths (unlike raw ccache in some configurations), so a CI runner and a developer working from different directories can share cache hits. This has no effect on a machine with nothing installed — it's a pure opt-in speedup when a cache is available.

🤖 Generated with Claude Code

Vendors cmake/CompileCache.cmake from LASTRADA-Software/fastcached
(self-contained, no dependency on that project) and includes it before
any fetched dependency, so both morph's own targets and the
FetchContent-fetched glaze get compiler-cache coverage.

Selection order: fastcache-cc when a fastcached daemon answers (probed
end-to-end with a throwaway translation unit, not just presence on
PATH), else sccache, else ccache, else no cache. Off entirely with
-DUSE_COMPILER_CACHE=OFF; the daemon address defaults to
127.0.0.1:6674 and is overridable via FASTCACHE_ADDR.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Yaraslaut
Yaraslaut merged commit 5bf4cde into master Aug 18, 2026
23 checks passed
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant