cmd/go: unset CC when we remove it from PATH in TestScript/cgo_stale_precompiled

Otherwise, if make.bash produced a relative default CC path but the
user has an absolute path to CC set in their environment, the test
will fail spuriously.

For #64423.

Change-Id: I0f3e1d04851585e1b39266badcda9f17489332d9
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/547997
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
This commit is contained in:
Bryan C. Mills 2023-12-06 09:50:42 -05:00 committed by Gopher Robot
parent b11d19e03b
commit 77e76c4387
1 changed files with 9 additions and 5 deletions

View File

@ -29,8 +29,12 @@ env GOROOT_FINAL=$oldGOROOT_FINAL
# no longer installed anyway! Since we're requiring a C compiler in order to
# build and use cgo libraries in the standard library, we should make sure it
# matches what's in the cache.
[!abscc] env CGO_ENABLED=1
[!abscc] [!GOOS:plan9] env PATH='' # Guaranteed not to include $(go env CC)!
[!abscc] [GOOS:plan9] env path=''
[!abscc] ! go build -x runtime/cgo
[!abscc] stderr 'C compiler .* not found'
[abscc] stop
env CGO_ENABLED=1
env CC=''
[!GOOS:plan9] env PATH='' # Guaranteed not to include $(go env CC)!
[GOOS:plan9] env path=''
! go build -x runtime/cgo
stderr 'C compiler .* not found'