Link Time Optimization
Embedded Studio enables link time optimization to make your code even smaller.
- One-click enable, no tinkering with command-line options
- Linker-independent, works with GNU Linker and SEGGER Linker
- Save up to 10% of ROM
Embedded Studio can run link time optimization (LTO, also intermodular optimization) on your project to produce a smaller application.
LTO is an additional step in the build process which is executed before the actual linking. It combines all input object files into one module and re-assembles it, which enables the compiler to further optimize code that came from different sources.
Link time optimization does not require changes in the source code or the linker scripts. You can simply enable it in the project options of your release configuration.
Embedded Studio's link time optimization can be used with the legacy GNU Linker as well as with the modern SEGGER Linker. In contrast to standard (GCC) makefile-based build systems, Embedded Studio made LTO an independent, stand-alone step.
Link time optimization mainly works on code and constant data and can reduce the ROM (Flash) requirements by up to 10%.
Use LTO in Embedded Studio
To use link time optimization in Embedded Studio, you simply need to enable it.
- Open the Project Properties (Right-click on the project in Project Explorer -> Options...
- Select the configuration you want LTO to be enabled in (usually your Release configuration)
- Set "Link Time Optimization" to "Yes".
LTO is ideally used with an application that is set to be optimized for size (set "Optimization Level" to "Optimize For Size").
When you now build your application, you will see an additional step "Link Time Optimization" before "Linking" in the Output Window.