Hi,
Been working on porting go1.4 to the powerpc 32-bit for the last month or so. It is still early on, but I wanted to share some progress. I'm testing on a PowerbookG4 and targeting 10.4 Tiger. This is a small demo script to show some of the technical details. I also created some tools along the way to help with the port including pynm which is similar to "go tool nm" but written in python and godiag.py which does disassembly tasks on the go binaries for diagnostics. C based tools like 9c/9g/9l are functional and still working on getting go_bootstrap going, but it is close. I'm past most of the 64-bit fun, the many R0 bugs, with goroutines and GC up and running this week.
All of this will make its way over to github soon. https://github.com/noworrieseh
Been working on porting go1.4 to the powerpc 32-bit for the last month or so. It is still early on, but I wanted to share some progress. I'm testing on a PowerbookG4 and targeting 10.4 Tiger. This is a small demo script to show some of the technical details. I also created some tools along the way to help with the port including pynm which is similar to "go tool nm" but written in python and godiag.py which does disassembly tasks on the go binaries for diagnostics. C based tools like 9c/9g/9l are functional and still working on getting go_bootstrap going, but it is close. I'm past most of the 64-bit fun, the many R0 bugs, with goroutines and GC up and running this week.
All of this will make its way over to github soon. https://github.com/noworrieseh
$ ./demo
$ hostinfo
Mach kernel version:
Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC
Kernel configured for a single processor only.
1 processor is physically available.
Processor type: ppc7450 (PowerPC 7450)
Processor active: 0
Primary memory available: 2.00 gigabytes
Default processor set: 63 tasks, 161 threads, 1 processors
Load average: 1.20, Mach factor: 0.06
$ gcc --version
gcc (GCC) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cat hello.go
package main
func main() {
println("hellorld")
}
$ cat tools/buildgo
#!/bin/bash
PRG=$1
BIN=${PRG%.go}
go1-4/pkg/tool/darwin_ppc/9g -S "${PRG}" > "${BIN}.out"
go1-4/pkg/tool/darwin_ppc/9l -o "${BIN}" "${BIN}.9"
$ file go1-4/pkg/tool/darwin_ppc/9g
go1-4/pkg/tool/darwin_ppc/9g: Mach-O executable ppc
$ file go1-4/pkg/tool/darwin_ppc/9l
go1-4/pkg/tool/darwin_ppc/9l: Mach-O executable ppc
$ rm -f hello hello.9 hello.out
$ ls -l hello*
-rw-r--r-- 1 andrew andrew 51 Mar 19 22:40 hello.go
$ ./tools/buildgo hello.go
$ ls -l hello*
-rwxr-xr-x 1 andrew andrew 796000 Mar 19 22:51 hello
-rw-r--r-- 1 andrew andrew 1939 Mar 19 22:51 hello.9
-rw-r--r-- 1 andrew andrew 51 Mar 19 22:40 hello.go
-rw-r--r-- 1 andrew andrew 4976 Mar 19 22:51 hello.out
$ file hello
hello: Mach-O executable ppc
$ pynm hello | grep main
00000000000790c8 T _main
0000000000002088 T main.init
00000000000bc926 B main.initdone.
0000000000002000 T main.main
000000000002d0f8 T runtime.main
0000000000097518 R runtime.main.f
000000000007e348 T runtime.main_init
000000000007e350 T runtime.main_main
$ ./tools/godiag.py --binary=hello inspect --func main.main
=== main.main @ 0x00002000 (34 instrs) ===
00002000: 807e0008 lwz r3,8(r30)
00002004: 7c030840 cmplw r3,r1
00002008: 41800014 blt +20 (0x0000201c)
0000200c: 7ca802a6 mflr r5
00002010: 48052391 bl +336784 (0x000543a0) ; runtime.morestack_noctxt
00002014: 7c000278 xor r0,r0,r0
00002018: 4bffffe8 b -24 (0x00002000) ; main.main
0000201c: 7fe802a6 mflr r31
00002020: 97e1fff0 stwu r31,-16(r1)
00002024: 7c000278 xor r0,r0,r0
00002028: 3fe00009 lis r31,9
0000202c: 38ffe810 addi r7,r31,-6128
00002030: 7ce73b78 or r7,r7,r7
00002034: 7ce83b78 or r8,r7,r7
00002038: 38e10004 addi r7,r1,4
0000203c: 7ce73b78 or r7,r7,r7
00002040: 3908fffc addi r8,r8,-4
00002044: 38e7fffc addi r7,r7,-4
00002048: 85280004 lwzu r9,4(r8)
0000204c: 95270004 stwu r9,4(r7)
00002050: 85280004 lwzu r9,4(r8)
00002054: 95270004 stwu r9,4(r7)
00002058: 3be10004 addi r31,r1,4
0000205c: 7fe0fb78 or r0,r31,r31
00002060: 4802abc9 bl +175048 (0x0002cc28) ; runtime.printstring
00002064: 7c000278 xor r0,r0,r0
00002068: 3be10004 addi r31,r1,4
0000206c: 7fe0fb78 or r0,r31,r31
00002070: 480292c1 bl +168640 (0x0002b330) ; runtime.printnl
00002074: 7c000278 xor r0,r0,r0
00002078: 83e10000 lwz r31,0(r1)
0000207c: 7fe803a6 mtlr r31
00002080: 38210010 addi r1,r1,16
00002084: 4e800020 blr
$ ./hello 2>&1 | grep -vE "LOG|PA"
hellorld
$ cat demo
#!/bin/bash
for cmd in hostinfo "gcc --version" \
"cat hello.go" "cat tools/buildgo" \
"file go1-4/pkg/tool/darwin_ppc/9g" \
"file go1-4/pkg/tool/darwin_ppc/9l" \
"rm -f hello hello.9 hello.out" \
"ls -l hello*" \
"./tools/buildgo hello.go" \
"ls -l hello*" \
"file hello" \
"pynm hello | grep main" \
"./tools/godiag.py --binary=hello inspect --func main.main" \
'./hello 2>&1 | grep -vE "LOG|PA"' \
"cat demo"; do
echo "\$ $cmd"
eval "$cmd"
done
Last edited: