Subject: NetBSD kernel fails to boot
To: None <netbsd-users@netbsd.org, current-users@netbsd.org>
From: None <sigsegv@rambler.ru>
List: current-users
Date: 08/20/2004 14:37:30
I have a question in regard to a NetBSD kernel, I ran "cvs update -dP" 
on my /usr/src tree today, to make sure I had the recent sources and 
then compiled the kernel for a Pentium MMX machine. I have observed the 
following things:

Setting "COPTS+=-march=pentium-mmx -Os" in my /etc/mk.conf file, 
produces a NetBSD kernel of 6.9 MB. This kernel boots OK.

Setting "COPTS+=-march=pentium-mmx -O2" in my /etc/mk.conf file, 
produces a NetBSD kernel of 7.8 MB. When I try to boot this kernel, the 
machine gets rebooted as soon as the bootloader loads the kernel.

Removing COPTS altogether from my /etc/mk.conf file and replacing it 
with "CPUFLAGS=-march=pentium-mmx" and "CFLAGS=-Os" does something I 
didn't ask it, i.e. it sets -O2 compiler flag, even though I didn't 
specify it. This is a sample output:

#   compile  kcompile/cast128.o
cc -Os -march=pentium-mmx -ffreestanding -march=pentium-mmx -O2 -Werror 
-Wall -Wno-main -Wno-format-zero-length -Wpointer-arith 
-Wmissing-prototypes -Wstrict-prototypes -Wno-sign-compare 
-fno-zero-initialized-in-bss -Di386 -I. -I/usr/src/sys/arch 
-I/usr/src/sys -nostdinc -DLKM -DNMBCLUSTERS=8192 -DALTQ_PRIQ 
-DMAXUSERS=64 -D_KERNEL -D_KERNEL_OPT -c 
/usr/src/sys/crypto/cast128/cast128.c

As far as I remember this also produced a NetBSD kernel which rebooted 
the machine as soon as it was loaded


Could somebody explain why this is happening, i.e. why does the kernel 
reboot the machine when it's compiled with -O2 option, does the compiler 
break the kernel when passing -O2 option to it, or it has something to 
do with the larger size of the kernel.

PS. the kernel fails to boot on my Pentium 200 MMX machine, with 64MB of 
RAM. I used GENERIC kernel config file, with some minor tweaks.