Skip to content

Commit

Permalink
fumbling
Browse files Browse the repository at this point in the history
  • Loading branch information
cellularmitosis committed May 2, 2020
1 parent 7a8187d commit 4994f3d
Showing 1 changed file with 138 additions and 0 deletions.
138 changes: 138 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,141 @@ go tool dist: unknown $GOARCH ppc
The first error comes from `src/cmd/go/internal/work/action.go`, in `func CheckGOOSARCHPair`.

In `src/cmd/dist/build.go`, add `ppc` to the `okgoarch` array.

Next failure:

```
Building packages and commands for target, linux/ppc.
cmd/go: unsupported GOOS/GOARCH pair linux/ppc
go tool dist: FAILED: /home/cell/github/pepaslabs/go-ppc/pkg/tool/linux_amd64/go_bootstrap install -gcflags=all= -ldflags=all= -v std cmd: exit status 2
```

`CheckGOOSARCHPair` checks the map `OSArchSupportsCgo` in `src/cmd/go/internal/cfg/zosarch.go`.

We need to add `"linux/ppc": true` to this map, but the first line of the file notes *Code generated by go tool dist; DO NOT EDIT.*.

`zosarch.go` is generated by the function `mkzosarch` in `src/cmd/dist/buildgo.go`.

Running `go tool dist` gets us:

```
$ go tool dist
usage: go tool dist [command]
Commands are:
banner print installation banner
bootstrap rebuild everything
clean deletes all built files
env [-p] print environment (-p: include $PATH)
install [dir] install individual directory
list [-json] list all supported platforms
test [-h] run Go test(s)
version print Go version
All commands take -v flags to emit extra information.
```

Let's try `go tool dist bootstrap`:

```
$ go tool dist bootstrap -v
go tool dist: mkdir /usr/local/go/pkg/obj/go-build: permission denied
```

Perhaps as root?

```
# go tool dist bootstrap -v
Building Go toolchain1 using /root/go1.4.
go tool dist: FAILED: /root/go1.4/bin/go install -gcflags=-l -tags=math_big_pure_go compiler_bootstrap -v bootstrap/cmd/...: fork/exec /root/go1.4/bin/go: no such file or directory
```

Perhaps I just need to run `make.bash`?

```
$ ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.14.2 linux/amd64)
Building Go toolchain1 using /usr/local/go.
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 linux/amd64.
---
Installed Go for linux/amd64 in /home/cell/github/pepaslabs/go-ppc
Installed commands in /home/cell/github/pepaslabs/go-ppc/bin
```

That seemed to work...

But zosarch.go still hasn't been updated:

```
$ cat cmd/go/internal/cfg/zosarch.go | grep ppc
"aix/ppc64": true,
"linux/ppc64": false,
"linux/ppc64le": true,
```

Welp, let's try editing `zosarch.go` by hand.

```
$ ./build-linux-ppc.sh
...
Building packages and commands for target, linux/ppc.
cmd/go: unsupported GOOS/GOARCH pair linux/ppc
go tool dist: FAILED: /home/cell/github/pepaslabs/go-ppc/pkg/tool/linux_amd64/go_bootstrap install -gcflags=all= -ldflags=all= -v std cmd: exit status 2
```

Hmm.

Ok, so my current `go` binary doesn't support `linux/ppc`, and it is what is failing:

```
$ go tool dist list | grep ppc
aix/ppc64
linux/ppc64
linux/ppc64le
```

So first I need to build a `go` which doesn't abort as soon as it sees a `linux/ppc` `GOOS/GOARCH`.

Let's try `GOOS=linux GOARCH=ppc ./bootstrap.bash`.

```
$ GOOS=linux GOARCH=ppc ./bootstrap.bash
#### Copying to ../../go-linux-ppc-bootstrap
#### Cleaning ../../go-linux-ppc-bootstrap
Removing VERSION.cache
Removing bin/
Removing pkg/
Removing src/cmd/cgo/zdefaultcc.go
Removing src/cmd/dist/dist
Removing src/cmd/go/internal/cfg/zdefaultcc.go
Removing src/cmd/go/internal/cfg/zosarch.go
Removing src/cmd/internal/objabi/zbootstrap.go
Removing src/go/build/zcgo.go
Removing src/runtime/internal/sys/zversion.go
#### Building ../../go-linux-ppc-bootstrap
cmd/go: unsupported GOOS/GOARCH pair linux/ppc
Building Go cmd/dist using /usr/local/go. ()
Building Go toolchain1 using /usr/local/go.
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 host, linux/amd64.
Building packages and commands for target, linux/ppc.
cmd/go: unsupported GOOS/GOARCH pair linux/ppc
go tool dist: FAILED: /home/cell/github/pepaslabs/go-linux-ppc-bootstrap/pkg/tool/linux_amd64/go_bootstrap install -gcflags=all= -ldflags=all= std cmd: exit status 2
```

Also, `zosarch.go` has been reset and no longer contains `linux/ppc`:

```
$ cat cmd/go/internal/cfg/zosarch.go | grep ppc
"aix/ppc64": true,
"linux/ppc64": false,
"linux/ppc64le": true,
```

0 comments on commit 4994f3d

Please sign in to comment.