Skip to content

Instantly share code, notes, and snippets.

View dmorn's full-sized avatar
:octocat:

Daniel Morandini dmorn

:octocat:
View GitHub Profile
@dmorn
dmorn / crossgo.md
Last active May 2, 2020 07:09
Notes on cross compiling a Go distribution

If you cannot get Go installed on your device either because a binary distribution is missing or there are not enough resources (ram, disk space) to directly compile it from source, but your target operating system and CPU architecture are supported, you can still do a cross-compilation from a host that has a working Go installation on it! There are some things you have to take care of, I thought it was worth sharing them.

Go compiles itself after version 1.4, probabily you need a different approach if you target a previous version.

From this point on, I'll call host the device where you have Go available, target the one where you would like it to be (in my case a raspberry Pi 2 running FreeBSD).

On the host

First we need to get the source from somewhere (here I'm following the official guide)

$ git clone https://go.googlesource.com/go goroot

Keybase proof

I hereby claim:

  • I am jecoz on github.
  • I am jecoz (https://keybase.io/jecoz) on keybase.
  • I have a public key ASAPzD3B7xgCwOjdGEWvpqx1iZCVG4AoFi86rZAOB3GdjQo

To claim this, I am signing this object: