Don't use HOSTCFLAGS in BOOTCFLAGS
In the bootwrapper code for powerpc, we include HOSTCFLAGS into the BOOTCFLAGS used for buildinf the zImage wrapper code. Since the wrapper code is not host code, this makes no sense. This patch removes the use of HOSTCFLAGS here, instead including directly into BOOTCFLAGS those flags from the normal kernel CFLAGS which also make sense in the bootwrapper code.
In particular, this makes the bootwrapper use -msoft-float, preventing the compiler from generating floating point instructions. Previously, under some circumstances the compiler could generate floating point instructions in the bootwrapper which would cause exceptions on embedded CPUS which don't have floating point support.
arch/powerpc/boot/Makefile +6 -4
@@ -11,7 +11,7 @@ # bootloader and increase compatibility with OpenFirmware. # # To this end we need to define BOOTCC, etc, as the tools -# needed to build the 32 bit image. These are normally HOSTCC, +# needed to build the 32 bit image. # but may be a third compiler if, for example, you are cross # compiling from an intel box. Once the 64bit ppc gcc is # stable it will probably simply be a compiler switch to
@@ -22,9 +22,11 @@ all: $(obj)/zImage -HOSTCC := gcc -BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -fno-unit-at-a-time -nostdinc -isystem \ - $(shell $(CROSS32CC) -print-file-name=include) -fPIC +BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -O2 -msoft-float -pipe \ + -fomit-frame-pointer -fno-builtin -fno-unit-at-a-time \ + -fPIC -nostdinc \ + -isystem $(shell $(CROSS32CC) -print-file-name=include) BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc ifeq ($(call cc-option-yn, -fstack-protector),y)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
arch/powerpc/boot/Makefile line 15
Quoted 4 lines
# To this end we need to define BOOTCC, etc, as the tools
arch/powerpc/boot/Makefile +1
-1-# needed to build the 32 bit image. These are normally HOSTCC, +# needed to build the 32 bit image. # but may be a third compiler if, for example, you are cross
You've broken this comment, you should pay for it now :-)
arch/powerpc/boot/Makefile line 26
Quoted 6 lines
arch/powerpc/boot/Makefile +2
-4-HOSTCC := gcc -BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -fno-unit-at-a-time -nostdinc -isystem \ - $(shell $(CROSS32CC) -print-file-name=include) -fPIC +BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -O2 -msoft-float -pipe \
-Os instead?
arch/powerpc/boot/Makefile line 27
Quoted 1 line
arch/powerpc/boot/Makefile +1
-0+ -fomit-frame-pointer -fno-builtin -fno-unit-at-a-time \
Why -fno-unit-at-a-time ?
arch/powerpc/boot/Makefile line 29
Quoted 2 lines
arch/powerpc/boot/Makefile +2
-0+ -fPIC -nostdinc \ + -isystem $(shell $(CROSS32CC) -print-file-name=include)
Also, is there any reason why you can't simply use $(CC) -m32 with the kernel $(CFLAGS) ?
Segher
Quoted 6 lines · Segher Boessenkool
arch/powerpc/boot/Makefile line 15
Quoted 4 lines
# To this end we need to define BOOTCC, etc, as the tools
arch/powerpc/boot/Makefile +1
-1-# needed to build the 32 bit image. These are normally HOSTCC, +# needed to build the 32 bit image. # but may be a third compiler if, for example, you are crossYou've broken this comment, you should pay for it now :-)
Eck, yes.
Quoted 8 lines
arch/powerpc/boot/Makefile line 26
Quoted 6 lines
arch/powerpc/boot/Makefile +2
-4-HOSTCC := gcc -BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -fno-unit-at-a-time -nostdinc -isystem \ - $(shell $(CROSS32CC) -print-file-name=include) -fPIC +BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -O2 -msoft-float -pipe \-Os instead?
Hrm, yeah, that's probably a good idea.
Quoted 3 lines
arch/powerpc/boot/Makefile line 27
Quoted 1 line
arch/powerpc/boot/Makefile +1
-0+ -fomit-frame-pointer -fno-builtin -fno-unit-at-a-time \Why -fno-unit-at-a-time ?
Crap. Because I forgot that the patch stack I was working on had my patch which adds -fno-unit-at-a-time (I often use that when debugging, because it makes the disassembly more comprehensible). In fact without that patch, this one doesn't apply.
Quoted 5 lines
arch/powerpc/boot/Makefile line 29
Quoted 2 lines
arch/powerpc/boot/Makefile +2
-0+ -fPIC -nostdinc \ + -isystem $(shell $(CROSS32CC) -print-file-name=include)Also, is there any reason why you can't simply use $(CC) -m32 with the kernel $(CFLAGS) ?
I did think about that. But the kernel CFLAGS does includes -ffixed-r2 and -Iarch/powerpc which I don't think we want here.
Revised version coming shortly.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 5 lines
Quoted 2 lines
Also, is there any reason why you can't simply use $(CC) -m32 with the kernel $(CFLAGS) ?
I did think about that. But the kernel CFLAGS does includes -ffixed-r2 and -Iarch/powerpc which I don't think we want here.
Both of these should be fairly harmless. But sure, it is cleaner to have separate flags -- the booter and the kernel run in different environments, after all.
Segher
Quoted 9 lines · Segher Boessenkool
Quoted 5 lines
Quoted 2 lines
Also, is there any reason why you can't simply use $(CC) -m32 with the kernel $(CFLAGS) ?
I did think about that. But the kernel CFLAGS does includes -ffixed-r2 and -Iarch/powerpc which I don't think we want here.
Both of these should be fairly harmless. But sure, it is cleaner to have separate flags -- the booter and the kernel run in different environments, after all.
Well, the -I is potentially dangerous, because it allows people to get away with header file dependecies outside the booter specific headers.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson