]> Cypherpunks repositories - gostls13.git/commitdiff
make.bat: don't try to download a newer toolchain
authorqmuntal <quimmuntal@gmail.com>
Fri, 25 Aug 2023 12:29:13 +0000 (14:29 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Mon, 28 Aug 2023 14:31:20 +0000 (14:31 +0000)
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>
src/make.bat

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