IT lexicon › Programming › Link-time optimization (LTO)

Link-time optimization (LTO)

Programming På svenska → Updated: 2026-11-05

Optimization deferred until link time, so the compiler sees the whole program instead of one source file at a time.

C and C++ are traditionally compiled file by file, and a function in a.c can't be inlined into b.c because the compiler never sees both at once. With LTO the compiler writes its intermediate representation into the object files instead of finished machine code, and the linker calls back into the optimizer once everything is on the table.

GCC gained -flto in version 4.5 in 2010; Microsoft already had its Whole Program Optimization. The catch was that the link step became one giant, memory-hungry job that wouldn't parallelise. LLVM's ThinLTO (2016) fixed that by sharing only summaries between modules and optimizing them in parallel, which made LTO practical even for web browsers.

← Back to the lexicon