Here is the patch with the ld option check as well. I had to make a few changes to Ron's original patch. One of the problems was that CFLAGS was being set as a := in the Makefile and was overwriting the += that was in Makefile.settings. So I added DISTRO_CFLAGS and DISTRO_LFLAGS for the two additonal flags. The reason for two was that the build-id option is only used during linking and generated warnings if used on a compile line and was not being pulled in for the linker lines. These defines were added to the appropriate places in the Makefile via the Config.lb file.


/*********************
Marc Karasek
MTS
Sun Microsystems
mailto:[EMAIL PROTECTED]
ph:770.360.6415
*********************/



ron minnich wrote:
On Jan 3, 2008 10:33 AM, Marc Karasek <[EMAIL PROTECTED]> wrote:

I could add the check to this patch (using awk to check ld) to add the
-Wl option to the EXTRA_CFLAGS.

cool! I'll take it and add it.

ron
Index: src/config/Config.lb
===================================================================
--- src/config/Config.lb	(revision 3007)
+++ src/config/Config.lb	(working copy)
@@ -8,7 +8,7 @@
 makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
 
 makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
-makedefine CFLAGS := $(CPU_OPT) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin  -Wall
+makedefine CFLAGS := $(CPU_OPT) $(DISTRO_CFLAGS) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin  -Wall
 
 makedefine HOSTCFLAGS:= -Os -Wall
 
@@ -38,14 +38,15 @@
         action  "ar cr linuxbios.a $(OBJECTS)"
 end
 
+
 makerule linuxbios_ram.o
 	depends	"$(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)" 
-	action	"$(CC) -nostdlib -r -o $@ c_start.o $(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
+	action	"$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o $(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
 end
 
 makerule linuxbios_ram
 	depends	"linuxbios_ram.o $(TOP)/src/config/linuxbios_ram.ld ldoptions" 
-	action	"$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_ram.ld linuxbios_ram.o"
+	action	"$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_ram.ld linuxbios_ram.o"
 	action 	"$(CROSS_COMPILE)nm -n linuxbios_ram | sort > linuxbios_ram.map"
 end
 
@@ -83,12 +84,12 @@
 
 	makerule linuxbios_apc.o
 		depends "linuxbios_apc.a c_start.o $(LIBGCC_FILE_NAME)"
-        action  "$(CC) -nostdlib -r -o $@ c_start.o linuxbios_apc.a $(LIBGCC_FILE_NAME)"
+        action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o linuxbios_apc.a $(LIBGCC_FILE_NAME)"
 	end
 
 	makerule linuxbios_apc
 		depends "linuxbios_apc.o $(TOP)/src/config/linuxbios_apc.ld ldoptions"
-		action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_apc.ld linuxbios_apc.o"
+		action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_apc.ld linuxbios_apc.o"
 		action  "$(CROSS_COMPILE)nm -n linuxbios_apc | sort > linuxbios_apc.map"
 	end
 
@@ -121,7 +122,7 @@
 
 makerule linuxbios   
 	depends	"crt0.o $(INIT-OBJECTS) $(LINUXBIOS_APC) $(LINUXBIOS_RAM_ROM) ldscript.ld"
-	action	"$(CC) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
+	action	"$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
 	action	"$(CROSS_COMPILE)nm -n linuxbios | sort > linuxbios.map"
 end
Index: src/arch/i386/lib/id.lds
===================================================================
--- src/arch/i386/lib/id.lds	(revision 3007)
+++ src/arch/i386/lib/id.lds	(working copy)
@@ -1,5 +1,11 @@
 SECTIONS {
-	. = (_ROMBASE + ROM_IMAGE_SIZE - 0x10) - (__id_end - __id_start);
+
+/*
+ *           . = (_ROMBASE + (ROM_IMAGE_SIZE - 0x10)) - (__id_end - __id_start);
+ *  		This is a temporary fix.  Under Fedora 8 ld does not like it if the .id section is above address 0xFFFF_EF00          
+*/
+        _ROMTEMP = 0xffffef00;
+        . = _ROMTEMP;
 	.id (.): {
 		*(.id)
 	}
Index: targets/buildtarget
===================================================================
--- targets/buildtarget	(revision 3007)
+++ targets/buildtarget	(working copy)
@@ -53,4 +53,32 @@
 export PYTHONPATH=$config_dir
 $PYTHON $config_py $config_lb $lbpath
 
+# now start checking for distro-specific breakage. 
+## This check is for the no stack protector mess.
+EXTRA_CFLAGS=
+
+if [ -z "$CC" ]; then
+       CC=gcc
+fi
+
+$CC -fno-stack-protector -S -xc /dev/null -o .$$.tmp
+
+if [ $? -eq 0 ]; then
+       EXTRA_CFLAGS=-fno-stack-protector
+fi
+
+rm -rf .$$.tmp
+
+ld --help | awk '{for (i=1;i<=NF;i++) if ($i ~ /build-id/){n++} }; END {exit n}' 
+build_id=$?
+if [ $build_id ] ; then
+	EXTRA_LFLAGS+=" -Wl,--build-id=none"
+fi
+
+for i in $build_dir/Makefile.settings $build_dir/*/Makefile.settings
+do
+	echo DISTRO_CFLAGS+=$EXTRA_CFLAGS >>$i
+	echo DISTRO_LFLAGS+=$EXTRA_LFLAGS >>$i
+done
+
 exit $?
-- 
linuxbios mailing list
linuxbios@linuxbios.org
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to