Kbuild, lto: Add Link Time Optimization support
XXX update description
With LTO gcc will do whole program optimizations for
the whole kernel and each module. This increases compile time,
but can generate faster and smaller code and allows
the compiler to do global checking. For example the compiler
can complain now about type mismatches for symbols between
different files.
Unlike earlier, this version doesn't require special
binutils, but relies on THIN_ARCHIVES instead.
LTO allows gcc to inline functions between different files and
do various other optimization across the whole binary.
Also incremenential rebuilds are somewhat
slower, as the whole kernel always needs to be reoptimized.
Very modular kernels have less build time slow down, as
the LTO will run for each module individually.
XXX add new timing on gcc 5.0
This adds the basic Kbuild plumbing for LTO:
- In Kbuild add a new scripts/Makefile.lto that checks
the tool chain (note the checks may not be fully bulletproof)
and when the tests pass sets the LTO options
Currently LTO is very finicky about the tool chain.
- Add a new LDFINAL variable that controls the final link
for vmlinux or module. In this case we call gcc-ld instead
of ld, to run the LTO step.
- Kconfigs:
Since LTO with allyesconfig needs more than 4G of memory (~8G)
XXX update number
and has the potential to makes people's system swap to death.
I used a nested config that ensures that a simple
allyesconfig disables LTO. It has to be explicitely
enabled.
XXX this can be fixed
LTO is disabled for the real mode code and for the VDSO.
It also is currently disabled for some crypto modules
(cast6, cammelia) which have unresolved symbols with LTO.
Some dependencies on other Kconfigs:
- MODVERSIONS causes problems currently, so it's also
disabled
Thanks to HJ Lu, Joe Mario, Honza Hubicka, Richard Guenther,
Don Zickus, Changlong Xie, Gleb Schukin who helped with this project
(and probably some more who I forgot, sorry)
<old version numbers dropped>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
13 files changed