public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Miller <davem@davemloft.net>,
	akpm@linux-foundation.org, rdreier@cisco.com,
	ian.campbell@citrix.com, jeremy.fitzhardinge@citrix.com,
	deller@gmx.de, rusty@rustcorp.com.au,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	kyle@mcmartin.ca, randolph@tausq.org, sam@ravnborg.org,
	dave@hiauly1.hia.nrc.ca
Subject: Re: [PATCH] kbuild: Disallow GCC 4.1.0 / 4.1.1
Date: Fri, 2 Jan 2009 18:44:24 +0100	[thread overview]
Message-ID: <20090102174424.GA14065@elte.hu> (raw)
In-Reply-To: <alpine.LFD.2.00.0901020844070.5086@localhost.localdomain>


* Linus Torvalds <torvalds@linux-foundation.org> 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

------------->
>From bb951ce0794f0e5974b834eb14e974a0a2c119db Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Fri, 2 Jan 2009 12:46:22 +0100
Subject: [PATCH] kbuild: Disallow GCC 4.1.0 / 4.1.1

Impact: fix crashes that can trigger if built with GCC 4.1.0 or 4.1.1

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.

In the past we tried to work around this problem by artificially
isolating call site and definition site - but these bugs tend to
pop up regularly:

 43a2563: sparseirq: move __weak symbols into separate compilation unit
 13a0c3c: sparseirq: work around compiler optimizing away __weak functions

And Linus has extended Sparse to report same-file callsites for __weak
symbols - which gave two dozen hits.

We have not found a clean way to work around this bug on the source
code level (noinline and explicit barrier()s are ignored by GCC), 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).

Kernel builds under gcc 410 or 411 will now fail with this error message:

  Sorry, GCC 4.1.0/4.1.1 are too buggy to build the kernel - please
  upgrade to 4.1.2 or later versions.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 include/linux/compiler-gcc3.h |    4 ++++
 include/linux/compiler-gcc4.h |   14 ++++++++++++++
 include/linux/compiler.h      |    4 ++--
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h
index e5eb795..a929a6d 100644
--- a/include/linux/compiler-gcc3.h
+++ b/include/linux/compiler-gcc3.h
@@ -2,6 +2,10 @@
 #error "Please don't include <linux/compiler-gcc3.h> directly, include <linux/compiler.h> instead."
 #endif
 
+#if __GNUC_MINOR__ < 2
+# error Sorry, your compiler is too old - please upgrade it.
+#endif
+
 /* These definitions are for GCC v3.x.  */
 #include <linux/compiler-gcc.h>
 
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 974f5b7..b1edc9d 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -2,6 +2,20 @@
 #error "Please don't include <linux/compiler-gcc4.h> directly, include <linux/compiler.h> instead."
 #endif
 
+/*
+ * 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):
+ */
+#if __GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ <= 1
+# error Sorry, GCC 4.1.0/4.1.1 are too buggy to build the kernel - please upgrade to 4.1.2 or later versions.
+#endif
+
 /* These definitions are for GCC v4.x.  */
 #include <linux/compiler-gcc.h>
 
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index ea7c6be..18edc7a 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -38,10 +38,10 @@ extern void __chk_io_ptr(const volatile void __iomem *);
 
 #if __GNUC__ >= 4
 # include <linux/compiler-gcc4.h>
-#elif __GNUC__ == 3 && __GNUC_MINOR__ >= 2
+#elif __GNUC__ == 3
 # include <linux/compiler-gcc3.h>
 #else
-# error Sorry, your compiler is too old/not recognized.
+# error Sorry, your compiler is too old or not recognized.
 #endif
 
 #define notrace __attribute__((no_instrument_function))

  parent reply	other threads:[~2009-01-02 17:45 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-29 20:34 [PATCH] parisc: fix module loading failure of large kernel modules (take 2) Helge Deller
2008-12-29 20:43 ` [PATCH 1/2] module.c: fix module loading failure of large " Helge Deller
     [not found]   ` <20081230180724.GA15235@bombadil.infradead.org>
2008-12-30 18:10     ` Kyle McMartin
2008-12-30 18:18       ` Helge Deller
2008-12-30 19:42         ` [PATCH 1/2] module.c: fix module loading failure of large modules (take 3) Helge Deller
2008-12-29 20:45 ` [PATCH 2/2] parisc: fix module loading failure of large modules (take 2) Helge Deller
2008-12-30 19:55   ` [PATCH 2/2] parisc: fix module loading failure of large modules (take 3) Helge Deller
2008-12-30 22:45 ` [PATCH] parisc: fix module loading failure of large kernel modules (take 2) Rusty Russell
2008-12-30 23:02   ` Helge Deller
2008-12-31  4:08     ` Rusty Russell
2008-12-31 11:31   ` [PATCH] parisc: fix module loading failure of large kernel modules (take 4) Helge Deller
2008-12-31 11:36     ` [PATCH 2/2] parisc: fix module loading failure of large modules Helge Deller
2008-12-31 13:32     ` [PATCH] parisc: fix module loading failure of large kernel modules (take 4) Rusty Russell
2008-12-31 14:13       ` Helge Deller
2009-01-01  0:52         ` Rusty Russell
2009-01-01 12:02           ` Helge Deller
2008-12-31 17:29     ` Linus Torvalds
2008-12-31 17:36       ` Roland Dreier
2008-12-31 17:47         ` Linus Torvalds
2008-12-31 18:02           ` Linus Torvalds
2008-12-31 18:11           ` Sam Ravnborg
2009-01-02 11:31             ` Ingo Molnar
2008-12-31 18:54           ` Andrew Morton
2008-12-31 21:22             ` Linus Torvalds
2008-12-31 22:14               ` David Miller
2009-01-02 11:55                 ` [PATCH] kbuild: Disallow GCC 4.1.0 / 4.1.1 Ingo Molnar
2009-01-02 13:43                   ` Bartlomiej Zolnierkiewicz
2009-01-02 15:21                     ` [PATCH] kbuild: Remove gcc 4.1.0 quirk from init/main.c Ingo Molnar
2009-01-02 18:05                       ` Sam Ravnborg
2009-01-02 16:49                   ` [PATCH] kbuild: Disallow GCC 4.1.0 / 4.1.1 Linus Torvalds
2009-01-02 17:38                     ` Linus Torvalds
2009-01-02 17:46                       ` Ingo Molnar
2009-01-02 17:54                         ` [PATCH] Disallow gcc versions 3.{0,1} Ingo Molnar
2009-01-02 17:58                         ` [PATCH] kbuild: Disallow GCC 4.1.0 / 4.1.1 Linus Torvalds
2009-01-02 18:01                           ` Ingo Molnar
2009-01-02 18:05                             ` Linus Torvalds
2009-01-02 18:08                               ` Linus Torvalds
2009-01-02 19:54                               ` Willy Tarreau
2009-01-02 20:18                                 ` Linus Torvalds
2009-01-02 17:57                       ` Sam Ravnborg
2009-01-02 18:04                         ` Linus Torvalds
2009-01-02 18:27                           ` Sam Ravnborg
2009-01-02 18:28                             ` Randy Dunlap
2009-01-02 18:51                           ` Al Viro
2009-01-02 19:14                             ` Andi Kleen
2009-01-02 22:52                               ` Al Viro
2009-01-03 14:03                           ` Krzysztof Halasa
2009-01-02 18:22                         ` Ingo Molnar
2009-01-02 18:29                           ` Sam Ravnborg
2009-01-02 18:33                             ` Ingo Molnar
2009-01-02 19:05                               ` Detlef Riekenberg
2009-01-02 22:27                         ` Benjamin Herrenschmidt
2009-01-02 22:37                           ` Sam Ravnborg
2009-01-02 17:44                     ` Ingo Molnar [this message]
2009-01-01 14:24               ` [PATCH] parisc: fix module loading failure of large kernel modules (take 4) Ingo Molnar
2009-01-01 16:37                 ` Andrew Morton
2008-12-31 17:39       ` Helge Deller
2008-12-31 18:24       ` James Bottomley
2008-12-31 22:16       ` Rusty Russell
2009-01-01  7:12       ` Jeremy Fitzhardinge

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=20090102174424.GA14065@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=dave@hiauly1.hia.nrc.ca \
    --cc=davem@davemloft.net \
    --cc=deller@gmx.de \
    --cc=ian.campbell@citrix.com \
    --cc=jeremy.fitzhardinge@citrix.com \
    --cc=kyle@mcmartin.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=randolph@tausq.org \
    --cc=rdreier@cisco.com \
    --cc=rusty@rustcorp.com.au \
    --cc=sam@ravnborg.org \
    --cc=torvalds@linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox