⑨ lab ≡ ByteLabs

Plan9/Go

— Igor Böhm

To build and install Go one has to bootstrap the installation with a version of Go already compiled for Plan9. The process consists of obtaining a bootstrap version and a target version, followed by telling the target version to use the bootstrapped version to build the toolchain. Note that the bootstrap version and the target version are the same in the example below. Normally, the target version is newer than the bootstrap version.

Create temporary scratch space:

 % ramfs -u
 % cd /tmp

Download bootstrap and target versions of Go:

 % hget http://www.9legacy.org/download/go/go1.16.15-plan9-amd64-bootstrap.tbz | bunzip2  -c | tar x 
 % hget https://golang.org/dl/go1.16.15.src.tar.gz | gunzip -c | tar x

Create target installation directory and bind downloaded version to that directory:

 % mkdir -p /sys/lib/go/amd64-1.16.15
 % bind -c go /sys/lib/go/amd64-1.16.15 

Setup GOROOT_BOOTSTRAP:

 % cd /sys/lib/go/amd64-1.16.15/src 
 % GOROOT_BOOTSTRAP=/tmp/go-plan9-amd64-bootstrap

Configure loopback address to pass standard library tests:

 % ip/ipconfig -P loopback /dev/null 127.1 
 % ip/ipconfig -P loopback /dev/null ::1

Build and install:

 % ./make.rc
Building Go cmd/dist using /tmp/go-plan9-amd64-bootstrap
Building Go toolchain1 using /tmp/go-plan9-amd64-bootstrap.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for plan9/amd64.
---
Installed Go for plan9/amd64 in /sys/lib/go/amd64-1.16.15
Installed commands in /sys/lib/go/amd64-1.16.15/bin
*** You need to bind /sys/lib/go/amd64-1.16.15/bin before /bin.

Persist installation and cleanup:

 % unmount /sys/lib/go/amd64-1.16.15 
 % dircp /tmp/go /sys/lib/go/amd64-1.16.15 
 % cp /sys/lib/go/amd64-1.16.15/bin/* /amd64/bin 
 % unmount /tmp

Extend $home/lib/profile with:

 % cat $home/lib/profile
...
GO111MODULE=on
switch($service){
case terminal
	bind -a $home/go/bin /bin
...	

To build go modules CA certificates are required:

 % hget https://curl.haxx.se/ca/cacert.pem >/sys/lib/tls/ca.pem 

#Plan9 #9front