Subject: Re: NetBSD kernel fails to boot
To: None <sigsegv@rambler.ru>
From: Chuck Swiger <cswiger@mac.com>
List: current-users
Date: 08/20/2004 13:50:00
sigsegv@rambler.ru wrote:
[ ... ]
> 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.

The most likely answer is that the NetBSD kernel source code accesses memory 
not entirely in a type-safe fashion, and higher optimization levels will 
expose these problems because the compiler's assumptions about which variables 
can be changed via pointer, structure, or union member dereferencing are not 
correct.

The gcc-3 documentation has more discussion about this issue, I believe, 
search for "type punning".  Consider using "-O2 -fno-strict-aliasing" as your 
compiler flags, and see whether that gives you a kernel which works.

-- 
-Chuck