As stated on the official Golang site, there is no binary distribution for ARM yet.

I'll have to compile GO from source, and it might not be straightforward, and require a few tries. Compilation itself is more likely to succeed if I have a lot of RAM and plenty of HDD space. Also I don't want to mess up with my tiny system during the several try-error compilation attempts.

Is it possible for me to use my desktop PC with Ubuntu to make the compilation, with all the flags indicating that the target platform is my ARM-based Raspberry Pi?

Thanks in advance, any experience feedback will be welcome.

  • Note : my Pi is a Model B so it has 512MB of RAM and an Ethernet plug.
    – Deleplace
    Commented Jan 20, 2013 at 17:19

2 Answers 2


I would try it on the pi itself, it seems simpler. The tutorial page you point at lists only gcc and mercurial as dependencies, these are simple and safe to install. Further, you can avoid mercurial if you just download the source as a tarball.

On the raspberry forum there is a useful thread about installing go on the Pi. In particular: you have to set the environment variable GOARM=5 before compiling, to choose the correct ARM instruction set.

I just tested building go on my 256 MB Pi with raspbian.

sudo apt-get install gcc libc6-dev mercurial
mkdir src
cd src
hg clone -u release https://code.google.com/p/go #takes several minutes
cd go/src
GOARM=5 ./make.bash 

GOARM=5 chooses an appropriate instruction set make.bash just compiles, while all.bash runs some tests as well.

Compilation succeeded, and I was able to run the hello.go example.

GOARM=5 ~/src/go/bin/go run hello.go

note that the GOARM variable again needed to be set. Put it in .bashrc or some appropriate place to set it permanently.

Cross-compilation is in general possible, though. These instructions for cross-compiling the kernel, might help.

EDIT: reading further in the forum thread, I saw that there is a golang package in the raspbian repositories. You could try installing it. According to the forum, you still need the environment variable GOARM=5 when running.

  • Thank you Frepa, I'll give it a try right now. For i'm not sure why "GOARM=5" and "./make.bash" are on the same line, I will use "export GOARM=5". Feedback very soon :)
    – Deleplace
    Commented Jan 20, 2013 at 16:25
  • export should work, then the variable stays for the rest of your shell session. Putting variables on the same line as the command is a way of setting them for just that command, there is no particular reason to do that here.
    – Frepa
    Commented Jan 20, 2013 at 16:55
  • The compilation steps you provided worked like a charm. Yabadabadoo ! It results in 191MB in the new "src" directory (not prohibitive, but good to be aware of).
    – Deleplace
    Commented Jan 20, 2013 at 18:11
  • I now have to try the raspbian repo solution, and wait a little to know if someone has actually cross-compiled, before marking your answer as the Accepted one. Also I will vote you up when I gain the privilege. Best regards
    – Deleplace
    Commented Jan 20, 2013 at 18:16
  • sudo apt-get install golang is fine, but then go version -> crash SIGILL: illegal instruction PC=0x7d394, even with GOARM=5. For now it is easier for me to compile from source than to try to tamper with the repo stuff. Hopefully it will be fixed one day and won't need tampering anymore.
    – Deleplace
    Commented Jan 21, 2013 at 15:18

I just set-up a gcc/++ cross-compiler targeting the pi (hard float armv6, etc) on a linux x86-64 desktop using crosstool-ng, and was pretty impressed with how user friendly the crosstool is (the interface is exactly like the kernel source's make menuconfig, including help for all options and a / search). It even downloads all the necessary tarballs for you.

I've been a C programmer for years but the idea of configuring all that manually made me want to retch, so hooray crosstool-ng.

The compiler compiles but I won't be able to test any executables on the pi until later today or tomorrow, at which point I'll update this post. However, seeing as how I found it recommended somewhere by a pi-head, I assume this should work.

[Later...] It does work, but here's the rub: WRT non-trivial stuff involving a lot of infrastructure, autotools configure, pkg-config, etc -- pure headache. I would only go that route if I had no other choice at all.

My advice would be to build GO from source on your desktop, for your desktop, without installing, just so you can check how the configure options etc. work out. Once you have that straight, do it on the pi and leave it alone for however long it takes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.