Optimize performance using Link-Time Optimization with GCC
Introduction
An LTO Primer
Deploying LTO
Potential Gains
Next Steps
Optimize performance using Link-Time Optimization with GCC
Review frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
Yes. Compile each translation unit with
-flto and also pass -flto to the final link so that GCC performs whole‑program optimization.Use a single
gcc invocation that includes your optimization level and -flto. This compiles and links with LTO enabled in one step.Object files contain LTO information in special sections. The final link performs whole‑program optimization before generating machine code.
Confirm that all compile steps and the final link included
-flto. If -flto is missing from any step, the link won’t perform whole‑program optimization.Compare runtime and binary size before and after enabling
-flto. Refer to the SPEC CPU2017 integer rate as an example framework to understand potential performance changes.