3 ms·
> And because all code is in a single translation unit, compilers can do better inter-procedure and inlining optimization resulting in machine code that is betw
by matheusmoreira 2y ago
> And because all code is in a single translation unit, compilers can do better inter-procedure and inlining optimization resulting in machine code that is between 5% and 10% faster.
It's weird that this is still true even though compilers are now capable of whole program optimization at link time. Enabling LTO should be equivalent to compiling everything as a single translation unit but apparently it isn't. I wonder what exactly inhibits the aforementioned inter-procedural and code inlining optimizations in LTO builds.
- lifthrasiir 2y agoBecause LTO is a global decision while amalgamation (or unity builds) is a local decision. As a global decision, LTO can't be too slow and is subject to heavier trade-offs. Combining files in this way is a local decision that you can just do if you know it would be a-okay and doesn't otherwise impact the whole build.