From 106afda184a16195fae754ad4a066b19ebfbd4f5 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 25 Aug 2023 14:29:13 +0200 Subject: [PATCH] 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 TryBot-Result: Gopher Robot Reviewed-by: Dmitri Shuralyov Run-TryBot: Quim Muntal Reviewed-by: Bryan Mills Reviewed-by: Dmitri Shuralyov --- src/make.bat | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/make.bat b/src/make.bat index 5e76368199..d9f9b6cb6a 100644 --- a/src/make.bat +++ b/src/make.bat @@ -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 -- 2.50.0