|
| 1 | +From 6b05378097c6a386ed9912d2471976dc39504e86 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Christian Stewart < [email protected]> |
| 3 | +Date: Thu, 27 Jul 2023 21:28:47 -0700 |
| 4 | +Subject: [PATCH] cmd/dist: set buildvcs=false when building go-bootstrap |
| 5 | + |
| 6 | +When building go-bootstrap as part of the make.bash process, the cmd/dist |
| 7 | +invokes the bootstrap Go compiler to build the go_bootstrap tool: |
| 8 | + |
| 9 | +${GOROOT_BOOTSTRAP}/bin/go install -tags=math_big_pure_go compiler_bootstrap purego bootstrap/cmd/... |
| 10 | + |
| 11 | +If there is an invalid .git directory in a parent of ${GOROOT_BOOTSTRAP}, |
| 12 | +make.bash will fail. Reproduction of the issue: |
| 13 | + |
| 14 | + mkdir go-issue-61620 |
| 15 | + cd ./go-issue-61620 |
| 16 | + wget https://go.dev/dl/go1.19.11.src.tar.gz |
| 17 | + mkdir go-bootstrap |
| 18 | + tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1 |
| 19 | + cd ./go-bootstrap/src/ |
| 20 | + bash make.bash |
| 21 | + cd ../../ |
| 22 | + wget https://go.dev/dl/go1.20.6.src.tar.gz |
| 23 | + mkdir go |
| 24 | + tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1 |
| 25 | + printf "gitdir: ../../does/not/exist/.git" > ./.git |
| 26 | + cd ./go/src/ |
| 27 | + GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash |
| 28 | + |
| 29 | +The build fails with the following error: |
| 30 | + |
| 31 | + Building Go toolchain1 using [snip]/go-1.19.10. |
| 32 | + error obtaining VCS status: exit status 128 |
| 33 | + Use -buildvcs=false to disable VCS stamping. |
| 34 | + go tool dist: FAILED: [snip]/go-1.19.10/bin/go install -tags=math_big_pure_go \ |
| 35 | + compiler_bootstrap purego bootstrap/cmd/...: exit status 1 |
| 36 | + |
| 37 | +This change unconditionally sets -buildvcs=false when compiling go-bootstrap. We |
| 38 | +don't need the revision information in those binaries anyway. Setting this flag |
| 39 | +was previously not done as we were unsure if the go-bootstrap compiler would be |
| 40 | +new enough to support the buildvcs build flag. Since Go 1.20.x, Go 1.19.x is the |
| 41 | +minimum version for go-bootstrap, and supports -buildvcs=false. We can now set |
| 42 | +-buildvcs=false without worrying about compatibility. |
| 43 | + |
| 44 | +Related: https://github.com/golang/go/issues/54852 |
| 45 | +Fixes: https://github.com/golang/go/issues/61620 |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +Upstream PR: https://github.com/golang/go/pull/61621 |
| 50 | + |
| 51 | +Signed-off-by: Christian Stewart < [email protected]> |
| 52 | + |
| 53 | +--- |
| 54 | + src/cmd/dist/buildtool.go | 3 +++ |
| 55 | + 1 file changed, 3 insertions(+) |
| 56 | + |
| 57 | +diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go |
| 58 | +index a528d7aa76..3b411d6ebb 100644 |
| 59 | +--- a/src/cmd/dist/buildtool.go |
| 60 | ++++ b/src/cmd/dist/buildtool.go |
| 61 | +@@ -221,6 +221,9 @@ func bootstrapBuildTools() { |
| 62 | + cmd := []string{ |
| 63 | + pathf("%s/bin/go", goroot_bootstrap), |
| 64 | + "install", |
| 65 | ++ // Fixes cases where an invalid .git is present in a parent of GOROOT_BOOTSTRAP. |
| 66 | ++ // See: https://github.com/golang/go/issues/61620 |
| 67 | ++ "-buildvcs=false", |
| 68 | + "-tags=math_big_pure_go compiler_bootstrap purego", |
| 69 | + } |
| 70 | + if vflag > 0 { |
| 71 | +-- |
| 72 | +2.41.0 |
| 73 | + |
0 commit comments