Resurrecting this thread, because I think Korli’s work is the most recent work on porting Go?
I was able to use Korli’s code to cross-compile Go 1.18 for Haiku today (from macOS 10.13 High Sierra running Go 1.20). The resulting Go compiler really can compile working Haiku programs, but I have to recompile several times to get through the fork/exec bugs in the compiler. Also networking doesn’t work, but at least I can compile programs with networking code, which is more than I can with Go 1.4.
Some errors seems spurious - one compile error while compiling my own Go programs claimed this when it encountered a call to os.Hostname():
But compiling my program again, it was suddenly fine! Another error along the way was:
go build internal/reflectlite: mkdir: errno 2147483653
And most errors were of the form:
go build [packagename]: [path-to-compile-or-asm] fork/exec [path-to-compile-or-asm] errno 2147483653
Does anyone know what “errno 2147483653” is? My guess is it’s meant to be a negative error code and should actually be “errno -6”, but I still don’t know what that means.
I’d need networking to work in Go before I can actually get work done with this. My Go programs mostly call out to SFTP servers. But this seems like it’s actually really far along!
If it’s a Haiku error code, you’d have better luck converting it to hex.
In this case, the error translates to 0x80000005, which corresponds to B_BAD_VALUE.
Nice!
I never had time to sync the work I did with korli’s. I was careful in trying to get every commit clean, so if you have time, you might want to just walk through the commits there and compare if I did something differently.
You might be able to use strace to find the failing fork/exec calls and see if any of the arguments are obviously bad. (Note you might need to specify some flags to strace if there’s multiple threads/processes in use.)
This is a bit late, but I can compare your changes (a simple git diff HEAD~14) to the korli’s branch and make appropriate changes to the korli’s fork (with git commit –author) to sync them up, if you allow it?
So far I wasn’t able to compile programs with the korli’s fork (but I’ve only tried it once, so maybe it is possible still); but at least I was able to hack netpackage enough to get go mod tidy working, haven’t tested it further
If anyone wants to try, I have Go Haiku port here GitHub - gen2brain/go: The Go programming language · GitHub (bootstrap tarballs are attached), version is latest 1.27.1, CGo is working and supports amd64, 386, arm64 and riscv64. Sure, it is done with AI in many iterations, that is one thing they are good at, porting, and with every part of code covered with tests it was a good target. The only failing tests are caused by issues and bugs in Haiku, I have the notes but I need to understand it better before I can report something here. And of course, it cannot do -race detection, that is a component of LLVM that must be ported.