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.

    mkdir -p gobuild
    cd gobuild
    git clone go1.8.3
    cd go1.8.3
    git checkout go1.8.3
    export GOHOSTARCH=arm
    export GOARCH=arm64
    export GOOS=linux
    cd src

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.

    scp -r raspberrypi.local:gobuild/*.tbz ./
    tar jxvf go-linux-arm64-bootstrap.tbz
    export GOROOT=go-linux-arm64-bootstrap
    go-linux-arm64-bootstrap/bin/go version
    unset GOROOT
    git clone
    cd go
    git checkout go1.8.3
    export GOROOT_BOOTSTRAP=$HOME/go-linux-arm64-bootstrap
    cd src

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.