buildworld failure (boot2.ld too big when CFLAGS set in make.conf)

Josh Carroll josh.carroll at gmail.com
Mon Oct 22 11:46:03 PDT 2007


Hello,

During buildworld on RELENG_7 csup'd as of 10/22, it dies in
sys/boot/i386/boot2 with:

===> sys/boot/i386/boot2 (all)
-533 bytes available
*** Error code 1

Stop in /usr/src/sys/boot/i386/boot2.
*** Error code 1

I took a look at the cc command line:

cc -Os  -fno-guess-branch-probability  -fomit-frame-pointer
-fno-unit-at-a-time  -mno-align-long-strings  -mrtd  -mno-mmx
-mno-3dnow -mno-sse -mno-sse2 -mno-sse3  -DUFS1_AND_UFS2  -DFLAGS=0x80
 -DSIOPRT=0x3f8  -DSIOFMT=0x3  -DSIOSPD=9600
-I/usr/src/sys/boot/i386/boot2/../../common
-I/usr/src/sys/boot/i386/boot2/../btx/lib -I.  -Wall
-Waggregate-return -Wbad-function-cast -Wcast-align
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings  -Winline
--param max-inline-insns-single=100 -ffreestanding
-mpreferred-stack-boundary=2  -mno-mmx -mno-3dnow -mno-sse -mno-sse2
-mno-sse3 -m32 -march=i386 -O2 -mmmx -msse -msse2 -msse3 -pipe  -S -o
boot2.s.tmp /usr/src/sys/boot/i386/boot2/boot2.c

Since CFLAGS defined in make.conf are being tacked onto the calls to
cc, and the last -O argument is the one that's effective with gcc,
it's effectively building with O2 optimizations instead of Os to
target smaller code size.

Here is my entry in make.conf:

CFLAGS+=-O2 -mmmx -msse -msse2 -msse3 -pipe

To avoid this, I wrapped setting CFLAGS with an .if so it doesn't
happen for the boot2 build:

# don't append to CFLAGS here, it breaks compilation of boot2.
.if ! ${.CURDIR:M*/boot/i386/boot2*}
CFLAGS+=-O2 -mmmx -msse -msse2 -msse3 -pipe
.endif

But is there a better way to do this? I don't think using -O2 is
overly aggressive for building world/ports, but obviously for things
that require a small code size, it's going to break. Is what I'm doing
above the best work around? Or am I missing an easier/more standard
solution? Can I prepend to a variable in make.conf instead of
appending (so that -Os comes _after_ -O2)?

Thanks,
Josh


More information about the freebsd-stable mailing list