Hi,

        I was doing my often world build when something came up.

$ make buildworld

just fine

$ make buildkernel 

not so good

$ make buildkernel -V CFLAGS
-Os -pipe -march=athlon-xp -falign-functions -falign-jumps -fno-strict-aliasing 
-fomit-frame-pointer -fpeel-loops -freorder-blocks -funit-at-a-time 
-funswitch-loops -mfpmath=387 -march=athlon-xp
$ make buildkernel -V COPTFLAGS
-Os -pipe -march=athlon-xp -falign-functions -falign-jumps -fno-strict-aliasing 
-fomit-frame-pointer -fpeel-loops -freorder-blocks -funit-at-a-time 
-funswitch-loops -mfpmath=387
$ make buildkernel -V LDFLAGS

        Those are the compile options I have. As you can see, both
COPTFLAGS and CFLAGS contents are the same whereas LDFLAGS is empty.

        I did a CVSup then a buildworld, then proceeded to a buildkernel.
Here is what I've got:

cd /usr/src/sys/modules; MAKEOBJDIRPREFIX=/usr/obj/usr/src/sys/LIOUX/modules 
KMODDIR=/boot/kernel MACHINE=i386 KERNBUILDDIR="/usr/obj/usr/src/sys/LIOUX" 
make  all
===> 3dfx
===> aac
===> aac/aac_linux
===> accf_data
===> accf_http
===> acpi
===> acpi/acpi
/usr/local/libexec/ccache/cc -O -pipe -pipe -msse -mfpmath=sse,387 
-funit-at-a-time -falign-functions -fforce-addr -fforce-mem 
-foptimize-register-move -foptimize-sibling-calls -fpeel-loops 
-fprefetch-loop-arrays -freorder-blocks -march=athlon-xp 
-I/usr/src/sys/modules/acpi/acpi/../../../contrib/dev/acpica -D_KERNEL 
-DKLD_MODULE -nostdinc -I-  
-I/usr/src/sys/modules/acpi/acpi/../../../contrib/dev/acpica -include 
/usr/obj/usr/src/sys/LIOUX/opt_global.h -I. -I@ -I@/contrib/altq -I@/../include 
-finline-limit=8000 -fno-common  -I/usr/obj/usr/src/sys/LIOUX 
-mno-align-long-strings -mpreferred-stack-boundary=2  -mno-mmx -mno-3dnow 
-mno-sse -mno-sse2 -ffreestanding -Wall -Wredundant-decls -Wnested-externs 
-Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  
-fformat-extensions -std=c99 -Wsystem-headers -Werror -Wall -Wno-format-y2k 
-Wno-uninitialized -c 
/usr/src/sys/modules/acpi/acpi/../../../contrib/dev/acpica/dsfield.c
/usr/src/sys/modules/acpi/acpi/../../../contrib/dev/acpica/dsfield.c:1: 
warning: SSE instruction set disabled, using 387 arithmetics
*** Error code 1

        As you can see the FLAGS options being used to build the
kernel DO NOT match either CFLAGS or COPTFLAGS for buildkernel. I
can reproduce this just fine. Let me know if you need a full log
'make buildworld buildkernel'

        As you can see below my standard CFLAGS is not the same as
of the one for buildkernel.

$ make -V CFLAGS
-O -pipe -pipe -msse -mfpmath=sse,387 -funit-at-a-time -falign-functions 
-fforce-addr -fforce-mem -foptimize-register-move -foptimize-sibling-calls 
-fpeel-loops -fprefetch-loop-arrays -freorder-blocks -march=athlon-xp

        I trick the system to use different build make options
depending on the given situation.

My /etc/make.conf contains the following

COPTFLAGS=-Os -pipe
COPTFLAGS+=-march=athlon-xp
COPTFLAGS+=-falign-functions
COPTFLAGS+=-falign-jumps
COPTFLAGS+=-fno-strict-aliasing
COPTFLAGS+=-fomit-frame-pointer
COPTFLAGS+=-fpeel-loops
COPTFLAGS+=-freorder-blocks
COPTFLAGS+=-funit-at-a-time
COPTFLAGS+=-funswitch-loops
.if make(buildworld) || make(buildkernel)
LDFLAGS_LD_INSTEAD_OF_CC=yes
NO_CFLAGS=yes
CFLAGS=${COPTFLAGS}
.if make(buildworld)
COPTFLAGS+=-msse
COPTFLAGS+=-mfpmath=sse,387
.elif make(buildkernel) # ! make(buildworld)
COPTFLAGS+=-mfpmath=387
.endif # make(buildkernel)
.endif # make(buildworld) || make(buildkernel)

        The botton line is, the following line

cd /usr/src/sys/modules; MAKEOBJDIRPREFIX=/usr/obj/usr/src/sys/LIOUX/modules 
KMODDIR=/boot/kernel MACHINE=i386 KERNBUILDDIR="/u
sr/obj/usr/src/sys/LIOUX" make  all

has no idea that it is part of a buildkernel statement. We can fix
that by setting a ENVIRONMENT variable when the kernel is being
built and check that within /usr/src/sys/modules in order to respect
COPTFLAGS over CFLAGS.

        What do you guys think? I hope my make.conf code tricks are
useful to some folks out there.

        Regards,

ps: Plz, CC: me in your responses since I am no longer subscribed
to this mailing list

-- 
Mario S F Ferreira - DF - Brazil - "I guess this is a signature."
feature, n: a documented bug | bug, n: an undocumented feature

Attachment: pgpBjh0bEwRjh.pgp
Description: PGP signature

Reply via email to