GCC since version 4.5 has supporting LTO building. In this mode, compiling cpp files to object files does not emit the final assembly code yet, but an intermediate representation which is used to produce the assembly at link time. This allows the compiler to perform inter-module optimizations; most notably it permits inlining across module boundaries.
Advantages:
- Smaller binaries (code from headers does not get duplicated into multiple objects anymore).
- Faster code (more optimization opportunities)
- Lower build-time memory requirements
Downsides:
- Slower building
- Requires modern compilers
- Debugging sometimes gets harder
- Before GCC 4.8: double size object files
I believe we should consider producing release binaries created using LTO, if the compiler is sufficiently modern. It categorically removes the concern about whether code should go in header files or not (before, moving implementations to .h files would sometimes be needed for performance reasons - with LTO that is not a good reason anymore).
Opinions?