shithub: docs.9front.org

Download patch

ref: 23520cdd0314a2ea171ce8a7c1047fbd805a7e83
parent: 898ad50ff987486f23880f1f8d23b64d2ba52e47
author: Moody <j4kem00dy@gmail.com>
date: Thu Nov 19 01:53:57 EST 2020

Tweak building-go to build in /sys/lib/go instead of /tmp
Move old ramfs instructions to a footer, and note the issue with larger version jumps

--- a/building-go.md
+++ b/building-go.md
@@ -1,30 +1,29 @@
 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:
+First we'll need a suitable location for our 'GOROOT', the standard convention is
+to place it in '/sys/lib/go/$objtype-$version'.
 
-	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:
-
+	mkdir -p /sys/lib/go
+	cd /sys/lib/go
 	hget https://golang.org/dl/go1.15.2.src.tar.gz | gunzip -c | tar x
+	mv go amd64-1.15.2
 
-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:
+If you don't already have some version of Go installed it's best to
+grab a bootstrap tarball built by the 9legacy folks:
 
-	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
+	hget http://www.9legacy.org/download/go/go1.14.1-plan9-amd64-bootstrap.tbz | bunzip2 -c | tar x
 
-Finally, we can start the build, making sure to set the `GOROOT_BOOTSTRAP`
-environment variable to the path where the bootstrap package is extracted:
+If you have an existing install you can use that instead of the 9legacy bootstraps.
+There may be some hiccups when there are large version distances between a
+bootstrap and desired build version. It is best to use to the latest bootstrap when possible and
+some intermediate builds may be required depending on the age of the bootstrap.
 
-	GOROOT_BOOTSTRAP=/tmp/go-plan9-amd64-bootstrap
+Next we'll need to configure both 'GOROOT' and 'GOROOT_BOOTSTRAP'
+
+	GOROOT_BOOTSTRAP=/sys/lib/go/go-plan9-amd64-bootstrap
+	GOROOT=/sys/lib/go/amd64-1.15.2
+	cd amd64-1.15.2/src
 	make.rc
 
 This will build the binaries under `$GOROOT/bin`. You can install these with:
@@ -34,3 +33,23 @@
 or bind them with `/bin` in your profile:
 
 	bind -b $GOROOT/bin /bin
+
+If you have the memory available on your system it may be faster to build using a ramfs in '/tmp'.
+Setting 'GOROOT_FINAL' to the desired final location of 'GOROOT' will help in building.
+
+	mkdir -p /sys/lib/go/
+	ramfs
+	cd /tmp
+	hget https://golang.org/dl/go1.15.2.src.tar.gz | gunzip -c | tar x
+	hget http://www.9legacy.org/download/go/go1.14.1-plan9-amd64-bootstrap.tbz | bunzip2 -c | tar x
+	mv go amd64-1.15.2
+	GOROOT_BOOTSTRAP=/tmp/go-plan9-amd64-bootstrap
+	GOROOT_FINAL=/sys/lib/go/amd64-1.15.2
+	cd amd64-1.15.2/src
+	make.rc
+	dircp /tmp/amd64-1.15.2 /sys/lib/go/
+
+You can verify that GOROOT has been set properly using:
+
+	$GOROOT_FINAL/bin/go env
+