Help with porting golang

Error on runtime. Need help creating elf Haiku.

eDozor/haiku-go1.16.7 (

Not experienced there, but did you try searching the forum? I think there has been plenty of talk about go(lang)?

@return_0e has a port where some progress had been made GitHub - golang-haiku/go: The Haiku port of the Go programming language for upstream support. Changes are made in 'golang-1.11-haiku' or 'golang-haiku-master'.

I believe there is a port in HaikuDepot, but it’s rather old. Both should be good starting points to see what changes are needed to make it work. I can confirm that the version in HaikuDepot does make a working binary, at least a “hello world”.

1 Like

Here’s the link and GO ports!

1 Like

Please write instructions on how to build the Haiku binary. I can not get to collect. Sorry for my English

We really need a functional golang port. A lot of cool things could be done under Haiku with it.
(for example, podman should run under haiku in remote mode with few modifications letting us develop linux containers under haiku when paired with a VM)

The current golang 1.4.x port is essentially the last “C” version of golang.
Last I checked, a lot of bugs existed even in our old 1.4.x port.

To build golang under Haiku, after making applying changes to make it build under Haiku, you’ll need to do one of the following:

  • Fix any remaining critical bugs in our golang 1.4.x port, then compile the latest golang under Haiku using 1.4.x golang
  • A native port of gcc-go to compile golang
  • Cross-compile golang for Haiku using a linux system / a sysroot / a cross compiler (aka haiku cross-tools)

tldr; golang 1.4.x is really only useful to try and get later versions of golang building.

I had been about to start my own thread re: getting to a self hosted go compiler… but then it seemed maybe better to resurrect this old thread.

I’d love to have haiku as a daily driver and honestly Go is the big thing holding it back for me. Most of my work, both for pleasure and business, is in Go. There has also been talk of Go being needed for docker and podman. I’m sure there are lots of other great pieces of software that could be built for Haiku with golang available. It would also likely be possible to make a wrapper lib to support native haiku GUI development from Go… but first we need a decent working version (or at least something stable and newer than 1.4).

Is there a sense of how much dev time would be required to get us to the following:

  • A self-hosted go compiler (preferably with the rest of the toolchain)
  • Appropriate syscalls for haiku within the syscall section of the stdlib

My C abilities are nowhere near the level required to work on getting to self-hosting. :frowning: So, sadly I am of little direct help.

I imagine that if there was someone that could easily do this it would be done by now. However, sometimes money can be a motivating factor for choosing how to spend available time: would money put toward this be something that would make a difference? I would be happy to donate some funds (maybe a few hundred USD) to get this working and it is possible that others would also be interested in chipping in to get some focused dev time on this. That said, I am not sure that there is anyone that can do this that was holding back because they needed the funds… but I figured I’d ask.


I don’t think it’s possible to start from C anymore.

Basically you have two options:

  • Use the existing Go 1.4 to compile later versions, one by one, until you get an up to date one, or
  • Figure out how to compile Go on Linux so it emits Haiku executables, then use that to build Go for Haiku

In older versions of Go there used to be a way to build starting with a C compiler, but not anymore. The newer versions of Go are written in Go.


I started a cross compiling effort, but have not had much time yet. It seems to be off to a good start but there is a lot of work to be done. Wiki info here Building from Linux · tqh/go Wiki · GitHub, and the source tree contains my work.

(Note that when doing a port it is very important to document places that needs work, decisions made and other factors so they can be revisited as you progress further.)


This looks like a great start @tqh and I think @PulkoMandy is right and going this route (cross compiling) seems like it may be the better route at this point.

@tqh is this something you are wanting to do/spearhead (as time permits)? If so, is there any specific support or help the community here can provide? I’m not sure what I can offer (I do not know a lot about compiler internals or low level Haiku code/binary support), but I am open to researching things. It sounds like you do not have a lot of time on your hands to work on this, but if you manage to find time to open issues on that repo with what needs to be done (to your knowledge) maybe various members here could try to pick off some of it or help organize and tag it to enlist efforts from other developers.


@korli is probably further along, so pinging him here.
Some of the code in my tree might be useful (signals, TLS?), so can perhaps be good to look at my commit history if needed.


thanks @tqh

I’m posting what I have so far:

Build tested with Go 1.18.x on Linux amd64 from the src directory.

GOROOT_BOOTSTRAP=~/go-1.18-linux/ GOOS=haiku GOARCH=amd64 ./bootstrap.bash

The one problem is the use of fork/exec for go compilation which requires a good swap on Haiku. When it fails, one can launch again until it succeeds.
Runtime requires hrev56220 or newer.


Oooh, nice, can you give some info on status? Does the build then produce working go apps?


Using what you have posted @korli, I was also able to cross-compile from macOS to bootstrap a go 1.18.2 toolchain for Haiku and it does indeed cross-compile a working executable in Haiku which is more further than we have gotten with porting Go. I believe this is the latest version of the complier we have working right now. Nice work @korli!

I haven’t tried yet but I guess that attempting to compile some go code would result in errors due to the fork/exec issues @korli already mentioned.


This is great news! A running compiler built for the system is a big step :smiley:

Thanks @tqh @korli and @return_0e for all your work trying to get this to happen!

I managed to cross compile from MacOS Monterey on a MacBook Pro M1, too.
I did not succeed to build GitHub CLI from source, though.

go: downloading v1.0.0
script/build.go:37:2: Get "": dial tcp: lookup on [::1]:53: read udp [::1]:63588->[::1]:53: i/o timeout

Could it be related to the fork/exec problem @korli mentioned before or something else?


I think the network doesn’t work yet.


Hello… I am a student interested in learning something about this project. This project seems fun but I cannot research much info for a beginner on “How to port a language to support an OS” or “How to port a program to support a new language”, I want to learn a bit of the above topic, could I ask some help to recommend some course/website/tutorial on above topic.

Here is a topic I opended Advice on porting language to support HaiKu

1 Like

Meanwhile Go 1.20 Released With Preview PGO Support, CPU Architecture Feature Build Flags - Phoronix

Golang 1.20.5 has been released 5 days ago: