This is a link collection for the talk I held at stockholm c++ meetup where I talked about how to compile c++ faster.
The slides can be found here: https://docs.google.com/presentation/d/e/2PACX-1vQnImhVyHCiZka4wRmnhISq7O8wl6wvf0zmja2HNsiBDF4l6xBL6fXwFXHjdEpIsvZkiRhNNQBXmNuP/pub?start=false&loop=false&delayms=3000
- 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=gold
and-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.
- Rebuild clang with LTO, the relevant flag is
LLVM_ENABLE_LTO
but 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
-fvisibility=hidden
- https://gcc.gnu.org/wiki/Visibility-fexperimental-new-pass-mananger
- This should be combined with theMake Clang Faster
topic above. Not so experimental any more - google is using it by default for example.- distcc - distributed compiler
-ftime-trace
get flame graphs for your own code!