2
1

0001-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch 2.7 KB

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