• prefer ninja over make when possible.

  • if using make, use the flags -r and -j`nproc`.
    • -r greatly improves “do nothing” build speed.
      When I started using it “do nothing” went from 0.6 seconds to 0.02, eliminating
      an annoying lag when launching via IDE.

  • use LLVM’s LLD linker.
    compiler flag: -fuse-ld=lld
    • if you’re using precompiled headers it only works with Clang’s precompiled headers.
      • if GCC gives you better performance, you can use Clang for development only.
    • if you can’t use LLD, alternatively you can use GOLD linker, which slower than LLD but faster than the default LD.
      compiler flag: -fuse-ld=gold

  • use Clang ThinLTO with caching.
    In my testing it’s faster than not using LTO at all.
    compiler flags: -flto=thin -Wl,--thinlto-cache-dir=...
    • in my project it resulted x2.3 speedup.

  • use -pipe compiler flag.
    make sure you have enough RAM for big projects.


  • use forward declarations to move #includes from headers to .cpp files.
    This can help eliminate dependencies and reduce incremental build time.


  • Fast storage can make compilation several times faster.
    In my experience switching from HDD to SSD resulted ~x10 speedup.

  • More cores for parallel builds.

  • RAM consumption can scale up with parallel builds, especially when using -pipe.
    I’ve reached ~30GB RAM usage while compiling a medium sized project, with 16c/32t CPU.
    So at least 1GB per CPU thread should be a good heuristic.