Subject: Re: Turning off optimization on selected files.
To: None <tech-kern@netbsd.org>
From: Simon J. Gerraty <sjg@quick.com.au>
List: tech-kern
Date: 06/10/2000 00:44:52
> >>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.

Actually that 1st diff is a bit half hearted.  One should also allow
CFLAGS to be completely specified for a target.  Though I think being
able to set just a subset (eg the optimizer flags) is also worth
while.

Again, variable names probably suck... anyone violetly object to:
I used _CFLAGS_ as just a more readable? form of
${CFLAGS_${.TARGET}:U${CFLAGS}}

one could do the same trick with CPPFLAGS etc, too if need be.

--sjg

Index: sys.mk
===================================================================
RCS file: /cvsroot/sharesrc/share/mk/sys.mk,v
retrieving revision 1.57
diff -u -p -r1.57 sys.mk
--- sys.mk	2000/05/02 03:44:36	1.57
+++ sys.mk	2000/06/09 14:37:08
@@ -27,21 +27,22 @@ CC?=		cc
     ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
     ${MACHINE_ARCH} == "sparc" || \
     ${MACHINE_ARCH} == "vax"
-DBG?=	-O2
+COPT?=	-O2
 .else
-DBG?=	-O
+COPT?=	-O
 .endif
-CFLAGS?=	${DBG}
-COMPILE.c?=	${CC} ${CFLAGS} ${CPPFLAGS} -c
-LINK.c?=	${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+CFLAGS?=	${DBG} ${COPT_${.TARGET}:U${COPT}}
+_CFLAGS_=	${CFLAGS_${.TARGET}:U${CFLAGS}}
+COMPILE.c?=	${CC} ${_CFLAGS_} ${CPPFLAGS} -c
+LINK.c?=	${CC} ${_CFLAGS_} ${CPPFLAGS} ${LDFLAGS}
 
 CXX?=		c++
-CXXFLAGS?=	${CFLAGS}
+CXXFLAGS?=	${_CFLAGS_}
 COMPILE.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
 LINK.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
 
 OBJC?=		${CC}
-OBJCFLAGS?=	${CFLAGS}
+OBJCFLAGS?=	${_CFLAGS_}
 COMPILE.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
 LINK.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}