]> Cypherpunks repositories - gostls13.git/commit
cmd/go: add detection of toolchain switch loops
authorRuss Cox <rsc@golang.org>
Fri, 26 May 2023 03:28:39 +0000 (23:28 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 31 May 2023 15:20:23 +0000 (15:20 +0000)
commit97a2ed74adbb389ce2e8da790dc3567e89e2af71
tree635d071364ee32b73eeab98b85d8426bd68a1df7
parent125c2cac642c4feacfc7d98a52f2287646d03fc7
cmd/go: add detection of toolchain switch loops

This happens mainly during testing because the virtual
toolchain switch is not terribly robust, and if you accidentally
try to exec "1.23" instead of "go1.23" it will let you, but it
won't work right.

Of course, although we feel pretty good about the non-test
implementation, perhaps it has a toolchain switch loop lurking too,
or perhaps one will be introduced in the future.

To handle the test bug, and just in case we have a real bug later,
add detection of toolchain switch loops with clear messages.

Also fixes a bug in setting the -lang flag properly when invoking
the Go compiler: this is the first test using 'go 1.21.x' lines
during a build.

For #57001.

Change-Id: I0ece3dd718596689a23b677cf08ddf32ea97bc57
Reviewed-on: https://go-review.googlesource.com/c/go/+/498436
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/go/go_test.go
src/cmd/go/internal/gover/local.go [moved from src/cmd/go/internal/gover/latest.go with 52% similarity]
src/cmd/go/internal/toolchain/exec.go
src/cmd/go/internal/toolchain/toolchain.go
src/cmd/go/internal/work/exec.go
src/cmd/go/internal/work/gc.go
src/cmd/go/main.go
src/cmd/go/testdata/script/gotoolchain_local.txt
src/cmd/go/testdata/script/gotoolchain_loop.txt [new file with mode: 0644]
src/cmd/go/testdata/script/mod_get_exec_toolchain.txt
src/cmd/go/testdata/script/mod_toolchain.txt