Plan 9 from Bell Labs’s /usr/web/sources/contrib/mospak/misc/go-install-plan9-386

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


GO INSTALLATION ON PLAN 9/386
=============================

This is a standalone procedure for installing Go 1.26.4 on a stock
9legacy Plan 9/386 machine such as gnot.

Download the files on a 9legacy machine, on another host, or by any other
method available to you.  Transfer them to gnot by your own method.  The
only requirement is that all files arrive in:

        /usr/glenda/incoming

Replace "glenda" with the user who will own the installation.

The bootstrap chain is:

        go1.4.3     built by 8c / 8l
        go1.17.13   built by go1.4.3
        go1.20.14   built by go1.17.13
        go1.22.12   built by go1.20.14
        go1.24.13   built by go1.22.12
        go1.26.4    built by go1.24.13

Go 1.4.3 is the seed: its compiler can still be built from C.  Later
releases require the preceding Go compiler as their bootstrap compiler.


1. DOWNLOAD THE FILES
=====================

Download these six source archives:

        go1.4.3.src.tar.gz
        https://dl.google.com/go/go1.4.3.src.tar.gz

        go1.17.13.src.tar.gz
        https://dl.google.com/go/go1.17.13.src.tar.gz

        go1.20.14.src.tar.gz
        https://dl.google.com/go/go1.20.14.src.tar.gz

        go1.22.12.src.tar.gz
        https://dl.google.com/go/go1.22.12.src.tar.gz

        go1.24.13.src.tar.gz
        https://dl.google.com/go/go1.24.13.src.tar.gz

        go1.26.4.src.tar.gz
        https://dl.google.com/go/go1.26.4.src.tar.gz

Also download the 9legacy fix for the Go 1.4.3 seed:

        syscall-exec.diff
        http://9legacy.org/go/patch/syscall-exec.diff

The Go release index is:

        https://go.dev/dl/

Keep the exact filenames above.  Transfer all seven files to gnot and put
them in /usr/glenda/incoming.


2. CHECKSUMS
============

The SHA-256 checksums are listed below.  The filename is on a separate line
so that the note remains within 80 columns.

        9947fc705b0b841b5938c48b22dc33e9647ec0752bae66e50278df4f23f64959
        go1.4.3.src.tar.gz

        a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd
        go1.17.13.src.tar.gz

        1aef321a0e3e38b7e91d2d7eb64040666cabdcc77d383de3c9522d0d69b67f4e
        go1.20.14.src.tar.gz

        012a7e1f37f362c0918c1dfa3334458ac2da1628c4b9cf4d9ca02db986e17d71
        go1.22.12.src.tar.gz

        639a6204c2486b137df1eb6e78ee3ed038f9877d0e4b5a465e796a2153f858d7
        go1.24.13.src.tar.gz

        4f668a32fbfc1132e6a881fb968c2f1dada631492a339211735fbb255a42602d
        go1.26.4.src.tar.gz

        32e108211b056128562a712f2b188db5e27a299f7b36ac9f68c0f6b75fc7cb05
        syscall-exec.diff

Go 1.4.3 has no publisher-provided SHA-256 value.  The digest above is
the digest of the archive used here.  Its extracted source was independently
compared with the signed go1.4.3 GitHub tag:

        https://github.com/golang/go/releases/tag/go1.4.3


3. PREPARE GNOT
===============

Log in as the user who will own the installation.  Check the architecture
and the Plan 9 C toolchain:

        echo $objtype
        grep '^(CC|LD|O)=' /$objtype/mkfile

The output must be:

        386
        CC=8c
        LD=8l
        O=8

Create the incoming directory if necessary and check that all seven files
are present:

        mkdir -p /usr/glenda/incoming
        ls -l /usr/glenda/incoming

Allow about 1.2 GB of free space while building the ladder.  On the tested
single-core gnot, the complete build took about two hours.


4. VERIFY THE TRANSFER ON GNOT
==============================

Run these commands on gnot after transferring the files:

        cd /usr/glenda/incoming
        sha1sum -2 256 go1.4.3.src.tar.gz
        sha1sum -2 256 go1.17.13.src.tar.gz
        sha1sum -2 256 go1.20.14.src.tar.gz
        sha1sum -2 256 go1.22.12.src.tar.gz
        sha1sum -2 256 go1.24.13.src.tar.gz
        sha1sum -2 256 go1.26.4.src.tar.gz
        sha1sum -2 256 syscall-exec.diff

Plan 9 calls the command "sha1sum" even when calculating SHA-256.  Compare
the hexadecimal digest itself with section 2.  Plan 9 prints a tab before
the filename.  Do not build from a missing or mismatched file.


5. BUILD THE C BOOTSTRAP SEED
=============================

Change to the user's home directory, unpack the seed, and rename it
immediately.  Every archive extracts to a directory named "go".

        cd /usr/glenda
        tar xf /usr/glenda/incoming/go1.4.3.src.tar.gz
        mv go go1.4.3

Apply the only patch used by this procedure:

        cd /usr/glenda/go1.4.3
        ape/patch -p1 < /usr/glenda/incoming/syscall-exec.diff

Build the seed:

        cd /usr/glenda/go1.4.3/src
        GOROOT=()
        GOROOT_BOOTSTRAP=()
        make.rc

The first build message should mention "Building C bootstrap tool" and
"cmd/dist".  This shows that 8c and 8l, rather than an existing Go
compiler, are building the seed.

Verify it before continuing:

        /usr/glenda/go1.4.3/bin/go version

Expected output:

        go version go1.4.3 plan9/386


6. BUILD EACH GO-ON-GO RUNG
===========================

Build the following pairs in order:

        previous compiler       source archive              new directory
        -----------------       -------------              ------------
        go1.4.3                 go1.17.13.src.tar.gz       go1.17.13
        go1.17.13               go1.20.14.src.tar.gz       go1.20.14
        go1.20.14               go1.22.12.src.tar.gz       go1.22.12
        go1.22.12               go1.24.13.src.tar.gz       go1.24.13
        go1.24.13               go1.26.4.src.tar.gz        go1.26.4

For each row, replace PREV, ARCHIVE, and NEW in this block:

        cd /usr/glenda
        tar xf /usr/glenda/incoming/ARCHIVE
        mv go NEW

        cd /usr/glenda/NEW/src
        GOROOT=()
        GOROOT_BOOTSTRAP=/usr/glenda/PREV
        GO_TEST_TIMEOUT_SCALE=3
        make.rc

For example, the first rung is:

        cd /usr/glenda
        tar xf /usr/glenda/incoming/go1.17.13.src.tar.gz
        mv go go1.17.13
        cd /usr/glenda/go1.17.13/src
        GOROOT=()
        GOROOT_BOOTSTRAP=/usr/glenda/go1.4.3
        GO_TEST_TIMEOUT_SCALE=3
        make.rc

Use make.rc, not all.rc, for these five intermediate builds.  After each
build, verify its version before continuing:

        /usr/glenda/NEW/bin/go version

After the final build, the output must be:

        go version go1.26.4 plan9/386

Do not delete previous rungs until the next rung passes its version check.
If disk space is tight, remove only a previous rung after its successor is
verified:

        rm -rf /usr/glenda/PREV
        rm -rf /usr/glenda/lib/cache/go-build


7. INSTALL THE FINAL TOOLCHAIN
==============================

Keep the final tree at /usr/glenda/go1.26.4.  Do not rename it to
/usr/glenda/go.  Plan 9's default GOPATH is /usr/glenda/go, and Go cannot
use the same directory as both GOROOT and GOPATH.

Edit /usr/glenda/lib/profile.  In the terminal profile branch, before it
starts the interactive program, add:

        GOROOT=/usr/glenda/go1.26.4
        GOTOOLCHAIN=local
        bind -a $GOROOT/bin /bin

GOTOOLCHAIN=local prevents the go command from trying to download a newer
toolchain for a module that requests one.  rc exports variables when they
are assigned; no separate export command is needed.

Start a new shell, or run the assignments and bind command in the current
shell.  Check the installation:

        go version
        go env GOROOT GOPATH GOTOOLCHAIN

Expected values include:

        go version go1.26.4 plan9/386
        GOROOT='/usr/glenda/go1.26.4'
        GOPATH='/usr/glenda/go'
        GOTOOLCHAIN='local'


8. TEST COMPILATION AND RUNTIME
===============================

Create a small program:

        mkdir -p /usr/glenda/go/src/hello
        cd /usr/glenda/go/src/hello

Create hello.go:

        package main

        import "fmt"

        func main() {
                fmt.Println("hello from plan9/386")
        }

Build and run it:

        go build
        ./hello


9. TEST GO'S OWN TLS
====================

Create net.go:

        package main

        import (
                "fmt"
                "io"
                "net/http"
        )

        func main() {
                r, err := http.Get("https://go.dev/VERSION?m=text")
                if err != nil {
                        fmt.Println("error:", err)
                        return
                }
                defer r.Body.Close()
                b, _ := io.ReadAll(r.Body)
                fmt.Printf("%s\n", b)
        }

Build and run it:

        go build -o net net.go
        ./net

A Go version string proves compilation, execution, certificate validation,
and an HTTPS connection all work.  An x509 error usually means that
/sys/lib/tls/ca.pem is absent or unreadable.

This procedure does not use libsec for Go TLS.  Go uses its own TLS
implementation.


COMMON MISTAKES
===============

* Do not skip checksum verification on gnot.
* Rename each extracted "go" directory before unpacking the next archive.
* Clear GOROOT before every build with GOROOT=().
* Set GOROOT_BOOTSTRAP only to the previous verified rung.
* Use make.rc for intermediate rungs; reserve all.rc for an optional full
  test run after installation.
* Do not use /usr/glenda/go as GOROOT.
* If a rung builds but its go binary crashes, keep that rung and stop.
  Add an intermediate supported release rather than continuing with a
  runtime failure.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.