Cross compiling Go 1.8.3 for Pine64 Pinebook

By R. S. Doiel 2017-06-16

Pine64’s Pinebook has a 64-bit Quad-Core ARM Cortex A53 which is not the same ARM processor found on a Raspberry Pi 3. As a result it needs its own compiled version of Go. Fortunately cross compiling Go is very straight forward. I found two helpful Gists on GitHub discussing compiling Go for a 64-Bit ARM processor.

I am using a Raspberry Pi 3, raspberrypi.local, as my cross compile host. Go 1.8.3 is already compiled and available. Inspired by the gists I worked up with this recipe to bring a Go 1.8.3 to my Pinebook.

  1. cd
  2. mkdir -p gobuild
  3. cd gobuild
  4. git clone https://github.com/golang/go.git go1.8.3
  5. cd go1.8.3
  6. git checkout go1.8.3
  7. export GOHOSTARCH=arm
  8. export GOARCH=arm64
  9. export GOOS=linux
  10. cd src
  11. ./bootstrap.bash

After the bootstrap compile is finished I switch to my Pinebook, copy the bootstrap compiler to my Pinebook and use it to compile a new go1.8.3 for Pine64.

  1. cd
  2. scp -r raspberrypi.local:gobuild/*.tbz ./
  3. tar jxvf go-linux-arm64-bootstrap.tbz
  4. export GOROOT=go-linux-arm64-bootstrap
  5. go-linux-arm64-bootstrap/bin/go version
  6. unset GOROOT
  7. git clone https://github.com/golang/go
  8. cd go
  9. git checkout go1.8.3
  10. export GOROOT_BOOTSTRAP=$HOME/go-linux-arm64-bootstrap
  11. cd src
  12. ./all.bash

all.bash will successfully compile go and gofmt but fail on the tests. It’s not perfect but appears to work as I explore building Go applications on my Pinebook. Upcoming Go releases should provide better support for 64 bit ARM.