Dear SeaBIOS folks,
in #coreboot on <irc.freenode.net> Stefan mentioned that link time optimization (LTO) [1] might yield some speed improvements for coreboot as the resulting firmware image might be smaller and therefore it takes less time to read it from flash. This was confirmed with coreboot and GCC 4.6.0 in 2011 by Scott Duplichan [2][3].
The same is true for the payload. As LTO has been greatly improved in GCC 4.9.0 and is currently all over the news, I wanted to build SeaBIOS with LTO, but noticed that it already uses `-fwhole-program`. Reading GCC’s online documentation [1], it says it should not be used in combination with `-lto`.
-fwhole-program Assume that the current compilation unit represents the whole program being compiled. All public functions and variables with the exception of main and those merged by attribute externally_visible become static functions and in effect are optimized more aggressively by interprocedural optimizers. This option should not be used in combination with -flto. Instead relying on a linker plugin should provide safer and more precise information.
Using GCC 4.8.2 from Debian Sid/unstable and just removing `-fwhole-program` and adding `-lto` increased the resulting binary size though.
As I do not know a lot about compilers and linkers, could some expert please comment, if `-fwhole-program` already optimizes the code the best way possible for GCC and therefore LTO is not going to reduce SeaBIOS’ binary size? Unfortunately I did not yet try GCC 4.9.0, so I have no idea if something improved in that version. And probably my hack was incorrect anyway.
Thanks,
Paul
[1] http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html (search for `lto`) [2] http://www.coreboot.org/pipermail/coreboot/2011-April/064859.html [3] http://www.coreboot.org/pipermail/coreboot/2011-May/064874.html