Re: [PATCH] kbuild: Disallow GCC 4.1.0 / 4.1.1

From: Ingo Molnar
Date: Fri Jan 02 2009 - 12:45:07 EST



* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

>
>
> On Fri, 2 Jan 2009, Ingo Molnar wrote:
> > --- a/include/linux/compiler.h
> > +++ b/include/linux/compiler.h
> > @@ -36,12 +36,25 @@ extern void __chk_io_ptr(const volatile void __iomem *);
> >
> > #ifdef __KERNEL__
> >
> > -#if __GNUC__ >= 4
> > +/*
> > + * GCC 4.1.0 and 4.1.1 has a bug that can miscompile __weak symbols,
> > + * by inlining __weak functions into same-file call sites - breaking the
> > + * kernel if the __weak symbol is overriden later on.
> > + *
> > + * We have not found a clean way to work around this bug on the source
> > + * code level, so we do not allow these compilers (which are quite
> > + * rare these days, have other bugs and are superceded by the 4.1.2
> > + * bugfix release anyway):
> > + */
> > +#define gcc41_inlining_bug \
> > + (__GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ <= 1)
> > +
> > +#if __GNUC__ >= 4 && !gcc41_inlining_bug
> > # include <linux/compiler-gcc4.h>
>
> I think this is wrong.
>
> Just move the check into <linux/compiler-gcc4.h>
>
> It makes no sense to do stuff that is specific to gcc4 in the general
> gcc header file. It seems you did this just in order to re-use a (bad)
> generic error case.

yeah. I first hacked the generic check then saw how ugly the end result
was and moved it one level higher. Which was less ugly than where it came
from and not much worse than the starting point (so it passed my filters)
but still not clean enough (so it didnt pass your filters).

How about the patch below instead? It cleans up the generic check by
splitting all the per-major-version checks out into gcc4 and gcc3.

(still untested)

Ingo

------------->