Improving C++ builds 1
Tricks:
- compilers do a lot less in Debug, use it in development
- minimze optimizations
- remove unreachable or dead code
- cppcheck, Coverity, Understand, CppDepend, OCLint, gcov...
- unused sources, libraries
- commonly used sources => static libraries
- use granular includes
- applications (bad includes): Resharper C++ Analyzer, Doxygen + Graphviz, IWYU...
- move definitions from header files
- use link time optimization (or unity build) for inlining
- use forward declarations where feasible
- 3rd party code
- create wrapper types/headers for 3rd party libraries
- create forward declaration headers
- PIMPL
- preserves ABI
- tricks
- pre-compiled headers
- ubity builds
Watch the rule of chiel (from fastest to slowest)
- look up memoized type
- add a parameter to an alias call
- add a parameter to a type
- call an alias
- instantiate a type
- instantiate a function template
- SFINAE
Templates
- diagnostics:
-ftime-reportandtemplight
Dynamic linking
- in Unix compile with
-fvisibility=hidden
Linkers
-
lld
-
CMake -
LINK_WHAT_YOU_USE -
cmake --graphviz=[file]