Re:GCC x86 Performance Hints (2012)
by jhallenworld on Friday August 21, 2020 @10:53AM
(#24235385)
-flto is great at the other end of the spectrum- tiny systems. With "-Os -lto", much unused code from newlib is deleted, allowing the rest to fit in a tiny Cortex-M0 system. In the old days, each function of the C library was in its own object file in the library, but these days this appears to not be the case. But -lto gives the same effect.
[ Parent
| on HN ]
I use it too for embedded. Functions get inlined, fewer registers get saved unnecessarily in functions.
I also use “-fdata-sections -ffunction-sections” with “-Wl,--gc-sections” to prune unused sections.
There is some evidence this can actually increase your code size sometimes: https://stackoverflow.com/a/29951897.