go/src/cmd/dist
Christian Stewart b3b8d2bfeb cmd/dist: use gohostarch for ssa rewrite check
Fix a build failure when bootstrapping the Go compiler with go-bootstrap 1.4
while the environment contains GOARCH=riscv64.

Building Go toolchain1 using go-1.4-bootstrap-20171003.
src/cmd/compile/internal/ssa/rewriteRISCV64.go:4814
invalid operation: y << x (shift count type int64, must be unsigned integer)

This is because:

 - buildtool.go:198: calls bootstrapRewriteFile(src)
 - bootstrapRewriteFile: buildtool.go:283 calls:
 - isUnneededSSARewriteFile: checks os.Getenv("GOARCH")
 - isUnneededSSARewriteFile: returns "", false
 - bootstrapRewriteFile: calls bootstrapFixImports
 - boostrapFixImports: generates code go1.4 cannot compile

Instead of checking "GOARCH" in the environment, use the gohostarch variable.

Change-Id: Ie9c190498555c4068461fead6278a62e924062c6
GitHub-Last-Rev: 300d7a7fea
GitHub-Pull-Request: golang/go#52362
Reviewed-on: https://go-review.googlesource.com/c/go/+/400376
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
2022-06-02 17:15:54 +00:00
..
README
build.go cmd/dist: support spaces and quotes in CC 2022-05-26 20:14:15 +00:00
buildgo.go all: fix various doc comment formatting nits 2022-04-01 18:18:01 +00:00
buildruntime.go all: remove trailing blank doc comment lines 2022-04-01 18:18:07 +00:00
buildtag.go cmd/dist: implement //go:build parsing 2021-10-28 03:35:04 +00:00
buildtag_test.go cmd/dist: add buildtag parsing test 2021-11-25 00:02:52 +00:00
buildtool.go cmd/dist: use gohostarch for ssa rewrite check 2022-06-02 17:15:54 +00:00
doc.go all: gofmt main repo 2022-04-11 16:34:30 +00:00
exec.go cmd/dist: consistently set PWD when executing a command in a different directory 2021-09-30 20:30:12 +00:00
imports.go
main.go cmd/dist: support dist tool for loong64 2022-05-01 00:05:20 +00:00
quoted.go cmd/dist: support spaces and quotes in CC 2022-05-26 20:14:15 +00:00
sys_default.go
sys_windows.go Revert "cmd/dist: log CPU model when testing" 2022-01-14 20:50:36 +00:00
test.go cmd/dist: pass a -test.timeout option to a host test 2022-05-19 21:32:46 +00:00
test_linux.go
util.go os/exec: return error when PATH lookup would use current directory 2022-05-02 14:54:05 +00:00
util_gc.go
util_gccgo.go
vfp_arm.s all: add //go:build lines to assembly files 2021-05-13 09:12:17 +00:00
vfp_default.s all: add //go:build lines to assembly files 2021-05-13 09:12:17 +00:00

README

This program, dist, is the bootstrapping tool for the Go distribution.

As of Go 1.5, dist and other parts of the compiler toolchain are written
in Go, making bootstrapping a little more involved than in the past.
The approach is to build the current release of Go with an earlier one.

The process to install Go 1.x, for x ≥ 5, is:

1. Build cmd/dist with Go 1.4.
2. Using dist, build Go 1.x compiler toolchain with Go 1.4.
3. Using dist, rebuild Go 1.x compiler toolchain with itself.
4. Using dist, build Go 1.x cmd/go (as go_bootstrap) with Go 1.x compiler toolchain.
5. Using go_bootstrap, build the remaining Go 1.x standard library and commands.

NOTE: During the transition from the old C-based toolchain to the Go-based one,
step 2 also builds the parts of the toolchain written in C, and step 3 does not
recompile those.

Because of backward compatibility, although the steps above say Go 1.4,
in practice any release ≥ Go 1.4 but < Go 1.x will work as the bootstrap base.

See golang.org/s/go15bootstrap for more details.

Compared to Go 1.4 and earlier, dist will also take over much of what used to
be done by make.bash/make.bat/make.rc and all of what used to be done by
run.bash/run.bat/run.rc, because it is nicer to implement that logic in Go
than in three different scripting languages simultaneously.