New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/dist: no way to disable buildvcs stamping during bootstrap #54852
Comments
This was reported by a user here, but I wanted to reproduce it outside of our package manager before I reported it to you. |
Note that we currently have 1.17 as our minimum bootstrap version. If you only want to support 1.18+ as bootstrap you could add |
Hmm. As of CL 398855 (backported to Go 1.18.2), the default behavior is to stamp VCS information when the VCS tool is present, and to omit it when the VCS tool is not found. Moreover, we intentionally avoid stamping VCS information for programs found in the standard library: So one option might be to change that condition from |
That said, looking at https://bugs.gentoo.org/836261 I don't understand why this would affect Go bootstrapping. The issue reported there is that the VCS stamping is somehow coming up with So I guess a contributing factor is that |
I believe Gentoo builds using a source tarball rather than a vcs checkout |
That's correct, we build using a source tarball. |
I confirmed that the following sequence produces a successful build, so this is definitely caused by building from a release tarball instead of the git repository.
|
Change https://go.dev/cl/432435 mentions this issue: |
Hi @williamh @bcmills - has there been a regression with this in Go 1.20? In Buildroot we have a build failure due to not having the .git directory in the Go sources: https://gitlab.com/buildroot.org/buildroot/-/jobs/4725186525
It seems that -buildvcs=false is not set in the "go install" command regardless of isGitRepo(): https://github.com/golang/go/blob/go1.20.6/src/cmd/dist/buildtool.go#L205 Applying two patches fixes the issue within Buildroot:
This worked fine with go1.19.x but regressed with go1.20.x. |
When compiling without a Git repository, "go install" returns an error: error obtaining VCS status: exit status 128 Use -buildvcs=false to disable VCS stamping. Set -buildvcs=false in go install when isGitDir() returns false. Fixes: golang#61620 Related: golang#54852 Signed-off-by: Christian Stewart <christian@aperture.us>
Add an environment variable to bypass the isGitRepo() check and force it to return false, thereby also setting -buildvcs=false during "go install." This is useful in situations where the .git directory may be present but we still want to force cmd/dist to ignore it. Fixes: golang#61620 Related: golang#54852 Signed-off-by: Christian Stewart <christian@aperture.us>
When compiling without a Git repository, "go install" returns an error: error obtaining VCS status: exit status 128 Use -buildvcs=false to disable VCS stamping. Set -buildvcs=false in go install when isGitDir() returns false. Fixes: golang#61620 Related: golang#54852
Add an environment variable to bypass the isGitRepo() check and force it to return false, thereby also setting -buildvcs=false during "go install." This is useful in situations where the .git directory may be present but we still want to force cmd/dist to ignore it. Fixes: golang#61620 Related: golang#54852
When compiling without a Git repository, "go install" returns an error: error obtaining VCS status: exit status 128 Use -buildvcs=false to disable VCS stamping. Set -buildvcs=false in go install when isGitDir() returns false. Fixes: golang#61620 Related: golang#54852
Add an environment variable to bypass the isGitRepo() check and force it to return false, thereby also setting -buildvcs=false during "go install." This is useful in situations where the .git directory may be present but we still want to force cmd/dist to ignore it. Fixes: golang#61620 Related: golang#54852
When compiling without a Git repository, "go install" returns an error: error obtaining VCS status: exit status 128 Use -buildvcs=false to disable VCS stamping. Set -buildvcs=false in go install when isGitDir() returns false. Fixes: golang#61620 Related: golang#54852
Add an environment variable to bypass the isGitRepo() check and force it to return false, thereby also setting -buildvcs=false during "go install." This is useful in situations where the .git directory may be present but we still want to force cmd/dist to ignore it. Fixes: golang#61620 Related: golang#54852
Change https://go.dev/cl/513835 mentions this issue: |
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: golang#54852 Fixes: golang#61620
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: golang#54852 Fixes: golang#61620
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. 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: golang#54852 Fixes: golang#61620
Hi,
I am the packager for Go on Gentoo linux.
We have an on-going issue with the VCS stamping which has appeared in another way.
Since go 1.17 and older are not in our tree any longer, we are able to add "-buildvcs=false" to our default build flags for go-based packages to prevent vcs stamping from breaking our package builds.
However, if go is being bootstrapped and the bootstrap binaries are newer than version 1.18, it is possible for vcs stamping to crash the build as shown below.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
$ cd
$ mkdir build
$ cd build
$ git init
$ chmod 000 .git
$ tar -xf /path/to/go1.18.5.tar.gz
$ cd go/src
$ export GOROOT_BOOTSTRAP=/usr/lib/go
$ ./all.bash
What did you expect to see?
Successful build.
What did you see instead?
Building Go cmd/dist using /usr/lib/go. (go1.18.5 linux/amd64)
Building Go toolchain1 using /usr/lib/go.
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
go tool dist: FAILED: /usr/lib/go/bin/go install -gcflags=-l -tags=math_big_pure_go compiler_bootstrap bootstrap/cmd/...: exit status 1
The text was updated successfully, but these errors were encountered: