shithub: docs.9front.org

ref: dc4130953531aad5ddeb7ff0bc3cb10fda7d35f1
dir: /building-go.md/

View raw version
Building Go from source
===

If you don't already have some version of Go installed it's best to
grab a bootstrap tarball built by 9legacy folks:

	cd /tmp
	hget http://www.9legacy.org/download/go/go1.14.1-plan9-amd64-bootstrap.tbz | bunzip2 -c | tar x

Next, grab the source for the version of Go you want to build:

	hget https://golang.org/dl/go1.15.2.src.tar.gz | gunzip -c | tar x

With the bootstrap and source ready to build we'll need to create a `GOROOT`.
The usual location, and the one we'll use here, is `/sys/lib/go/$arch-$version`.
Create the directory and bind the downloaded Go source directory over it,
then change into the `src/` directory under the real `GOROOT` so that the
correct path is picked up during the build:

	mkdir -p /sys/lib/go/amd64-1.15.2
	bind -c go /sys/lib/go/amd64-1.15.2
	cd /sys/lib/go/amd64-1.15.2/src

Finally, we can start the build, making sure to set the `GOROOT_BOOTSTRAP`
environment variable to the path where the bootstrap package is extracted:

	GOROOT_BOOTSTRAP=/tmp/go-plan9-amd64-bootstrap
	make.rc

This will build the binaries under `$GOROOT/bin`. You can install these with:

	cp $GOROOT/bin/* /$objtype/bin

or bind them with `/bin` in your profile:

	bind -b $GOROOT/bin /bin