From: Matthew Dillon Date: Fri, 6 Aug 2004 20:50:35 +0000 (+0000) Subject: GCC3.4's (default) unit-at-a-time optimization is incompatible with -mrtd. X-Git-Tag: v2.0.1~10568 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/3d310902fc8a687a85aec646f78b014082cc42c0 GCC3.4's (default) unit-at-a-time optimization is incompatible with -mrtd. Bad code (missing stack pops) will be produced. See the assembly generated for 'xputc' with -mrtd and unit-at-a-time enabled for an example of this. GCC3.4's unit-at-a-time seems to cause other problems as well, specifically in boot2, as yet not tracked down, so disable unit-at-a-time optimizations for the boot code if the compiler is not GCC2. --- diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index 12d6d4c38a..41492e33d6 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -1,5 +1,5 @@ # $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.47 2003/06/26 03:51:57 peter Exp $ -# $DragonFly: src/sys/boot/i386/boot2/Attic/Makefile,v 1.10 2004/07/27 19:37:17 dillon Exp $ +# $DragonFly: src/sys/boot/i386/boot2/Attic/Makefile,v 1.11 2004/08/06 20:50:35 dillon Exp $ PROG= boot2 NOMAN= @@ -51,10 +51,8 @@ BOOT2_UFS?= UFS1_ONLY # gcc3.x # -fno-guess-branch-probability # -mno-align-long-strings - CFLAGS= -elf -ffreestanding -Os -fno-builtin -fno-stack-protector \ -fomit-frame-pointer \ - -mrtd \ -D${BOOT2_UFS} \ -I${.CURDIR}/../../common \ -I${.CURDIR}/../btx/lib -I. \ @@ -62,6 +60,23 @@ CFLAGS= -elf -ffreestanding -Os -fno-builtin -fno-stack-protector \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings +# -mrtd will produce bad code (missing stack pops) when combined with +# gcc-3.4's (default on) unit-at-a-time optimization. See the code +# generated for 'xputc' as an example. +# +.if ${CCVER} == "gcc2" +CFLAGS+= -mrtd +.endif + +# Unfortunately, unit-at-a-time creates other issues as well, as yet +# not tracked down, in boot2, so we have to turn it off. Note that +# the problem has been narrowed down to the 'boot2' code. The /boot/loader +# doesn't seem to have a problem. +# +.if ${CCVER} != "gcc2" +CFLAGS+= -fno-unit-at-a-time +.endif + LDFLAGS=-nostdlib -static -N --gc-sections all: boot1 boot2 boot diff --git a/sys/boot/pc32/boot2/Makefile b/sys/boot/pc32/boot2/Makefile index 8253d20c97..15473566e8 100644 --- a/sys/boot/pc32/boot2/Makefile +++ b/sys/boot/pc32/boot2/Makefile @@ -1,5 +1,5 @@ # $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.47 2003/06/26 03:51:57 peter Exp $ -# $DragonFly: src/sys/boot/pc32/boot2/Makefile,v 1.10 2004/07/27 19:37:17 dillon Exp $ +# $DragonFly: src/sys/boot/pc32/boot2/Makefile,v 1.11 2004/08/06 20:50:35 dillon Exp $ PROG= boot2 NOMAN= @@ -51,10 +51,8 @@ BOOT2_UFS?= UFS1_ONLY # gcc3.x # -fno-guess-branch-probability # -mno-align-long-strings - CFLAGS= -elf -ffreestanding -Os -fno-builtin -fno-stack-protector \ -fomit-frame-pointer \ - -mrtd \ -D${BOOT2_UFS} \ -I${.CURDIR}/../../common \ -I${.CURDIR}/../btx/lib -I. \ @@ -62,6 +60,23 @@ CFLAGS= -elf -ffreestanding -Os -fno-builtin -fno-stack-protector \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings +# -mrtd will produce bad code (missing stack pops) when combined with +# gcc-3.4's (default on) unit-at-a-time optimization. See the code +# generated for 'xputc' as an example. +# +.if ${CCVER} == "gcc2" +CFLAGS+= -mrtd +.endif + +# Unfortunately, unit-at-a-time creates other issues as well, as yet +# not tracked down, in boot2, so we have to turn it off. Note that +# the problem has been narrowed down to the 'boot2' code. The /boot/loader +# doesn't seem to have a problem. +# +.if ${CCVER} != "gcc2" +CFLAGS+= -fno-unit-at-a-time +.endif + LDFLAGS=-nostdlib -static -N --gc-sections all: boot1 boot2 boot