Build Acceleration
Purpose
Guide agents through reducing C/C++ build times using caching (ccache/sccache), distributed compilation (distcc), unity/jumbo builds, precompiled headers, split-DWARF for faster linking, and include pruning with IWYU.
Triggers
- "My C++ build is too slow — how do I speed it up?"
- "How do I set up ccache / sccache?"
- "How do precompiled headers work with CMake?"
- "How do I set up distributed compilation with distcc?"
- "How do I reduce link times with split-DWARF?"
- "How do I find which headers are slowing down compilation?"
Workflow
1. Diagnose the bottleneck first
2. ccache — compiler cache
CMake integration (recommended over prefix hacks):
Key ~/.config/ccache/ccache.conf options:
3. sccache — cloud-compatible cache (Rust, C/C++)
4. Precompiled headers (PCH)
PCH compiles a large header once and reuses the binary form.
PCH is most effective when headers are large and stable (STL, Boost, Qt). Avoid PCH for frequently-changing project headers.
5. Unity / jumbo builds
Combine multiple .cpp files into one TU to reduce header parsing overhead and improve inlining.
Manual unity file:
Watch out for: anonymous namespaces (each TU has its own), using namespace in headers, duplicate static variables.
6. split-DWARF — reduce link time
Split DWARF puts debug info in .dwo sidecar files, dramatically reducing what the linker must process.
Pair with --gdb-index for faster GDB startup:
Link time comparison (large project, typical): -g full DWARF ~4×–6× longer link vs -gsplit-dwarf.
7. distcc — distributed compilation
Stack with ccache: CC="ccache distcc gcc" — ccache checks local cache first, falls back to distcc.
8. Include pruning with IWYU
See skills/build-systems/include-what-you-use for full IWYU workflow.
For ccache configuration options, see references/ccache-config.md [blocked].
Related skills
- Use
skills/build-systems/cmakefor CMake project structure - Use
skills/build-systems/include-what-you-usefor IWYU header pruning - Use
skills/rust/rust-build-timesfor Rust-specific build acceleration - Use
skills/debuggers/dwarf-debug-formatfor split-DWARF internals


