/build-acceleration
Build acceleration skill for C/C++ projects. Use when reducing compilation times with ccache, sccache, distcc, unity builds, precompiled headers, split DWARF, or IWYU. Covers caching strategies, distributed compilation, link time reduction, and diagnosing build bottlenecks.
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill build-acceleration --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/build-acceleration
Context preview
The summary Claude sees to decide when to auto-load this skill.
Build acceleration skill for C/C++ projects. Use when reducing compilation times with ccache, sccache, distcc, unity builds, precompiled headers, split DWARF, or IWYU. Covers caching strategies, distributed compilation, link time reduction, and diagnosing build bottlenecks.
SKILL.md
build-acceleration.SKILL.mdname: build-acceleration
description: Build acceleration skill for C/C++ projects. Use when reducing compilation times with ccache, sccache, distcc, unity builds, precompiled headers, split DWARF, or IWYU. Covers caching strategies, distributed compilation, link time reduction, and diagnosing build bottlenecks. Activates on queries about slow builds, ccache, sccache, precompiled headers, unity builds, split-DWARF, or reducing C++ compile times.
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
# Time the full build
time cmake --build build -j$(nproc)
# Find the slowest TUs (CMake ≥3.16 with --profiling-output)
cmake -S . -B build -DCMAKE_CXX_FLAGS="-ftime-report"
cmake --build build 2>&1 | grep "Total" | sort -t: -k2 -rn | head -20
# Ninja build timings (use ninja -j1 for serial timing)
ninja -C build -j1 2>&1 | grep "^\[" | sort -t" " -k2 -rn | head -20
2. ccache — compiler cache
# Install
apt-get install ccache # Ubuntu/Debian
brew install ccache # macOS
# Check hit rate
ccache -s
# Configure cache size (default 5GB)
ccache -M 20G
# Invalidate cache if needed
ccache -C
CMake integration (recommended over prefix hacks):
# CMakeLists.txt
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
endif()Key `~/.config/ccache/ccache.conf` options:
max_size = 20G
compression = true
compression_level = 6
# For CI: share cache across jobs
cache_dir = /shared/ccache
3. sccache — cloud-compatible cache (Rust, C/C++)
cargo install sccache
# Or: brew install sccache
# Set as compiler launcher
export RUSTC_WRAPPER=sccache # for Rust
export CMAKE_C_COMPILER_LAUNCHER=sccache # for CMake
# With S3 backend
export SCCACHE_BUCKET=my-build-cache
export SCCACHE_REGION=us-east-1
sccache --start-server
sccache --show-stats
4. Precompiled headers (PCH)
PCH compiles a large header once and reuses the binary form.
# CMake ≥3.16 native PCH support
target_precompile_headers(mylib PRIVATE
<vector>
<string>
<unordered_map>
"myproject/common.h"
)
# Share PCH across targets (avoids recompilation)
target_precompile_headers(myapp REUSE_FROM mylib)// Traditional: stdafx.h / pch.h approach
// All TUs include pch.h as the very first include
// pch.h includes heavy system headers
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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.
# CMake ≥3.16 unity build
set_target_properties(mylib PROPERTIES UNITY_BUILD ON)
# Control batch size (default 8 files per unity TU)
set_target_properties(mylib PROPERTIES UNITY_BUILD_BATCH_SIZE 16)
# Exclude specific files from unity (e.g., if they have ODR issues)
set_source_files_properties(problem.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
Manual unity file:
// unity_build.cpp
#include "module_a.cpp"
#include "module_b.cpp"
#include "module_c.cpp"
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.
# GCC / Clang
gcc -g -gsplit-dwarf -o prog main.c
# CMake global
add_compile_options(-gsplit-dwarf)
# Combine .dwo files for distribution (optional)
dwp -o prog.dwp prog # GNU dwp tool
Pair with `--gdb-index` for faster GDB startup:
gcc -g -gsplit-dwarf -Wl,--gdb-index -o prog main.c
Link time comparison (large project, typical): `-g` full DWARF ~4×–6× longer link vs `-gsplit-dwarf`.
7. distcc — distributed compilation
# Install on all machines
apt-get install distcc
# Start daemon on worker machines
distccd --daemon --allow 192.168.1.0/24 --jobs 8
# Client: set DISTCC_HOSTS
export DISTCC_HOSTS="localhost/4 worker1/8 worker2/8"
make -j20 CC="distcc gcc"
# CMake integration
set(CMAKE_C_COMPILER_LAUNCHER distcc)
set(CMAKE_CXX_COMPILER_LAUNCHER distcc)
Stack with ccache: `CC="ccache distcc gcc"` — ccache checks local cache first, falls back to distcc.
8. Include pruning with IWYU
# Install
apt-get install iwyu
# Run via CMake
cmake -S . -B build -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=iwyu
cmake --build build 2>&1 | tee iwyu.log
# Apply fixes automatically
fix_include < iwyu.log --nosafe_headers
See `skills/build-systems/include-what-you-use` for full IWYU workflow.
For ccache configuration options, see [references/ccache-config.md](references/ccache-config.md).
Related skills
- Use `skills/build-systems/cmake` for CMake project structure
- Use `skills/build-systems/include-what-you-use` for IWYU header pruning
- Use `skills/rust/rust-build-times` for Rust-specific build acceleration
- Use `skills/debuggers/dwarf-debug-format` for split-DWARF internals
Read more
name: build-acceleration description: Build acceleration skill for C/C++ projects. Use when reducing compilation times with ccache, sccache, distcc, unity builds, precompiled headers, split DWARF, or IWYU. Covers caching strategies, distributed compilation, link time reduction, and diagnosing build bottlenecks. Activates on queries about slow builds, ccache, sccache, precompiled headers, unity builds, split-DWARF, or reducing C++ compile times.
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
# Time the full build time cmake --build build -j$(nproc) # Find the slowest TUs (CMake ≥3.16 with --profiling-output) cmake -S . -B build -DCMAKE_CXX_FLAGS="-ftime-report" cmake --build build 2>&1 | grep "Total" | sort -t: -k2 -rn | head -20 # Ninja build timings (use ninja -j1 for serial timing) ninja -C build -j1 2>&1 | grep "^\[" | sort -t" " -k2 -rn | head -20
2. ccache — compiler cache
# Install apt-get install ccache # Ubuntu/Debian brew install ccache # macOS # Check hit rate ccache -s # Configure cache size (default 5GB) ccache -M 20G # Invalidate cache if needed ccache -C
CMake integration (recommended over prefix hacks):
# CMakeLists.txt
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
endif()Key `~/.config/ccache/ccache.conf` options:
max_size = 20G compression = true compression_level = 6 # For CI: share cache across jobs cache_dir = /shared/ccache
3. sccache — cloud-compatible cache (Rust, C/C++)
cargo install sccache # Or: brew install sccache # Set as compiler launcher export RUSTC_WRAPPER=sccache # for Rust export CMAKE_C_COMPILER_LAUNCHER=sccache # for CMake # With S3 backend export SCCACHE_BUCKET=my-build-cache export SCCACHE_REGION=us-east-1 sccache --start-server sccache --show-stats
4. Precompiled headers (PCH)
PCH compiles a large header once and reuses the binary form.
# CMake ≥3.16 native PCH support
target_precompile_headers(mylib PRIVATE
<vector>
<string>
<unordered_map>
"myproject/common.h"
)
# Share PCH across targets (avoids recompilation)
target_precompile_headers(myapp REUSE_FROM mylib)// Traditional: stdafx.h / pch.h approach // All TUs include pch.h as the very first include // pch.h includes heavy system headers #pragma once #include <stdio.h> #include <stdlib.h> #include <string.h>
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.
# CMake ≥3.16 unity build set_target_properties(mylib PROPERTIES UNITY_BUILD ON) # Control batch size (default 8 files per unity TU) set_target_properties(mylib PROPERTIES UNITY_BUILD_BATCH_SIZE 16) # Exclude specific files from unity (e.g., if they have ODR issues) set_source_files_properties(problem.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
Manual unity file:
// unity_build.cpp #include "module_a.cpp" #include "module_b.cpp" #include "module_c.cpp"
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.
# GCC / Clang gcc -g -gsplit-dwarf -o prog main.c # CMake global add_compile_options(-gsplit-dwarf) # Combine .dwo files for distribution (optional) dwp -o prog.dwp prog # GNU dwp tool
Pair with `--gdb-index` for faster GDB startup:
gcc -g -gsplit-dwarf -Wl,--gdb-index -o prog main.c
Link time comparison (large project, typical): `-g` full DWARF ~4×–6× longer link vs `-gsplit-dwarf`.
7. distcc — distributed compilation
# Install on all machines apt-get install distcc # Start daemon on worker machines distccd --daemon --allow 192.168.1.0/24 --jobs 8 # Client: set DISTCC_HOSTS export DISTCC_HOSTS="localhost/4 worker1/8 worker2/8" make -j20 CC="distcc gcc" # CMake integration set(CMAKE_C_COMPILER_LAUNCHER distcc) set(CMAKE_CXX_COMPILER_LAUNCHER distcc)
Stack with ccache: `CC="ccache distcc gcc"` — ccache checks local cache first, falls back to distcc.
8. Include pruning with IWYU
# Install apt-get install iwyu # Run via CMake cmake -S . -B build -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=iwyu cmake --build build 2>&1 | tee iwyu.log # Apply fixes automatically fix_include < iwyu.log --nosafe_headers
See `skills/build-systems/include-what-you-use` for full IWYU workflow.
For ccache configuration options, see [references/ccache-config.md](references/ccache-config.md).
Related skills
- Use `skills/build-systems/cmake` for CMake project structure
- Use `skills/build-systems/include-what-you-use` for IWYU header pruning
- Use `skills/rust/rust-build-times` for Rust-specific build acceleration
- Use `skills/debuggers/dwarf-debug-format` for split-DWARF internals
A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Repo: mohitmishra786/low-level-dev-skills
Other skills on low-level-dev-skills.
- /custom-allocators
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning jemalloc/mimalloc, writing Rust GlobalAlloc, or benchmarking allocator performance. Activates on queries about jemalloc, mimalloc, tcmalloc, arena allocator,
Open skill - /numa-programming
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using libnuma API, building NUMA-aware data structures, or measuring remote access penalties. Activates on queries about numactl, libnuma, NUMA topology,
Open skill - /af-xdp
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT programs, copy vs zero-copy mode, or comparing with DPDK. Activates on queries about AF_XDP, xsk_umem, XDP_REDIRECT, libbpf xsk, or zero-copy XDP.
Open skill - /dpdk
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting up huge pages, RSS, or testpmd validation. Activates on queries about DPDK, EAL, rte_eth_rx_burst, hugepages, PMD, or testpmd.
Open skill - /io-uring
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided buffers, fixed files, zero-copy send, or tokio-uring. Activates on queries about io_uring, SQE/CQE, liburing, IORING_OP_PROVIDE_BUFFERS, or io_uring vs
Open skill - /adc-dac-baremetal
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates on queries about ADC bare-metal, sampling time, DMA ADC, or DAC channel setup.
Open skill

