make.bat: don't try to download a newer toolchain

Calling `go env GOROOT` and `go version` will try to download a newer
toolchain if the current one is too old. This is not what we want when
building the toolchain itself. Avoid this by setting `GO111MODULE=off`.

While here, align the unset variables with nogoenv(), present in
make.bash and make.rc.

Fixes #62201
Fixes #62281

Change-Id: I2d3ac817c2fb161f7a31bf83e32ba934e773b6c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/523015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
qmuntal 2023-08-25 14:29:13 +02:00 committed by Quim Muntal
parent 071aed2aaa
commit 106afda184
1 changed files with 15 additions and 10 deletions

View File

@ -77,7 +77,10 @@ if not exist ..\bin\tool mkdir ..\bin\tool
if not "x%GOROOT_BOOTSTRAP%"=="x" goto bootstrapset
for /f "tokens=*" %%g in ('where go 2^>nul') do (
if "x%GOROOT_BOOTSTRAP%"=="x" (
setlocal
call :nogoenv
for /f "tokens=*" %%i in ('"%%g" env GOROOT 2^>nul') do (
endlocal
if /I not "%%i"=="%GOROOT_TEMP%" (
set GOROOT_BOOTSTRAP=%%i
)
@ -96,18 +99,13 @@ set GOROOT=%GOROOT_TEMP%
set GOROOT_TEMP=
setlocal
set GOOS=
set GOARCH=
set GOEXPERIMENT=
call :nogoenv
for /f "tokens=*" %%g IN ('"%GOROOT_BOOTSTRAP%\bin\go" version') do (set GOROOT_BOOTSTRAP_VERSION=%%g)
set GOROOT_BOOTSTRAP_VERSION=%GOROOT_BOOTSTRAP_VERSION:go version =%
echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%. (%GOROOT_BOOTSTRAP_VERSION%)
if x%vflag==x-v echo cmd/dist
set GOROOT=%GOROOT_BOOTSTRAP%
set GOBIN=
set GO111MODULE=off
set GOENV=off
set GOFLAGS=
"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist
endlocal
if errorlevel 1 goto fail
@ -158,7 +156,7 @@ if x%4==x--distpack set bootstrapflags=%bootstrapflags% -distpack
.\cmd\dist\dist.exe bootstrap -a %vflag% %bootstrapflags%
if errorlevel 1 goto fail
del .\cmd\dist\dist.exe
goto end
goto :eof
:: DO NOT ADD ANY NEW CODE HERE.
:: The bootstrap+del above are the final step of make.bat.
@ -169,7 +167,16 @@ goto end
:copydist
mkdir "%GOTOOLDIR%" 2>NUL
copy cmd\dist\dist.exe "%GOTOOLDIR%\"
goto end
goto :eof
:nogoenv
set GO111MODULE=off
set GOENV=off
set GOOS=
set GOARCH=
set GOEXPERIMENT=
set GOFLAGS=
goto :eof
:bootstrapfail
echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
@ -178,5 +185,3 @@ echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%.
:fail
set GOBUILDFAIL=1
if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%
:end