Skip to contentSkip to conversation

ipxe: fix compilation issues with some gcc versions

PATCH In review Roger Pau Monne 3 participants 8 messages Dec 16, 2011 – Dec 20, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipxe: fix compilation issues with some gcc versions

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1324039730 -3600
# Node ID 8c0ce135cda382630adc72d64757ec64854ba696 # Parent b60667a56ae085ee2bcea896887d0907fb86af41
ipxe: fix compilation issues with some gcc versions

Backported some changes from current ipxe, to fix a issue with some new versions of gcc that add -fPIC by default, and compilation fails with the following error:

arch/i386/core/cpu.c: In function 'get_cpuinfo':
arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand constraints in an 'asm' arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand constraints in an 'asm' arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand constraints in an 'asm' arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand constraints in an 'asm'

Two patches from ipxe git have been added. The problem is reproducible with at least this version of gcc:

Using built-in specs.
COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-uclibc/4.6.2/lto-wrapper
Target: x86_64-alpine-linux-uclibc
Configured with:
/home/buildozer/aports/main/gcc/src/gcc-4.6.2/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-uclibc --host=x86_64-alpine-linux-uclibc --target=x86_64-alpine-linux-uclibc --with-pkgversion='Alpine 4.6.2-r1' --disable-altivec --disable-checking --disable-fixed-point --disable-libssp --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --enable-__cxa_atexit --enable-cld --enable-esp --enable-cloog-backend --enable-languages=c,c++,objc,java,go --enable-shared --enable-target-optspace --enable-tls --enable-threads --with-dynamic-linker=ld64-uClibc.so.0.9.32 --with-dynamic-linker-prefix=/lib --with-system-zlib --without-system-libunwind
Thread model: posix
gcc version 4.6.2 (Alpine 4.6.2-r1)

tools/firmware/etherboot/patches/gpxe-git-b8924c1aed51 new file +72 -0
diff -r b60667a56ae0 -r 8c0ce135cda3 tools/firmware/etherboot/patches/gpxe-git-b8924c1aed51
@@ -0,0 +1,72 @@
+commit b8924c1aed512aa40cf28a43635df383880f771d
+Author: Michael Brown <[email protected]>
+Date:   Wed Mar 16 19:30:42 2011 +0000
+
+    [build] Allow workaround-specific flags to override default flags
+    
+    Signed-off-by: Michael Brown <[email protected]>
+
+diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
+index 709f8de..78e78c9 100644
+--- a/src/Makefile.housekeeping
++++ b/src/Makefile.housekeeping
+@@ -109,6 +109,10 @@ VERYCLEANUP	+= .toolcheck
+ # Check for various tool workarounds
+ #
+ 
++WORKAROUND_CFLAGS :=
++WORKAROUND_ASFLAGS :=
++WORKAROUND_LDFLAGS :=
++
+ # Make syntax does not allow use of comma or space in certain places.
+ # This ugly workaround is suggested in the manual.
+ #
+@@ -119,7 +123,7 @@ SPACE	:= $(EMPTY) $(EMPTY)
+ # Check for an old version of gas (binutils 2.9.1)
+ #
+ OLDGAS	:= $(shell $(AS) --version | grep -q '2\.9\.1' && $(ECHO) -DGAS291)
+-CFLAGS	+= $(OLDGAS)
++WORKAROUND_CFLAGS += $(OLDGAS)
+ oldgas :
+ 	@$(ECHO) $(oldgas)
+ 
+@@ -131,7 +135,7 @@ ifeq ($(CCTYPE),gcc)
+ SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
+ 		-o /dev/null >/dev/null 2>&1
+ SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
+-CFLAGS	+= $(SP_FLAGS)
++WORKAROUND_CFLAGS += $(SP_FLAGS)
+ endif
+ 
+ # gcc 4.4 generates .eh_frame sections by default, which distort the
+@@ -141,7 +145,7 @@ ifeq ($(CCTYPE),gcc)
+ CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -x c -c /dev/null \
+ 		 -o /dev/null >/dev/null 2>&1
+ CFI_FLAGS := $(shell $(CFI_TEST) && $(ECHO) '-fno-dwarf2-cfi-asm')
+-CFLAGS	+= $(CFI_FLAGS)
++WORKAROUND_CFLAGS += $(CFI_FLAGS)
+ endif
+ 
+ # Some versions of gas choke on division operators, treating them as
+@@ -150,7 +154,7 @@ endif
+ #
+ DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null
+ DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide')
+-ASFLAGS	+= $(DIVIDE_FLAGS)
++WORKAROUND_ASFLAGS += $(DIVIDE_FLAGS)
+ 
+ ###############################################################################
+ #
+@@ -375,9 +379,9 @@ CFLAGS		+= -diag-disable 1419 # Missing prototypes
+ CFLAGS		+= -diag-disable 1599 # Hidden variables
+ CFLAGS		+= -Wall -Wmissing-declarations
+ endif
+-CFLAGS		+= $(EXTRA_CFLAGS)
+-ASFLAGS		+= $(EXTRA_ASFLAGS)
+-LDFLAGS		+= $(EXTRA_LDFLAGS)
++CFLAGS		+= $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
++ASFLAGS		+= $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
++LDFLAGS		+= $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
+ 
+ # Inhibit -Werror if NO_WERROR is specified on make command line
+ #
tools/firmware/etherboot/patches/gpxe-git-fe61f6de0dd5 new file +32 -0
diff -r b60667a56ae0 -r 8c0ce135cda3 tools/firmware/etherboot/patches/gpxe-git-fe61f6de0dd5
@@ -0,0 +1,32 @@
+commit fe61f6de0dd5d39ac3de5e8e18742f9bd0aafad7
+Author: Gilles Espinasse <[email protected]>
+Date:   Tue Mar 29 15:30:11 2011 +0100
+
+    [build] Fix compilation when gcc is patched to default to -fPIE -Wl,-pie
+    
+    Signed-off-by: Gilles Espinasse <[email protected]>
+    Modified-by: Michael Brown <[email protected]>
+    Signed-off-by: Michael Brown <[email protected]>
+
+diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
+index 57e52c0..c184351 100644
+--- a/src/Makefile.housekeeping
++++ b/src/Makefile.housekeeping
+@@ -138,6 +138,17 @@ SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
+ WORKAROUND_CFLAGS += $(SP_FLAGS)
+ endif
+ 
++# Some widespread patched versions of gcc include -fPIE -Wl,-pie by
++# default.  Note that gcc will exit *successfully* if it fails to
++# recognise an option that starts with "no", so we have to test for
++# output on stderr instead of checking the exit status.
++#
++ifeq ($(CCTYPE),gcc)
++PIE_TEST = [ -z "`$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null 2>&1`" ]
++PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -nopie')
++WORKAROUND_CFLAGS += $(PIE_FLAGS)
++endif
++
+ # gcc 4.4 generates .eh_frame sections by default, which distort the
+ # output of "size".  Inhibit this.
+ #
tools/firmware/etherboot/patches/series +2 -0
diff -r b60667a56ae0 -r 8c0ce135cda3 tools/firmware/etherboot/patches/series
@@ -1,3 +1,5 @@
 boot_prompt_option.patch
 gpxe-git-0edf2405b457
 gpxe-git-a803ef3dfeac
+gpxe-git-b8924c1aed51
+gpxe-git-fe61f6de0dd5
#1 lore raw
Quoted 10 lines · Roger Pau Monne

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1324039730 -3600
# Node ID 8c0ce135cda382630adc72d64757ec64854ba696 # Parent b60667a56ae085ee2bcea896887d0907fb86af41
ipxe: fix compilation issues with some gcc versions

Backported some changes from current ipxe, to fix a issue with some new versions of gcc that add -fPIC by default, and compilation fails with the following error:

Is there a newer release tag on the ipxe repo that we could build instead, that would automatically get us these fixes?

-- Keir

Quoted 92 lines

arch/i386/core/cpu.c: In function 'get_cpuinfo':
arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand constraints in an 'asm' arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand constraints in an 'asm' arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand constraints in an 'asm' arch/i386/include/bits/cpu.h:79:2: error: inconsistent operand constraints in an 'asm'

Two patches from ipxe git have been added. The problem is reproducible with at least this version of gcc:

Using built-in specs.
COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-uclibc/4.6.2/lto-wrap per
Target: x86_64-alpine-linux-uclibc
Configured with:
/home/buildozer/aports/main/gcc/src/gcc-4.6.2/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-uclibc --host=x86_64-alpine-linux-uclibc --target=x86_64-alpine-linux-uclibc --with-pkgversion='Alpine 4.6.2-r1' --disable-altivec --disable-checking --disable-fixed-point --disable-libssp --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --enable-__cxa_atexit --enable-cld --enable-esp --enable-cloog-backend --enable-languages=c,c++,objc,java,go --enable-shared --enable-target-optspace --enable-tls --enable-threads --with-dynamic-linker=ld64-uClibc.so.0.9.32 --with-dynamic-linker-prefix=/lib --with-system-zlib --without-system-libunwind
Thread model: posix
gcc version 4.6.2 (Alpine 4.6.2-r1)

diff -r b60667a56ae0 -r 8c0ce135cda3 tools/firmware/etherboot/patches/gpxe-git-b8924c1aed51

tools/firmware/etherboot/patches/gpxe-git-b8924c1aed51 Fri Dec 16 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +0 -0

13:48:50 2011 +0100

tools/firmware/etherboot/patches/gpxe-git-b8924c1aed51 Fri Dec 16 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +48 -0
@@ -0,0 +1,72 @@
+commit b8924c1aed512aa40cf28a43635df383880f771d
+Author: Michael Brown <[email protected]>
+Date:   Wed Mar 16 19:30:42 2011 +0000
+
+    [build] Allow workaround-specific flags to override default flags
+    
+    Signed-off-by: Michael Brown <[email protected]>
+
+diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
+index 709f8de..78e78c9 100644
+--- a/src/Makefile.housekeeping
++++ b/src/Makefile.housekeeping
+@@ -109,6 +109,10 @@ VERYCLEANUP += .toolcheck
+ # Check for various tool workarounds
+ #
+ 
++WORKAROUND_CFLAGS :=
++WORKAROUND_ASFLAGS :=
++WORKAROUND_LDFLAGS :=
++
+ # Make syntax does not allow use of comma or space in certain places.
+ # This ugly workaround is suggested in the manual.
+ #
+@@ -119,7 +123,7 @@ SPACE := $(EMPTY) $(EMPTY)
+ # Check for an old version of gas (binutils 2.9.1)
+ #
+ OLDGAS := $(shell $(AS) --version | grep -q '2\.9\.1' && $(ECHO) -DGAS291)
+-CFLAGS += $(OLDGAS)
++WORKAROUND_CFLAGS += $(OLDGAS)
+ oldgas :
+  @$(ECHO) $(oldgas)
+ 
+@@ -131,7 +135,7 @@ ifeq ($(CCTYPE),gcc)
+ SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
+   -o /dev/null >/dev/null 2>&1
+ SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
+-CFLAGS += $(SP_FLAGS)
++WORKAROUND_CFLAGS += $(SP_FLAGS)
+ endif
+ 
+ # gcc 4.4 generates .eh_frame sections by default, which distort the
+@@ -141,7 +145,7 @@ ifeq ($(CCTYPE),gcc)
+ CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -x c -c /dev/null \
+    -o /dev/null >/dev/null 2>&1
+ CFI_FLAGS := $(shell $(CFI_TEST) && $(ECHO) '-fno-dwarf2-cfi-asm')
+-CFLAGS += $(CFI_FLAGS)
++WORKAROUND_CFLAGS += $(CFI_FLAGS)
+ endif

tools/firmware/etherboot/patches/gpxe-git-b8924c1aed51 Fri Dec 16 line 58

Quoted 10 lines
tools/firmware/etherboot/patches/gpxe-git-b8924c1aed51 Fri Dec 16 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +10 -0
+ 
+ # Some versions of gas choke on division operators, treating them as
+@@ -150,7 +154,7 @@ endif
+ #
+ DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null
+ DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide')
+-ASFLAGS += $(DIVIDE_FLAGS)
++WORKAROUND_ASFLAGS += $(DIVIDE_FLAGS)
+ 
+ 

##############################################################################> #

Quoted 68 lines
tools/firmware/etherboot/patches/gpxe-git-b8924c1aed51 Fri Dec 16 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +14 -0
+ #
+@@ -375,9 +379,9 @@ CFLAGS  += -diag-disable 1419 # Missing prototypes
+ CFLAGS  += -diag-disable 1599 # Hidden variables
+ CFLAGS  += -Wall -Wmissing-declarations
+ endif
+-CFLAGS  += $(EXTRA_CFLAGS)
+-ASFLAGS  += $(EXTRA_ASFLAGS)
+-LDFLAGS  += $(EXTRA_LDFLAGS)
++CFLAGS  += $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
++ASFLAGS  += $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
++LDFLAGS  += $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
+ 
+ # Inhibit -Werror if NO_WERROR is specified on make command line
+ #

diff -r b60667a56ae0 -r 8c0ce135cda3 tools/firmware/etherboot/patches/gpxe-git-fe61f6de0dd5

tools/firmware/etherboot/patches/gpxe-git-fe61f6de0dd5 Fri Dec 16 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +0 -0

13:48:50 2011 +0100

tools/firmware/etherboot/patches/gpxe-git-fe61f6de0dd5 Fri Dec 16 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +15 -0
@@ -0,0 +1,32 @@
+commit fe61f6de0dd5d39ac3de5e8e18742f9bd0aafad7
+Author: Gilles Espinasse <[email protected]>
+Date:   Tue Mar 29 15:30:11 2011 +0100
+
+    [build] Fix compilation when gcc is patched to default to -fPIE -Wl,-pie
+    
+    Signed-off-by: Gilles Espinasse <[email protected]>
+    Modified-by: Michael Brown <[email protected]>
+    Signed-off-by: Michael Brown <[email protected]>
+
+diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
+index 57e52c0..c184351 100644
+--- a/src/Makefile.housekeeping
++++ b/src/Makefile.housekeeping
+@@ -138,6 +138,17 @@ SP_FLAGS := $(shell $(SP_TEST) && $(ECHO)

'-fno-stack-protector')
+ WORKAROUND_CFLAGS += $(SP_FLAGS)
+ endif
+
++# Some widespread patched versions of gcc include -fPIE -Wl,-pie by ++# default. Note that gcc will exit *successfully* if it fails to ++# recognise an option that starts with "no", so we have to test for ++# output on stderr instead of checking the exit status.
++#
++ifeq ($(CCTYPE),gcc)
++PIE_TEST = [ -z "$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null 2>&1" ]
++PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -nopie') ++WORKAROUND_CFLAGS += $(PIE_FLAGS)
++endif
++
+ # gcc 4.4 generates .eh_frame sections by default, which distort the
+ # output of "size". Inhibit this.
+ #
diff -r b60667a56ae0 -r 8c0ce135cda3 tools/firmware/etherboot/patches/series

tools/firmware/etherboot/patches/series Fri Dec 16 13:48:50 2011 +0100 renamed from tools/firmware/etherboot/patches/series Fri Dec 16 10:47:18 2011 +0100 +2 -0
@@ -1,3 +1,5 @@
 boot_prompt_option.patch
 gpxe-git-0edf2405b457
 gpxe-git-a803ef3dfeac
+gpxe-git-b8924c1aed51
+gpxe-git-fe61f6de0dd5

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

2011/12/16 Keir Fraser <[email protected]>:

Quoted 9 lines · Roger Pau Monne
Quoted 8 lines

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1324039730 -3600
# Node ID 8c0ce135cda382630adc72d64757ec64854ba696 # Parent  b60667a56ae085ee2bcea896887d0907fb86af41
ipxe: fix compilation issues with some gcc versions

Quoted 6 lines
Quoted 3 lines

Backported some changes from current ipxe, to fix a issue with some new versions of gcc that add -fPIC by default, and compilation fails with the following error:

Is there a newer release tag on the ipxe repo that we could build instead, that would automatically get us these fixes?

No, latest tag (almost two years ago) is 1.0.0, which is the one we are currently using.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 14 lines · Roger Pau Monné

2011/12/16 Keir Fraser <[email protected]>:

Quoted 13 lines · Roger Pau Monne
Quoted 11 lines

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1324039730 -3600
# Node ID 8c0ce135cda382630adc72d64757ec64854ba696 # Parent  b60667a56ae085ee2bcea896887d0907fb86af41
ipxe: fix compilation issues with some gcc versions

Backported some changes from current ipxe, to fix a issue with some new versions of gcc that add -fPIC by default, and compilation fails with the following error:

Quoted 5 lines
Quoted 2 lines

Is there a newer release tag on the ipxe repo that we could build instead, that would automatically get us these fixes?

No, latest tag (almost two years ago) is 1.0.0, which is the one we are currently using.

Perhaps we should pick a recent commit hash to clone, then? There's plenty going on in there development-wise, which would surely have warranted a release or two; it just looks like they couldn't be arsed to tag releases. Hanging on to a two-year-old version and building up a backport queue doesn't make sense. At the very least we should do this in xen-unstable, and get some testing done of recent ipxe upstream.

-- Keir

#4 lore raw

2011/12/16 Keir Fraser <[email protected]>:

Quoted 6 lines

Perhaps we should pick a recent commit hash to clone, then? There's plenty going on in there development-wise, which would surely have warranted a release or two; it just looks like they couldn't be arsed to tag releases. Hanging on to a two-year-old version and building up a backport queue doesn't make sense. At the very least we should do this in xen-unstable, and get some testing done of recent ipxe upstream.

That's fine, I agree that we should pick a most recent ipxe version for unstable, if not things like this are going to happen every now and then and we will end up with a massive queue of patches. But in the meantime, is it possible to apply this patch to xen-4.1 and possibly xen-4.0?

Thanks, Roger.

#5 lore raw
Quoted 8 lines · Roger Pau Monné

2011/12/16 Keir Fraser <[email protected]>:

Quoted 6 lines

Perhaps we should pick a recent commit hash to clone, then? There's plenty going on in there development-wise, which would surely have warranted a release or two; it just looks like they couldn't be arsed to tag releases. Hanging on to a two-year-old version and building up a backport queue doesn't make sense. At the very least we should do this in xen-unstable, and get some testing done of recent ipxe upstream.

Quoted 5 lines

That's fine, I agree that we should pick a most recent ipxe version for unstable, if not things like this are going to happen every now and then and we will end up with a massive queue of patches. But in the meantime, is it possible to apply this patch to xen-4.1 and possibly xen-4.0?

Done for 4.1. In 4.0 it looks like we have the generated code checked in, so this fix is not necessary there.

-- Keir

Quoted 1 line

Thanks, Roger.

#6 lore raw

2011/12/18 Keir Fraser <[email protected]>:

Quoted 2 lines

Done for 4.1. In 4.0 it looks like we have the generated code checked in, so this fix is not necessary there.

Is there any preferred revision of ipxe that we should choose for unstable or just pick the latest one?

Roger.

#7 lore raw
Quoted 6 lines · Roger Pau Monné

2011/12/18 Keir Fraser <[email protected]>:

Quoted 2 lines

Done for 4.1. In 4.0 it looks like we have the generated code checked in, so this fix is not necessary there.

Is there any preferred revision of ipxe that we should choose for unstable or just pick the latest one?

If it builds and smoke-tests, let's go with the latest. :-)

The main thing is for us to then stick with that revision for a while, so we are testing a fixed version which we can use in our next release.

-- Keir

Quoted 6 lines

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel