Skip to content

Building Go 1.6 on Z Without Cross Compiling

billotosyr edited this page Jun 15, 2016 · 2 revisions

Building Go 1.6 on z Without Cross Compiling

These instructions describe how to build version 1.6 of Go for IBM Linux on z Systems running SLES 12 or RHEL 7.x. Ubuntu 16.0.4 is already distributed with a Go 1.6 compiler. These instructions do not require you to download an x86 binary or to cross compile from an x86 machine. All the steps are completed on a Linux on Z server.

Building Go for IBM Linux on z Systems is a four stage process:

  1. Download and unpack a Go compiler from the Ubuntu Launchpad
  2. Download a Go version 1.6 source tree for Linux on Z
  3. Use the Launchpad compiler to generate a bootstrap compiler
  4. Use the resulting bootstrap compiler to build Go

Step 1: Download and unpack a Go compiler from the Ubuntu Launchpad

  1. Create a directory; we will use $HOME/ubuntu

  2. cd to $HOME/ubuntu and execute this command

wget http://launchpadlibrarian.net/253551511/golang-1.6-go_1.6.1-0ubuntu1_s390x.deb ```

  1. Execute the following commands in $HOME/ubuntu:

ar -x golang-1.6-go_1.6.1-0ubuntu1_s390x.deb tar -xvf data.tar.xz rm usr/lib/go-1.6/src ```

Step 2: Download a Go version 1.6 source tree for Linux on Z

  1. Change to $HOME and execute the following:

git clone git@github.com:linux-on-ibm-z/go.git cd go git checkout release-branch.go1.6 ```

Step 3: Use the Launchpad compiler to generate a bootstrap compiler

  1. Execute:

cp -r $HOME/go/src $HOME/ubuntu/usr/lib/go-1.6/ ```

  1. Create this file:

    $HOME/ubuntu/usr/lib/go-1.6/src/runtime/internal/sys/zversion.go

    with the following text as its content:

// auto generated by go tool dist

package sys

const DefaultGoroot = /sandbox/billo/go1.6/go const TheVersion = go1.6 const Goexperiment = `` const StackGuardMultiplier = 1

3. Execute:

export GOROOT=$HOME/go export GOROOT_BOOTSTRAP=$HOME/ubuntu/usr/lib/go-1.6 cd $HOME/go/src GOOS=linux GOARCH=s390x ./bootstrap.bash


#### Step 4: Use the resulting bootstrap compiler to build Go

1. In $HOME/go/src execute:

export GOROOT_BOOTSTRAP=$HOME/go-linux-s390x-bootstrap ./all.bash


The go compiler will build and run its built-in tests.