2008-06-26 14:32:39

by Benny Halevy

[permalink] [raw]
Subject: [PATCH] fix extern inline errors with gcc 4.3.0

gcc 4.3.0 needs -funit-at-a-time for extern inline functions
otherwise it doesn't find their body.

For example:
$ gcc --version
gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)

/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/fs/buffer.c: In function ‘alloc_page_buffers’:
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/fs/buffer.c:51: sorry, unimplemented: inlining failed in call to ‘init_buffer’: function body not available
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/fs/buffer.c:948: sorry, unimplemented: called from here

Fix follows the lines of commit 22eecde2f9034764a3fd095eecfa3adfb8ec9a98
that was reverted by commit c0a18111e571138747a98af18b3a2124df56a0d1,
just limiting the flag for pre- gcc 4.3.0 rather than 4.0.

Signed-off-by: Benny Halevy <[email protected]>
---
arch/um/Makefile | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/um/Makefile b/arch/um/Makefile
index dbeab15..e7ed37b 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -77,7 +77,11 @@ include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
-Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
KBUILD_CFLAGS += $(KERNEL_DEFINES)
-KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
+# Disable unit-at-a-time mode on pre-gcc-4.3 compilers, it makes gcc use
+# a lot more stack due to the lack of sharing of stacklots:
+# gcc 4.3.0 needs -funit-at-a-time for extern inline functions
+KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0403 ] ; then \
+ echo $(call cc-option,-fno-unit-at-a-time); fi ;)

PHONY += linux

--
1.5.6.GIT


2008-06-27 17:12:28

by Jeff Dike

[permalink] [raw]
Subject: Re: [PATCH] fix extern inline errors with gcc 4.3.0

On Thu, Jun 26, 2008 at 04:50:51PM +0300, Benny Halevy wrote:
> -KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
> +# Disable unit-at-a-time mode on pre-gcc-4.3 compilers, it makes gcc use
> +# a lot more stack due to the lack of sharing of stacklots:
> +# gcc 4.3.0 needs -funit-at-a-time for extern inline functions
> +KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0403 ] ; then \
> + echo $(call cc-option,-fno-unit-at-a-time); fi ;)

How do we know that this patch won't cause the same crash reported in
http://marc.info/?l=linux-kernel&m=121011722806093&w=2?

Jeff

--
Work email - jdike at linux dot intel dot com

2008-06-28 13:14:41

by Benny Halevy

[permalink] [raw]
Subject: RE: [PATCH] fix extern inline errors with gcc 4.3.0

On Fri 2008-06-27 19:26, Jeff Dike <[email protected]> wrote:
> On Thu, Jun 26, 2008 at 04:50:51PM +0300, Benny Halevy wrote:
> > -KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
> > +# Disable unit-at-a-time mode on pre-gcc-4.3 compilers, it makes gcc use
> > +# a lot more stack due to the lack of sharing of stacklots:
> > +# gcc 4.3.0 needs -funit-at-a-time for extern inline functions
> > +KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0403 ] ; then \
> > + echo $(call cc-option,-fno-unit-at-a-time); fi ;)
>
> How do we know that this patch won't cause the same crash reported in
> http://marc.info/?l=linux-kernel&m=121011722806093&w=2?

I don't know what was the root cause for the crash you mentioned.
FWIW, with these options UML/x86_64 builds on Fedora 9, w/ gcc 4.3.0
and runs well for me.

Benny

>
> Jeff
>
> --
> Work email - jdike at linux dot intel dot com
>

2008-06-29 07:32:59

by Benny Halevy

[permalink] [raw]
Subject: Re: [PATCH] fix extern inline errors with gcc 4.3.0

On Jun. 28, 2008, 16:10 +0300, "Halevy, Benny" <[email protected]> wrote:
> On Fri 2008-06-27 19:26, Jeff Dike <[email protected]> wrote:
>> On Thu, Jun 26, 2008 at 04:50:51PM +0300, Benny Halevy wrote:
>>> -KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
>>> +# Disable unit-at-a-time mode on pre-gcc-4.3 compilers, it makes gcc use
>>> +# a lot more stack due to the lack of sharing of stacklots:
>>> +# gcc 4.3.0 needs -funit-at-a-time for extern inline functions
>>> +KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0403 ] ; then \
>>> + echo $(call cc-option,-fno-unit-at-a-time); fi ;)
>> How do we know that this patch won't cause the same crash reported in
>> http://marc.info/?l=linux-kernel&m=121011722806093&w=2?

Note that the crash happened with gcc 4.1.2 and it will get the
-fno-unit-at-a-time flag with the proposed patch.

That said, this option or the lack of it ought not to cause any
runtime crashes. If it does, I'd feel much more comfortable to know
exactly what the root cause is before deciding to use the flag to
workaround^hide it.

Benny

>
> I don't know what was the root cause for the crash you mentioned.
> FWIW, with these options UML/x86_64 builds on Fedora 9, w/ gcc 4.3.0
> and runs well for me.
>
> Benny
>
>> Jeff
>>
>> --
>> Work email - jdike at linux dot intel dot com
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2008-06-30 16:22:45

by Jeff Dike

[permalink] [raw]
Subject: Re: [PATCH] fix extern inline errors with gcc 4.3.0

On Sun, Jun 29, 2008 at 10:32:43AM +0300, Benny Halevy wrote:
> Note that the crash happened with gcc 4.1.2 and it will get the
> -fno-unit-at-a-time flag with the proposed patch.
>
> That said, this option or the lack of it ought not to cause any
> runtime crashes. If it does, I'd feel much more comfortable to know
> exactly what the root cause is before deciding to use the flag to
> workaround^hide it.

I agree.

The constraints on [no-]unit-at-a-time that I see are:
i386 uses no-unit-at-a-time for pre-4.0 (not 4.3)
x86_64 uses unit-at-a-time always

Uli reported a crash on x86_64 with gcc 4.1.2 with unit-at-a-time
Ingo reported a gcc internal error with gcc 4.3 with
no-unit-at-a-time
You are seeing extern inlines not resolved with gcc 4.3 with
no-unit-at-a-time

I'm tempted to follow x86 on this, with the results that
extern inlines should be fine
Ingo's gcc crash should not reappear
Uli's crash may reappear

If that crash does come back, I'd say we should just debug it. It's
likely UML implicitly relying on some gcc behavior anyway.

This is the patch that I'm dropping into my tree:

Index: linux-2.6.22/arch/um/Makefile-i386
===================================================================
--- linux-2.6.22.orig/arch/um/Makefile-i386 2008-05-29 11:21:25.000000000 -0400
+++ linux-2.6.22/arch/um/Makefile-i386 2008-06-30 12:20:01.000000000 -0400
@@ -32,4 +32,10 @@ cflags-y += $(call cc-option,-mpreferred
# an unresolved reference.
cflags-y += -ffreestanding

+# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
+# a lot more stack due to the lack of sharing of stacklots. Also, gcc
+# 4.3.0 needs -funit-at-a-time for extern inline functions.
+KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0403 ] ; then \
+ echo $(call cc-option,-fno-unit-at-a-time); fi ;)
+
KBUILD_CFLAGS += $(cflags-y)
Index: linux-2.6.22/arch/um/Makefile-x86_64
===================================================================
--- linux-2.6.22.orig/arch/um/Makefile-x86_64 2008-05-29 11:21:25.000000000 -0400
+++ linux-2.6.22/arch/um/Makefile-x86_64 2008-06-30 12:21:01.000000000 -0400
@@ -21,3 +21,6 @@ HEADER_ARCH := x86

LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
LINK-y += -m64
+
+# Do unit-at-a-time unconditionally on x86_64, following the host
+KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)

Jeff

--
Work email - jdike at linux dot intel dot com

2008-06-30 16:37:42

by Benny Halevy

[permalink] [raw]
Subject: Re: [PATCH] fix extern inline errors with gcc 4.3.0

On Jun. 30, 2008, 19:22 +0300, Jeff Dike <[email protected]> wrote:
> On Sun, Jun 29, 2008 at 10:32:43AM +0300, Benny Halevy wrote:
>> Note that the crash happened with gcc 4.1.2 and it will get the
>> -fno-unit-at-a-time flag with the proposed patch.
>>
>> That said, this option or the lack of it ought not to cause any
>> runtime crashes. If it does, I'd feel much more comfortable to know
>> exactly what the root cause is before deciding to use the flag to
>> workaround^hide it.
>
> I agree.
>
> The constraints on [no-]unit-at-a-time that I see are:
> i386 uses no-unit-at-a-time for pre-4.0 (not 4.3)
> x86_64 uses unit-at-a-time always
>
> Uli reported a crash on x86_64 with gcc 4.1.2 with unit-at-a-time
> Ingo reported a gcc internal error with gcc 4.3 with
> no-unit-at-a-time
> You are seeing extern inlines not resolved with gcc 4.3 with
> no-unit-at-a-time
>
> I'm tempted to follow x86 on this, with the results that
> extern inlines should be fine
> Ingo's gcc crash should not reappear
> Uli's crash may reappear
>
> If that crash does come back, I'd say we should just debug it. It's
> likely UML implicitly relying on some gcc behavior anyway.

Agreed.

>
> This is the patch that I'm dropping into my tree:
>
> Index: linux-2.6.22/arch/um/Makefile-i386
> ===================================================================
> --- linux-2.6.22.orig/arch/um/Makefile-i386 2008-05-29 11:21:25.000000000 -0400
> +++ linux-2.6.22/arch/um/Makefile-i386 2008-06-30 12:20:01.000000000 -0400
> @@ -32,4 +32,10 @@ cflags-y += $(call cc-option,-mpreferred
> # an unresolved reference.
> cflags-y += -ffreestanding
>
> +# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
> +# a lot more stack due to the lack of sharing of stacklots. Also, gcc
> +# 4.3.0 needs -funit-at-a-time for extern inline functions.
> +KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0403 ] ; then \

This isn't exactly aligned with the comment above.
Should be -lt 0400, as in 22eecde2f9034764a3fd095eecfa3adfb8ec9a98?

> + echo $(call cc-option,-fno-unit-at-a-time); fi ;)
> +
> KBUILD_CFLAGS += $(cflags-y)
> Index: linux-2.6.22/arch/um/Makefile-x86_64
> ===================================================================
> --- linux-2.6.22.orig/arch/um/Makefile-x86_64 2008-05-29 11:21:25.000000000 -0400
> +++ linux-2.6.22/arch/um/Makefile-x86_64 2008-06-30 12:21:01.000000000 -0400
> @@ -21,3 +21,6 @@ HEADER_ARCH := x86
>
> LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
> LINK-y += -m64
> +
> +# Do unit-at-a-time unconditionally on x86_64, following the host
> +KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)

Hmm, arch/um/Makefile includes $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
before add -fno-unit-at-a-time to KBUILD_CFLAGS.
Will this override the flag set first here?

Benny

>
> Jeff
>

2008-06-30 16:43:49

by Adrian Bunk

[permalink] [raw]
Subject: Re: [PATCH] fix extern inline errors with gcc 4.3.0

On Mon, Jun 30, 2008 at 12:22:01PM -0400, Jeff Dike wrote:
> On Sun, Jun 29, 2008 at 10:32:43AM +0300, Benny Halevy wrote:
> > Note that the crash happened with gcc 4.1.2 and it will get the
> > -fno-unit-at-a-time flag with the proposed patch.
> >
> > That said, this option or the lack of it ought not to cause any
> > runtime crashes. If it does, I'd feel much more comfortable to know
> > exactly what the root cause is before deciding to use the flag to
> > workaround^hide it.
>
> I agree.
>
> The constraints on [no-]unit-at-a-time that I see are:
>...
> x86_64 uses unit-at-a-time always
>...

The only gcc versions that ever supported unit-at-a-time without
enabling it by default was some patched gcc 3.3 that included a
backport of unit-at-a-time to gcc 3.3.

Just as a note that I doubt this matters in practice today.

> Jeff

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2008-07-07 16:58:49

by Jeff Dike

[permalink] [raw]
Subject: Re: [PATCH] fix extern inline errors with gcc 4.3.0

On Mon, Jun 30, 2008 at 07:37:27PM +0300, Benny Halevy wrote:
> This isn't exactly aligned with the comment above.
> Should be -lt 0400, as in 22eecde2f9034764a3fd095eecfa3adfb8ec9a98?

Oops, right.

Jeff

--
Work email - jdike at linux dot intel dot com

2008-08-08 01:03:20

by Rob Landley

[permalink] [raw]
Subject: Re: [uml-devel] [PATCH] fix extern inline errors with gcc 4.3.0

On Monday 30 June 2008 11:22:01 Jeff Dike wrote:
> Uli reported a crash on x86_64 with gcc 4.1.2 with unit-at-a-time
...
> If that crash does come back, I'd say we should just debug it. It's
> likely UML implicitly relying on some gcc behavior anyway.

Well, I'm seeing the crash in stock 2.6.26. For the moment I'm reverting

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=4f81c5350b44bcc501ab6f8a089b16d064b4d2f6

And then it runs fine. (With gcc 4.1.2, on x86-64.)

Rob
--
"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson.

2008-08-08 01:43:00

by Rob Landley

[permalink] [raw]
Subject: Re: [uml-devel] [PATCH] fix extern inline errors with gcc 4.3.0

> On Monday 30 June 2008 11:22:01 Jeff Dike wrote:
> > Uli reported a crash on x86_64 with gcc 4.1.2 with unit-at-a-time
>
> ...
>
> > If that crash does come back, I'd say we should just debug it. It's
> > likely UML implicitly relying on some gcc behavior anyway.
>
> Well, I'm seeing the crash in stock 2.6.26. For the moment I'm reverting
>
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdi
>ff;h=4f81c5350b44bcc501ab6f8a089b16d064b4d2f6
>
> And then it runs fine. (With gcc 4.1.2, on x86-64.)

Nevermind, fixed in 2.6.26.2 already. Sorry for the noise...

Rob
--
"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson.