Earlier quoted context omitted.
* Compile with clang, link with mold or at least lld. mold can link gigabyte-sized binaries in, like, one second * Use ninja instead of make * Use PCH * -gsplit-dwarf
This is all solid advice (particularly using a faster linker). IME, the single best way to reduce your C++ compile times is to compile less code : * Remove all unnecessary headers. Template expansion is slow, and preprocessing is even slower. Some of the standard includes (like ` ` and ` `) are notorious for slowing individual translation units to a crawl. `#pragma once` for your own headers also helps with cpp-time…
Substantial improvement in compilation speed might depend on use of JIT techniques, running generated code in the compiler to perform template evaluation. I.e., a template is not just a data structure, it is a compile-time function that, where used much, is compiled to optimized machine code, its run-time values being what we think of as types. Thus far, all these functions are run like an interpreter walking a syntax tree.
Precompiled headers, or module intermediate files, could have this code in them already optimized.