Subject: Kernels versus optimization
To: None <port-pmax@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: port-pmax
Date: 05/15/2001 20:26:35
Are kernels built without optimization supposed to work?  I was trying
to do an upgrade, and the kernel appeared unstable.  So I blew away the
build directory, configured afresh, edited the Makefile to change -O2
into -O0, and built.  (I had to add ffs.c to
sys/lib/libkern/arch/mips/Makefile.inc or the link fell over because
ffs() was undefined.)

But then when I try to boot the result....

| mainbus0 (root)
| cpu0 at mainbus0
| cpu0: MIPS R3000 CPU Rev. 2.0 with MIPS R3010 FPC Rev. 2.0
| cpu0: 64KB Instruction, 64KB Data, direct mapped cache
| ibus0 at mainbus0
| pm0 at ibus0 addr 0xfc00000: 1024x864x1
| dc0 at ibus0 addr 0x1c000000
| le0 at ibus0 addr 0x18000000: address 08:00:2b:1a:8b:63
| le0: 32 receive buffers, 8 transmit buffers
| le0: supplying EUI64: 08:00:2b:ff:fe:1a:8b:63
| sii0 at ibus0 addr 0x1a000000: target 6
| mcclock0 at ibus0 addr 0x1d000000: mc146818 or compatible
| Beginning old-style SCSI device autoconfiguration
| sii_StartCmd: timeout cs c480 ds f004 cnt 10000
| sii0: device 0: spurrious disconnect (0)
| sii0: target -1 DNE?? dev 0,0 cs 400
| panic: sc_target 1
| halted.
| 
| 
| KN01 V7.01 
| 08-00-2b-1a-8b-63
| 0x01800000
| >> 

Comparing this with a boot of the previous kernel, the one that I
wanted to replace because of the apparent instability, everything's the
same up to the "Beginning old-style..." line, at which point I see

| Beginning old-style SCSI device autoconfiguration
| rz0 at sii0 drive 0 slave 0 SEAGATE ST31230N rev 0640 (SCSI-2)
| rz0: 1010MB, 3992 cyl, 5 head, 103 sec, 512 bytes/sect x 2069860 sectors
| rz1 at sii0 drive 1 slave 0 SGI SEAGATE ST31230N rev 0272 (SCSI-2)
| rz1: 1010MB, 3992 cyl, 5 head, 103 sec, 512 bytes/sect x 2070235 sectors
| boot device: rz0
| root on rz0a dumps on rz0b
| root file system type: ffs
| Enter pathname of shell or RETURN for sh: 

So, a kernel built with -O0 supposed to work?  It obviously hadn't been
tested much (with the source tree I'm using); the ffs glitch is
evidence enough of that.  But is this really a bug, or am I just
pushing the envelope and getting paper cuts as a result?

(I'm trying to build a 2000-02-19 source tree from a binary install off
the 1.4.2 CD.  It occurs to me that this could also be bugs in the
1.4.2 build tools when applied to a 1.4T kernel....)

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B