Subject: Re: Turning off optimization on selected files.
To: None <>
From: Simon J. Gerraty <>
List: tech-kern
Date: 06/09/2000 17:25:33
>>If I know that a small set of MI source files will break the compiler if
>>compiled with optimization on, is there some easy way to turn it off in,
>>say, sys/${ARCH}/conf/Makefile.${ARCH}?

>Yes.  That's one of the reasons I added ODE's :U modifier.

Here you go:

SRCS=t1.c t2.c


.include <>

$ make t
cc  -O2  -Werror   -c t1.c
cc  -O0  -Werror   -c t2.c
cc   -o t t1.o t2.o 

RCS file: /cvsroot/sharesrc/share/mk/,v
retrieving revision 1.57
diff -u -p -r1.57
---      2000/05/02 03:44:36     1.57
+++      2000/06/09 07:20:40
@@ -27,11 +27,11 @@ CC?=                cc
     ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
     ${MACHINE_ARCH} == "sparc" || \
     ${MACHINE_ARCH} == "vax"
-DBG?=  -O2
+COPT?= -O2
-DBG?=  -O
+COPT?= -O
-CFLAGS?=       ${DBG}
+CFLAGS?=       ${DBG} ${COPT_${.TARGET}:U${COPT}}
 COMPILE.c?=    ${CC} ${CFLAGS} ${CPPFLAGS} -c
 LINK.c?=       ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}

Oh I guess I stopped it doing the CFLAGS?= -O already :-)
I've made it COPT above since that is what folk normally want
to turn on/off per target, and left DBG in CFLAGS even though its
not set by default.  I often use:

rm foo.o
make DBG=-g COPT=-O0
when debugging.

Anyone got better ideas on the names for these variables etc?