All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: linux-kernel@vger.kernel.org
Cc: linux-tiny@selenic.com, devel@laptop.org
Subject: [PATCH 0/4] Compile kernel with -fwhole-program --combine
Date: Thu, 24 Aug 2006 16:24:28 +0100	[thread overview]
Message-ID: <1156433068.3012.115.camel@pmac.infradead.org> (raw)
In-Reply-To: <1156429585.3012.58.camel@pmac.infradead.org>

`-combine'
     If you are compiling multiple source files, this option tells the
     driver to pass all the source files to the compiler at once (for
     those languages for which the compiler can handle this).  This
     will allow intermodule analysis (IMA) to be performed by the
     compiler.  Currently the only language for which this is supported
     is C.  If you pass source files for multiple languages to the
     driver, using this option, the driver will invoke the compiler(s)
     that support IMA once each, passing each compiler all the source
     files appropriate for it.  For those languages that do not support
     IMA this option will be ignored, and the compiler will be invoked
     once for each source file in that language.  If you use this
     option in conjunction with `-save-temps', the compiler will
     generate multiple pre-processed files (one for each source file),
     but only one (combined) `.o' or `.s' file.

`-fwhole-program'
     Assume that the current compilation unit represents 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 a affect gets
     more aggressively optimized by interprocedural optimizers.  While
     this option is equivalent to proper use of `static' keyword for
     programs consisting of single file, in combination with option
     `--combine' this flag can be used to compile most of smaller scale
     C programs since the functions and variables become local for the
     whole combined compilation unit, not for the single source file
     itself.

Using a combination of these two compiler options for building kernel
code leads to some useful optimisation -- especially with modules which
are made up of a bunch of incestuous C files, where none of the global
symbols actually _need_ to be visible outside the directory they reside
in. File systems are a prime example of this -- on PPC64 I see a
reduction in size of ext3.ko by 2.6%, jffs2.ko by 5%, cifs.ko by 8% and
befs.ko by a scary 14%. Strangely, udf.ko seems to have _grown_ by 6.6%
-- that'll probably be another optimisation bug like GCC PR28755.

The same benefits can be extended to the vmlinux too, although there are
caveats with making _everything_ static. However, it's relatively simple
to make EXPORT_SYMBOL() automatically set the 'externally_visible'
attribute on the symbol in question, and to introduce a new '__global'
tag which does the same for those symbols which aren't exported to
modules but which _are_ needed as a global symbol in vmlinux.

Size results from a test build on ppc64 are shown at
http://david.woodhou.se/combine/sizes.csv -- the format is
<old size>,<new size>,<delta>,<percentage * 100>,<object name>

The same file with objects where the size didn't change omitted, and
sorted on percentage is http://david.woodhou.se/combine/sizes-sorted.csv

There are a bunch of GCC bugs which make this interesting:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27898
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27889
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28706
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28712
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28744
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28755
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28779

Fixes (or workarounds) for some of these are at
http://david.woodhou.se/combine/gcc-patches/

(Actual patches will follow, to linux-kernel@vger.kernel.org only)

-- 
dwmw2


       reply	other threads:[~2006-08-24 15:24 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1156429585.3012.58.camel@pmac.infradead.org>
2006-08-24 15:24 ` David Woodhouse [this message]
2006-08-24 16:48   ` [PATCH 0/4] Compile kernel with -fwhole-program --combine Jan Engelhardt
2006-08-24 17:05     ` David Woodhouse
2006-08-25  6:01       ` Jan Engelhardt
2006-08-25  7:26         ` Sam Ravnborg
2006-08-25 10:14           ` David Woodhouse
2006-08-25  8:55         ` David Woodhouse
2006-08-25  9:11           ` Jan Engelhardt
2006-08-25  9:45             ` David Woodhouse
2006-08-25  9:51               ` Jan Engelhardt
2006-08-25 10:01                 ` David Woodhouse
2006-08-24 17:15     ` [OLPC-devel] " Arnd Bergmann
2006-08-24 17:25       ` David Woodhouse
2006-08-24 21:49   ` Adrian Bunk
2006-08-24 21:54     ` David Woodhouse
2006-08-25 20:11   ` Rob Landley
2006-08-25 20:35     ` David Woodhouse
2006-08-26  1:59       ` Segher Boessenkool
2006-08-28 10:52       ` Helge Hafting
2006-08-28 11:03         ` Jan Engelhardt
2006-08-28 11:21         ` David Woodhouse
2006-09-01 19:35           ` Ian Stirling
2006-09-01 21:15             ` David Woodhouse
2006-08-24 15:25 ` [PATCH 1/4] Inconsistent extern declarations David Woodhouse
2006-08-24 16:13   ` Alexey Dobriyan
2006-08-24 17:50     ` David Woodhouse
2006-08-24 21:17   ` Adrian Bunk
2006-08-24 15:26 ` [PATCH 2/4] Core support for --combine -fwhole-program David Woodhouse
2006-08-24 17:27   ` Josh Triplett
2006-08-24 17:33     ` David Woodhouse
2006-08-24 21:33   ` Adrian Bunk
2006-08-25  9:37     ` David Woodhouse
2006-08-25 10:30       ` Adrian Bunk
2006-08-25 10:40         ` David Woodhouse
2006-08-24 15:26 ` [PATCH 3/4] Add __global tag where needed David Woodhouse
2006-08-24 21:30   ` Adrian Bunk
2006-08-25  9:52     ` David Woodhouse
2006-08-25 10:26       ` Adrian Bunk
2006-08-25 10:34         ` David Woodhouse
2006-08-25 10:50           ` Adrian Bunk
2006-08-24 15:28 ` [PATCH 4/4] Some extra --combine hacks David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1156433068.3012.115.camel@pmac.infradead.org \
    --to=dwmw2@infradead.org \
    --cc=devel@laptop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tiny@selenic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.