Subject: fix? for kernel loading problems on sparc
To: None <tech-kern@netbsd.org, port-sparc@netbsd.org>
From: Simon J. Gerraty <sjg@crufty.net>
List: port-sparc
Date: 09/25/2002 15:24:32
Many sparc users put something like:

COPTS+= -msupersparc

in /etc/mk.conf and sys.mk provides 
DBG?= -O2 
or whatever.

However sys/conf/Makefile.kern.inc does:

DEFCOPTS?=	-O2
COPTS?=		${DEFCOPTS}
DBG=		# might contain unwanted -Ofoo

the effect of this with the COPTS in mk.conf is that we lose the -O2
which bloats the kernel to the point where loading clobbers the boot
loader (recent thread on port-sparc):

with -O2
2508460 93324   268176  2869960 2bcac8  /netbsd
with -msupersparc
4477616 93324   268176  4839116 49d6cc  /netbsd.ss
with -O2 -msupersparc
2521732 93324   268176  2883232 2bfea0  netbsd

The boot loader is at 388000.

Since most of the tree will pickup -O* from
${DBG} it isn't ideal to add -O2 to COPTS in mk.conf.  With the
following in mk.conf

COPTS+= -msupersparc
# for kernel builds
DEFCOPTS= -O2 -msupersparc

and the patch below, things work better.  This is perhaps not ideal
though. Why doesn't the kernel just use DBG?

Thanks
--sjg

Index: sys/conf/Makefile.kern.inc
===================================================================
RCS file: /cvsroot/syssrc/sys/conf/Makefile.kern.inc,v
retrieving revision 1.13.4.6
diff -u -p -r1.13.4.6 Makefile.kern.inc
--- sys/conf/Makefile.kern.inc	2002/08/17 16:02:38	1.13.4.6
+++ sys/conf/Makefile.kern.inc	2002/09/25 21:08:13
@@ -47,7 +47,7 @@ S!=	cd ../../../..; pwd
 INCLUDES?=	-I. ${EXTRA_INCLUDES} -I$S/arch -I$S -nostdinc
 CPPFLAGS+=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT
 DEFCOPTS?=	-O2
-COPTS?=		${DEFCOPTS}
+COPTS=		${DEFCOPTS}
 DBG=		# might contain unwanted -Ofoo
 DEFWARNINGS?=	yes
 .if (${DEFWARNINGS} == "yes")