Summary
On a byte-identical clean rebuild (same build dir path, unchanged sources, deterministic generated headers), ccache only hits 587 / 1606 compile calls (~18%) with direct mode. The _deps (CPM) targets hit; essentially all QGC TUs that consume the CMake precompiled header miss.
Evidence
Measured on macOS (Mac Pro, 24 cores, Debug + testing, Qt 6.11.1, clang) while benchmarking the moccache work:
- Fresh
CCACHE_DIR, clean build A → 1606 misses (expected).
- Delete build dir, reconfigure to the same path, clean build B with the warmed
CCACHE_DIR → only 581–587 direct hits, 0 preprocessed hits, ~1000 misses.
- moc outputs were verified byte-identical between the two builds (100% moccache hit rate, content-hashed), and the MAVLink dialect headers are deterministic, so generated-source churn is ruled out for those inputs.
Practical impact: a warm ccache gave zero wall-clock improvement on a clean build (548 s vs 549 s baseline) in this test.
Suspected cause
Clang embeds a timestamp in PCH files unless compiled with -Xclang -fno-pch-timestamp. Every clean build regenerates cmake_pch.hxx.pch with different bytes, and since the PCH participates in the hash of every TU that uses it, all PCH-consuming TUs miss. The ccache config (tools/configs/ccache.conf) already sets sloppiness = pch_defines,time_macros,..., but per ccache's PCH documentation clang additionally requires -fno-pch-timestamp for reliable PCH hits.
Ref: https://ccache.dev/manual/latest.html#_precompiled_headers
Suggested fix / investigation
- Add
-Xclang -fno-pch-timestamp to the PCH-related compile options for clang (macOS + Android/iOS toolchains as applicable).
- Re-check whether
sloppiness needs include_file_mtime,include_file_ctime interplay with the regenerated PCH file.
- Verify on Linux CI (GCC has its own PCH constraints — ccache docs recommend
-fpch-preamble alternatives / pch_external_checksum).
- Re-measure: expect warm-ccache clean-build hit rate to go from ~18% to near 100%, which would compound with the moc caching work for CI clean builds.
Summary
On a byte-identical clean rebuild (same build dir path, unchanged sources, deterministic generated headers), ccache only hits 587 / 1606 compile calls (~18%) with
directmode. The_deps(CPM) targets hit; essentially all QGC TUs that consume the CMake precompiled header miss.Evidence
Measured on macOS (Mac Pro, 24 cores, Debug + testing, Qt 6.11.1, clang) while benchmarking the moccache work:
CCACHE_DIR, clean build A → 1606 misses (expected).CCACHE_DIR→ only 581–587 direct hits, 0 preprocessed hits, ~1000 misses.Practical impact: a warm ccache gave zero wall-clock improvement on a clean build (548 s vs 549 s baseline) in this test.
Suspected cause
Clang embeds a timestamp in PCH files unless compiled with
-Xclang -fno-pch-timestamp. Every clean build regeneratescmake_pch.hxx.pchwith different bytes, and since the PCH participates in the hash of every TU that uses it, all PCH-consuming TUs miss. The ccache config (tools/configs/ccache.conf) already setssloppiness = pch_defines,time_macros,..., but per ccache's PCH documentation clang additionally requires-fno-pch-timestampfor reliable PCH hits.Ref: https://ccache.dev/manual/latest.html#_precompiled_headers
Suggested fix / investigation
-Xclang -fno-pch-timestampto the PCH-related compile options for clang (macOS + Android/iOS toolchains as applicable).sloppinessneedsinclude_file_mtime,include_file_ctimeinterplay with the regenerated PCH file.-fpch-preamblealternatives /pch_external_checksum).