GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
lto

LTO: Generated Makefiles mark parallel LTRANS outputs as phony

LTO builds now correctly handle parallel LTRANS outputs with -save-temps to avoid stale objects.

When using parallel LTRANS with the -save-temps option, Makefiles generated by the LTO wrapper could produce stale object files. This change marks persistent non-cache LTRANS outputs as ‘phony’ in the Makefile, ensuring that Make reruns the LTRANS recipe for the current link. A new test case verifies the fix, which passed on x86_64 and AArch64.

In Details

Parallel LTRANS invocations in lto-wrapper.cc's run_gcc were generating make targets without prerequisites. When combined with -save-temps, a subsequent link could reuse an old object file if its name collided with a new LTRANS output. Making these outputs 'phony' forces Make to re-execute the compilation step, ensuring the correct object is used.

For Context
LTO
Link-Time Optimization. A compilation technique where the compiler performs optimizations across multiple source files during the linking phase, rather than just on individual compilation units.
LTRANS
The LTO transformation step within GCC that performs inter-file optimizations.
-save-temps
A GCC command-line option that instructs the compiler to retain intermediate files, such as preprocessed source files (.i), assembled files (.s), and object files (.o).
Phony target
In Makefiles, a target that does not correspond to an actual file. 'Phony' targets are typically used for commands like 'clean' or 'all', ensuring the associated recipe runs every time, regardless of whether a file with that name exists.
Filed Under: ltooptimizationmakefile