lkml.org 
[lkml]   [2012]   [Aug]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRFC: Link Time Optimization support for the kernel
Date
This rather large patchkit enables gcc Link Time Optimization (LTO) 
support for the kernel.

With LTO gcc will do whole program optimizations for
the whole kernel and each module. This increases compile time,
but can generate faster code.

LTO allows gcc to inline functions between different files and
do various other optimization across the whole binary.

It might also trigger bugs due to more aggressive optimization.
It allows gcc to drop unused code. It also allows it to check
types over the whole program.

The build slow down is currently between 2-4x (with larger binaries
taking longer). Typical configs with reasonably sized vmlinux
compile with less than 4GB memory, but very large setups (like
allyes) need upto 9GB.

You probably wouldn't use it for development, but it may become
a useful option in the future for release builds.

We see speedups in various benchmarks, but also still a few minor
regressions. There's still some outstanding tuning, both in compile
time and allow gcc even better optimization. Also the kernel currently
triggers some slow behaviour in gcc, which will hopefully improve
in future gcc versions, allowing faster LTO builds.

The kit contains workarounds for various toolchain problems with gcc 4.7.
Part of those will be hopefully removed with some upcoming changes.

Currently a special tool chain setup is needed for LTO, with
gcc 4.7 and HJ Lu's Linux binutils. Please see Documentation/lto-build
for more details on how to install the right versions with the right setup.
The LTO code disables itself if it doesn't find the right toolchain
(however it may not be able to detect all misconfigurations)

This is in the RFC stage at this point. I only tested it on 32bit
and 64bit x86. Other architectures will undoubtedly need more
changes. I would be interested in any testing and benchmarking and
review.

Some options are currently disabled with LTO. MODVERSIONS I plan
to fix. Some others like the FUNCTION_TRACER (who rely on
different options for specific files) may need compiler changes.

This patchkit relies on the separately posted const-sections patchkit
With LTO gcc insists on correct section attributes.

Available from

git://github.com/andikleen/linux-misc lto-3.6 (or -3.5 and -3.7 in the future)

Note the tree is frequently rebased.

Thanks to HJ Lu, Joe Mario, Honza Hubicka, Richard Guenther,
Don Zickus, Changlong Xie who helped with this project
(and probably some more who I forgot, sorry)

-Andi



\
 
 \ /
  Last update: 2012-08-19 06:02    [W:0.459 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site