Skip to content

Instantly share code, notes, and snippets.

@Shemeikka
Last active April 27, 2016 14:29
Show Gist options
  • Save Shemeikka/107f15f6197c857943b42a9fc8c4bd17 to your computer and use it in GitHub Desktop.
Save Shemeikka/107f15f6197c857943b42a9fc8c4bd17 to your computer and use it in GitHub Desktop.
Building Go 1.6.2 for ARMv5 on ARM using Go 1.4.3
# Guide http://blog.hypriot.com/post/how-to-compile-go-on-arm/
# Todo
# Use named variables for versions
# Take version as a cmd argument
# Error handling
# Download Go 1.4.3 source
wget https://storage.googleapis.com/golang/go1.4.3.src.tar.gz
# Extract it
sudo tar -xzf go1.4.3.src.tar.gz -C /usr/local
# Enable CGO and set GOARCH version
export CGO_ENABLED=1
export GOARM=5
# Compile it without running tests
cd /usr/local/go/src
sudo ./make.bash
# Package Go as a binary tarball
sudo tar --numeric-owner -czf ~/go_build/go1.4.3.linux-armv5.tar.gz -C /usr/local go
# Remove Go 1.4.3 version
sudo rm -r /usr/local/go
# Install Go 1.4.3 from our own tarball into bootstrap folder
mkdir ~/go1.4
tar -xzf go1.4.3.linux-armv5.tar.gz -C $HOME/go1.4 --strip-components=1
# Download Go 1.6.2 source
wget https://storage.googleapis.com/golang/go1.6.2.src.tar.gz
# Extract it
sudo tar -xzf go1.6.2.src.tar.gz -C /usr/local
# Enable CGO and set GOARCH version
export CGO_ENABLED=1
export GOARM=5
# Compile it
cd /usr/local/go/src
sudo GOROOT_BOOTSTRAP=~/go1.4 ./make.bash
# Creat tarball
sudo tar --numeric-owner -czf ~/go_build/go1.6.2.linux-armv5.tar.gz -C /usr/local go
# Remove Go installation
sudo rm -r /usr/local/go
# Install Go from our own tarball
sudo tar -xzf go1.6.2.linux-armv5.tar.gz -C /usr/local
# Set path
export PATH=/usr/local/go/bin:$PATH
# Print version
go version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment