This is a link collection for the talk I held at stockholm c++ meetup where I talked about how to compile c++ faster.
- We are using Conan as our package manager and we talked about this setup in another talk.
- We use LLVM/Clang 8.0.1 as our compiler
- CMake and Ninja is our build system
- Switch linker to gold or lld - With clang you can pass
-fuse-ld=lld. If you are using gcc you need to update default ld symlink to point to gold instead. See this for an example: https://gist.github.com/daniel-j-h/ed3bf9e5cb458b012b5a
- Precompiled headers with CMake 3.16: target_precompile_headers()
- Cache objects with ccache
- Unity builds in CMake 3.16: CMAKE_UNITY_BUILD=ON
- PMIPL - Restructure your code according to the rules of pointer to implementation.
Make Clang Faster!
- Rebuild clang with LTO, the relevant flag is
LLVM_ENABLE_LTObut I think this document is requuired to read more about building llvm/clang: https://llvm.org/docs/CMake.html
- Rebuild clang with PGO. This document gives a good overview: https://llvm.org/docs/HowToBuildWithPGO.html
- Post-link optimizitaion of clang with llvm-bolt and llvm-propeller
-fexperimental-new-pass-mananger- This should be combined with the
Make Clang Fastertopic above. Not so experimental any more - google is using it by default for example.
- distcc - distributed compiler
-ftime-traceget flame graphs for your own code!