On 04/07/07 00:06 +0200, Uwe Hermann wrote:
On Tue, Jul 03, 2007 at 05:01:43AM +0200, Stefan Reinauer wrote:
is there some way we can include this in util/xcompile/xcompile instead?
That script was meant to be an abstraction for stuff like this at some point.
Ack, would be better in xcompile. Could somebody please test this on non-Linux platforms, too? E.g. Solaris, FreeBSD, OpenBSD etc. etc.
Okay then - here goes. Please test extensively.....
Jordan
[PATCH][v3] Add testcc() function to xcompile to check for -fno-stack-protector
enable xcompile to check for various compiler flags and set them in the CFLAGS variable if they are located.
Signed-off-by: Jordan Crouse jordan.crouse@amd.com
Index: LinuxBIOSv3/Makefile =================================================================== --- LinuxBIOSv3.orig/Makefile 2007-07-03 16:29:49.000000000 -0600 +++ LinuxBIOSv3/Makefile 2007-07-03 16:32:01.000000000 -0600 @@ -96,6 +96,7 @@ AS := $(AS_$(ARCH)) LD := $(LD_$(ARCH)) OBJCOPY := $(OBJCOPY_$(ARCH)) +CFLAGS += $(CFLAGS_$(ARCH))
CPPFLAGS := $(LINUXBIOSINCLUDE) CFLAGS += $(LINUXBIOSINCLUDE) Index: LinuxBIOSv3/util/xcompile/xcompile =================================================================== --- LinuxBIOSv3.orig/util/xcompile/xcompile 2007-07-03 16:32:16.000000000 -0600 +++ LinuxBIOSv3/util/xcompile/xcompile 2007-07-03 16:32:20.000000000 -0600 @@ -25,6 +25,15 @@ -e s/s390x/s390/ -e s/parisc64/parisc/ \ -e s/ppc.*/powerpc/ -e s/mips.*/mips/`
+testcc() +{ + TMP=".$$$$.tmp" + $1 $2 -S -xc /dev/null -o $TMP > /dev/null 2>&1 + ret=$? + rm -rf $TMP + return $ret +} + searchgnu() { # $1 short name @@ -45,18 +54,23 @@ case "$ARCH" in "x86_64") echo "CC_x86 := gcc -m32" + CC="gcc -m32" + searchgnu as >/dev/null && echo "AS_x86 := $(searchgnu as) --32" searchgnu ld >/dev/null && echo "LD_x86 := $(searchgnu ld) -b elf32-i386 -melf_i386" searchgnu objcopy >/dev/null && echo "OBJCOPY_x86 := $(searchgnu objcopy)" ;; "x86") echo "CC_x86 := gcc" + CC="gcc" + searchgnu as >/dev/null && echo "AS_x86 := $(searchgnu as)" searchgnu ld >/dev/null && echo "LD_x86 := $(searchgnu ld)" searchgnu objcopy >/dev/null && echo "OBJCOPY_x86 := $(searchgnu objcopy)" ;; *) # FIXME: This should be detected. + CC="i386-linux-gcc" echo "CC_x86 := i386-linux-gcc" echo "AS_x86 := i386-linux-as" echo "LD_x86 := i386-linux-ld" @@ -64,6 +78,13 @@ ;; esac
+# This is where we test for various flags and other things + +CFLAGS="" +testcc "$CC" "-fno-stack-protector" && CFLAGS="$CFLAGS-fno-stack-protector " + +echo "CFLAGS_x86 := $CFLAGS" + # TODO: The same as above for PowerPC, and other architectures # as soon as they are supported by LinuxBIOSv3.