5.7.7.31 Lto Option

This -flto option runs the standard link-time optimizer.

When invoked with source code, the compiler adds an internal bytecode representation of the code to special sections in the object file. When the object files are linked together, all the function bodies are read from these sections and instantiated as if they had been part of the same translation unit. Link time optimizations do not require the presence of the whole program to operate.

To use the link-timer optimizer, specify -flto both at compile time and during the final link. For example:
xc32-gcc -c -O3 -flto -mprocessor=ATSAME70N20B foo.c
xc32-gcc -c -O3 -flto -mprocessor=ATSAME70N20B bar.c
xc32-gcc -o myprog.elf -flto -O3 -mprocessor=ATSAME70N20B foo.o bar.o
Another (simpler) way to enable link-time optimization is:
xc32-gcc -o myprog.elf -flto -O3 -mprocessor=ATSAME70N20B foo.c bar.c

The bytecode files are versioned and there is a strict version check, so bytecode files generated in one version of the XC32 compiler might not work with a different version.

The -fno-lto form of this option does not run the standard link-time optimizer. This is the default action if this option is not specified.