Optimize performance using Link-Time Optimization with GCC

Explore related resources

Find more information about the topics in this Learning Path:

Give feedback

How would you rate this Learning Path?

Review frequently asked questions

AI-assisted

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.

Close
?
Do I need to pass -flto at both compile and link time?
Yes. Compile each translation unit with -flto and also pass -flto to the final link so that GCC performs whole‑program optimization.
How do I build a small program with LTO in one command?
Use a single gcc invocation that includes your optimization level and -flto. This compiles and links with LTO enabled in one step.
What should I expect from the linker when LTO is enabled?
Object files contain LTO information in special sections. The final link performs whole‑program optimization before generating machine code.
How do I know LTO was applied to my build?
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.
How should I evaluate the impact of LTO on my application?
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.

Share

Tell others about this Learning Path.

Back
Return to Servers and Cloud Computing