ppc@ taking a step back and make something out of this effort.
i am unsure of other developers efforts about moving macpcc to full base-clang ... so i hope i am not duplicating / wasting my efforts. short-term goals: are to determine if ofwboot/kernel will work w/ base-clang out of the box. long-term goals: submit patches that will make macppc working properly with base-clang on actual machines (G3/G4 laptops in my case). to achieve these goals i will try to ignore the assembly output of clang and gcc ... since i am not knowledgeable with the inner workings of the compilers. make notes though. use the packaged base-clang (-release or -snapshots) do no harm, that is assume the code works and don't hack around things i don't know. thus as an initial investigation, i will limit myself to tweaking only the build environment. find options that will work with the current source code and base-clang. i will run a GENERIC kernel. base will only be rebuilt as needed. so in my investigations it will be clang-kernel + gcc-userland applications. iBook G3 runs 6.6-release, sys.tar.gz gives me the kernel source. iBook G4 runs 6.6-current, i'm tracking CVS for this one. when everything seems right, there is a Powerbook G4 tracking -current that can also be used in testing. short term results: 1 unmodified ofwboot and the kernel code does compile with base-clang the build environment need to be adjusted. no linker errors. binaries are created with the base-clang + binutils (ld) chain. 2 clang compiled ofwboot works on actual machine it can load and boot the kernel 3 clang compiled kernel boots ... up to a certain point ... tested on all 3 machines i have. i did take a peek at the generated asm ... base-clang generates a messy set of assembly code. arch/macppc/macppc/openfirm.c OF_getnodebyname() i took a peek bec the part where i usually hang is in the OF_ code, openfirmware client interface code. it get's used much during device probing and initialization and doesn't get used after that. based on reading the code ... it is the realm where real-mode mem intermingle with virtual memory ... but very early in the boot i tend to assume physmem == virtmem in the end, i decided to just change the optimization settings. get -snapshot kernel and decompile. create clang-kernel with modified COPTS, decompile. compare and find COPTS settings that create least difference. 4 so tweaking the build environment ... led me to "-Oz" ... the disassembly somewhat closely matches the code generated by base-gcc -O2 is the default optimization settings. -O2 kernel does not boot as mentioned in my other ramblings the kernel either hangs in a zscinit() stack smash or no log is displayed after the "screen" is initialized (after trying to get the "backlight" node using OF_getnodebyname(). kernel is noticeably larger than base-gcc compiled version. -Os openfirm.o is very similar to -O2 kernel. the OF_child/ OF_peer/OF_parent calls are inlined in OF_getnodebyname ... i don't know the correct term for it. doesn't boot. i get a trap 300 very early. -Oz creates a good-ish kernel, openfirm.o is very similar to base-gcc generated code. the calls to OF_child/OF_peer/OF_parent are explicit jumps to the said functions. good-ish kernel ... the kernel to boots and probes devices. but at a certain point ... it slows down to a crawl .. a slug. it get's slow after initializing gem ... slow USB enumeration ... with DEBUG it show it was also at this point that arch/macppc/macppc/clock.c cpu_initclocks() was invoked. and it is slow from here on. rootdisk gets mounted. i get a login prompt. 'time sleep 1' takes ages. painfully slow. 'date' after rebooting the test kernel is way way off. from the looks of things it never advanced. i'm assuming a setting didn't stick ... or something. so that is where i'am at right now ... - rgc [ using 1293176 bytes of bsd ELF symbol table ] console out [ATY,Bee_A] console in [keyboard], using ADB using parent ATY,BeeParent:: memaddr 98000000, size 8000000 : consaddr 9c008000 : ioaddr 90020000, size 20000: width 1024 linebytes 1024 height 768 depth 8 Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2019 OpenBSD. All rights reserved. https://www.OpenBSD.org OpenBSD 6.6 (GENERIC) #604: Sat Oct 12 13:10:27 MDT 2019 dera...@macppc.openbsd.org:/usr/src/sys/arch/macppc/compile/GENERIC real mem = 402653184 (384MB) avail mem = 372981760 (355MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root: model PowerBook4,3 cpu0 at mainbus0: 750FX (Revision 0x112): 700 MHz: 512KB L2 cache mem0 at mainbus0 spdmem0 at mem0: no EEPROM found spdmem1 at mem0: 256MB SDRAM non-parity PC133CL3 memc0 at mainbus0: uni-n rev 0xc0 kiic0 at memc0 offset 0xf8001000 iic0 at kiic0 admtmp0 at iic0 addr 0xac mpcpcibr0 at mainbus0 pci: uni-north pci0 at mpcpcibr0 bus 0 pchb0 at pci0 dev 11 function 0 "Apple Pangea AGP" rev 0x00 agp at pchb0 not configured radeondrm0 at pci0 dev 16 function 0 "ATI Radeon Mobility M7" rev 0x00 drm0 at radeondrm0 radeondrm0: irq 48 mpcpcibr1 at mainbus0 pci: uni-north pci1 at mpcpcibr1 bus 0 macobio0 at pci1 dev 23 function 0 "Apple Pangea Macio" rev 0x00 openpic0 at macobio0 offset 0x40000: version 0x4614 feature 3f0302 LE macgpio0 at macobio0 offset 0x50 macgpio1 at macgpio0 offset 0x9: irq 47 "programmer-switch" at macgpio0 offset 0x11 not configured "firewire-linkon" at macgpio0 offset 0x5b not configured "cpu-vcore-select" at macgpio0 offset 0x6b not configured "extint-gpio4" at macgpio0 offset 0x5c not configured "gpio9" at macgpio0 offset 0x73 not configured "extint-gpio12" at macgpio0 offset 0x64 not configured "escc-legacy" at macobio0 offset 0x12000 not configured zs0 at macobio0 offset 0x13000: irq 22,23 zstty0 at zs0 channel 0 zstty1 at zs0 channel 1 snapper0 at macobio0 offset 0x10000: irq 30,1,2 "timer" at macobio0 offset 0x15000 not configured adb0 at macobio0 offset 0x16000: irq 25, via-pmu, 3 targets apm0 at adb0: battery flags 0x5, 98% charged piic0 at adb0 iic1 at piic0 akbd0 at adb0 addr 2: PowerBook G3 keyboard (Japanese layout) wskbd0 at akbd0: console keyboard ams0 at adb0 addr 3: EMP trackpad <tpad> 2-button, 400 dpi wsmouse0 at ams0 mux 0 abtn0 at adb0 addr 7: brightness/volume/eject buttons "battery" at macobio0 offset 0x0 not configured "backlight" at macobio0 offset 0xf300 not configured kiic1 at macobio0 offset 0x18000 iic2 at kiic1 wdc0 at macobio0 offset 0x1f000 irq 19: DMA wd0 at wdc0 channel 0 drive 0: <SUNEAST SSD SE800 mSATA 256GB> wd0: 16-sector PIO, LBA48, 244198MB, 500118192 sectors atapiscsi0 at wdc0 channel 0 drive 1 scsibus1 at atapiscsi0: 2 targets cd0 at scsibus1 targ 0 lun 0: <LG, CD-ROM CRN-8245B, AHTA> removable wd0(wdc0:0:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 2 cd0(wdc0:0:1): using PIO mode 4, DMA mode 2, Ultra-DMA mode 2 audio0 at snapper0 ohci0 at pci1 dev 24 function 0 "Apple Pangea USB" rev 0x00: irq 27, version 1.0 ohci1 at pci1 dev 25 function 0 "Apple Pangea USB" rev 0x00: irq 28, version 1.0 usb0 at ohci0: USB revision 1.0 uhub0 at usb0 configuration 1 interface 0 "Apple OHCI root hub" rev 1.00/1.00 addr 1 usb1 at ohci1: USB revision 1.0 uhub1 at usb1 configuration 1 interface 0 "Apple OHCI root hub" rev 1.00/1.00 addr 1 mpcpcibr2 at mainbus0 pci: uni-north pci2 at mpcpcibr2 bus 0 "Apple Pangea FireWire" rev 0x00 at pci2 dev 14 function 0 not configured gem0 at pci2 dev 15 function 0 "Apple Pangea GMAC" rev 0x00: irq 41, address 00:03:93:c7:d1:20 bmtphy0 at gem0 phy 0: BCM5221 100baseTX PHY, rev. 4 vscsi0 at root scsibus2 at vscsi0: 256 targets softraid0 at root scsibus3 at softraid0: 256 targets bootpath: /pci@f2000000/mac-io@17/ata-4@1f000/disk@0:/bsd root on wd0a (1a3833755fe31710.a) swap on wd0b dump on wd0b WARNING: / was not properly unmounted initializing kernel modesetting (RV200 0x1002:0x4C57 0x1002:0x4C57 0x00). [drm] *ERROR* Unable to locate a BIOS ROM radeondrm0: 1024x768, 16bpp wsdisplay0 at radeondrm0 mux 1: console (std, vt100 emulation), using wskbd0 wsdisplay0: screen 1-5 added (std, vt100 emulation) ugen0 at uhub1 port 2 "HCF USB V.90 Data/Fax Modem Apple internal modem" rev 1.10/1.00 addr 2 umass0 at uhub1 port 1 configuration 1 interface 0 "Verbatim STORE N GO" rev 2.00/1.00 addr 3 umass0: using SCSI over Bulk-Only scsibus4 at umass0: 2 targets, initiator 0 sd0 at scsibus4 targ 1 lun 0: <Verbatim, STORE N GO, 5.00> removable serial.18a503076B61B2C00142 sd0: 7389MB, 512 bytes/sector, 15133248 sectors syncing disks... [ using 1273868 bytes of bsd ELF symbol table ] console out [ATY,Bee_A] console in [keyboard], using ADB using parent ATY,BeeParent:: memaddr 98000000, size 8000000 : consaddr 9c008000 : ioaddr 90020000, size 20000: width 1024 linebytes 1024 height 768 depth 8 Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2019 OpenBSD. All rights reserved. https://www.OpenBSD.org OpenBSD 6.6 (GENERIC) #0: Thu Feb 27 21:41:24 JST 2020 r...@aibg3.my.domain:/home/rgc/u/s/sys/arch/macppc/compile/GENERIC real mem = 402653184 (384MB) avail mem = 373534720 (356MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root: model PowerBook4,3 cpu0 at mainbus0: 750FX (Revision 0x112): 700 MHz: 512KB L2 cache mem0 at mainbus0 spdmem0 at mem0: no EEPROM found spdmem1 at mem0: 256MB SDRAM non-parity PC133CL3 memc0 at mainbus0: uni-n rev 0xc0 kiic0 at memc0 offset 0xf8001000 iic0 at kiic0 admtmp0 at iic0 addr 0xac mpcpcibr0 at mainbus0 pci: uni-north pci0 at mpcpcibr0 bus 0 pchb0 at pci0 dev 11 function 0 "Apple Pangea AGP" rev 0x00 agp at pchb0 not configured radeondrm0 at pci0 dev 16 function 0 "ATI Radeon Mobility M7" rev 0x00 drm0 at radeondrm0 radeondrm0: irq 48 mpcpcibr1 at mainbus0 pci: uni-north pci1 at mpcpcibr1 bus 0 macobio0 at pci1 dev 23 function 0 "Apple Pangea Macio" rev 0x00 openpic0 at macobio0 offset 0x40000: version 0x4614 feature 3f0302 LE macgpio0 at macobio0 offset 0x50 macgpio1 at macgpio0 offset 0x9: irq 47 "programmer-switch" at macgpio0 offset 0x11 not configured "firewire-linkon" at macgpio0 offset 0x5b not configured "cpu-vcore-select" at macgpio0 offset 0x6b not configured "extint-gpio4" at macgpio0 offset 0x5c not configured "gpio9" at macgpio0 offset 0x73 not configured "extint-gpio12" at macgpio0 offset 0x64 not configured "escc-legacy" at macobio0 offset 0x12000 not configured zs0 at macobio0 offset 0x13000: irq 22,23 zstty0 at zs0 channel 0 zstty1 at zs0 channel 1 snapper0 at macobio0 offset 0x10000: irq 30,1,2 "timer" at macobio0 offset 0x15000 not configured adb0 at macobio0 offset 0x16000: irq 25, via-pmu, 3 targets apm0 at adb0: battery flags 0x5, 97% charged piic0 at adb0 iic1 at piic0 akbd0 at adb0 addr 2: PowerBook G3 keyboard (Japanese layout) wskbd0 at akbd0: console keyboard ams0 at adb0 addr 3: EMP trackpad <tpad> 2-button, 400 dpi wsmouse0 at ams0 mux 0 abtn0 at adb0 addr 7: brightness/volume/eject buttons "battery" at macobio0 offset 0x0 not configured "backlight" at macobio0 offset 0xf300 not configured kiic1 at macobio0 offset 0x18000 iic2 at kiic1 wdc0 at macobio0 offset 0x1f000 irq 19: DMA wd0 at wdc0 channel 0 drive 0: <SUNEAST SSD SE800 mSATA 256GB> wd0: 16-sector PIO, LBA48, 244198MB, 500118192 sectors atapiscsi0 at wdc0 channel 0 drive 1 scsibus1 at atapiscsi0: 2 targets cd0 at scsibus1 targ 0 lun 0: <LG, CD-ROM CRN-8245B, AHTA> removable wd0(wdc0:0:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 2 cd0(wdc0:0:1): using PIO mode 4, DMA mode 2, Ultra-DMA mode 2 audio0 at snapper0 ohci0 at pci1 dev 24 function 0 "Apple Pangea USB" rev 0x00: irq 27, version 1.0 ohci1 at pci1 dev 25 function 0 "Apple Pangea USB" rev 0x00: irq 28, version 1.0 usb0 at ohci0: USB revision 1.0 uhub0 at usb0 configuration 1 interface 0 "Apple OHCI root hub" rev 1.00/1.00 addr 1 usb1 at ohci1: USB revision 1.0 uhub1 at usb1 configuration 1 interface 0 "Apple OHCI root hub" rev 1.00/1.00 addr 1 mpcpcibr2 at mainbus0 pci: uni-north pci2 at mpcpcibr2 bus 0 "Apple Pangea FireWire" rev 0x00 at pci2 dev 14 function 0 not configured gem0 at pci2 dev 15 function 0 "Apple Pangea GMAC" rev 0x00: irq 41, address 00:03:93:c7:d1:20 bmtphy0 at gem0 phy 0: BCM5221 100baseTX PHY, rev. 4 umass0 at uhub1 port 1 configuration 1 interface 0 "Verbatim STORE N GO" rev 2.00/1.00 addr 2 umass0: using SCSI over Bulk-Only scsibus2 at umass0: 2 targets, initiator 0 sd0 at scsibus2 targ 1 lun 0: <Verbatim, STORE N GO, 5.00> removable serial.18a503076B61B2C00142 sd0: 7389MB, 512 bytes/sector, 15133248 sectors vscsi0 at root scsibus3 at vscsi0: 256 targets softraid0 at root scsibus4 at softraid0: 256 targets bootpath: /pci@f2000000/mac-io@17/ata-4@1f000/disk@0:/tbsd root on wd0a (1a3833755fe31710.a) swap on wd0b dump on wd0b initializing kernel modesetting (RV200 0x1002:0x4C57 0x1002:0x4C57 0x00). [drm] *ERROR* Unable to locate a BIOS ROM radeondrm0: 1024x768, 16bpp wsdisplay0 at radeondrm0 mux 1: console (std, vt100 emulation), using wskbd0 wsdisplay0: screen 1-5 added (std, vt100 emulation)