Re: [patch 00/2] improve .text size on gcc 4.0 and newer compilers

Linus Torvalds
2005-12-28T19:17:38Z

On Wed, 28 Dec 2005, Ingo Molnar wrote:
>
> this patchset (for the 2.6.16 tree) consists of two patches:
>
> gcc-no-forced-inlining.patch
> gcc-unit-at-a-time.patch

Why do you mix the two up? I'd assume they are independent, and if they
aren't, please explain why?

The forced inlining is not just a good idea. Several versions of gcc would
NOT COMPILE the kernel without it. The fact that it works with your
configurations and your particular compiler version has absolutely ZERO
relevance.

Gcc has had horrible mistakes in inlining functions. Inlining too much,
and quite often, not inlining things that absolutely _have_ to be inlined.
Trivial things that inline to an instruction or two, but that look
complicated because they have a big switch-statement that just happens to
be known at compile-time.

And not inlining them not only results in horribly bad code (dynamic tests
for something that should be static), but also results in link errors when
cases that should be statically unreachable suddenly become reachable
after all.

So the fact that your gcc-4.x version happens to get things right for your
case in no way means that you can do this in general.

Also, the inlining patch apparently makes code larger in some cases, so
it's not even a unconditional win.

What's the effect of _just_ the "unit-at-a-time" thing which we can (and
you did) much more easily make gcc-version-dependent?

Linus