go
go copied to clipboard
cmd/dist: set buildvcs=false when building go-bootstrap
When building go-bootstrap as part of the make.bash process, the cmd/dist invokes the bootstrap Go compiler to build the go_bootstrap tool:
${GOROOT_BOOTSTRAP}/bin/go install -tags=math_big_pure_go compiler_bootstrap purego bootstrap/cmd/...
If there is an invalid .git directory in a parent of ${GOROOT_BOOTSTRAP}, make.bash will fail. Reproduction of the issue:
mkdir go-issue-61620 cd ./go-issue-61620 wget https://go.dev/dl/go1.19.11.src.tar.gz mkdir go-bootstrap tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1 cd ./go-bootstrap/src/ bash make.bash cd ../../ wget https://go.dev/dl/go1.20.6.src.tar.gz mkdir go tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1 printf "gitdir: ../../does/not/exist/.git" > ./.git cd ./go/src/ GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash
The build fails with the following error:
Building Go toolchain1 using [snip]/go-1.19.10.
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
go tool dist: FAILED: [snip]/go-1.19.10/bin/go install -tags=math_big_pure_go
compiler_bootstrap purego bootstrap/cmd/...: exit status 1
This change unconditionally sets -buildvcs=false when compiling go-bootstrap. We don't need the revision information in those binaries anyway. Setting this flag was previously not done as we were unsure if the go-bootstrap compiler would be new enough to support the buildvcs build flag. However, since Go 1.20.x, Go 1.19.x is the minimum version for go-bootstrap, and supports -buildvcs=false. We can now set -buildvcs=false without worrying about compatibility.
Related: #54852 Fixes: #61620