Skip to content
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

runtime/debug: vcs.modified populated in ReadBuildInfo for go install but not go build #51637

Closed
carbocation opened this issue Mar 12, 2022 · 2 comments

Comments

@carbocation
Copy link

carbocation commented Mar 12, 2022

What version of Go are you using (go version)?

$ go version
go version go1.18beta2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/james/Library/Caches/go-build"
GOENV="/Users/james/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/james/go/pkg/mod"
GOOS="darwin"
GOPATH="/Users/james/go"
GOPROXY="direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18beta2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/james/projects/debug-module-version-demo/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/g1/r_29t6g17l926yzy2610sy3m0000gn/T/go-build2749357119=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Produce a binary with go build and with go install:

  1. Fetch the demo repo from @mark-rushakoff : git clone https://github.com/mark-rushakoff/debug-module-version-demo.git
  2. go install
  3. go build -o demo.osx *.go

Compare the attached build info:

Output from go build
$ go version -m demo.osx                                     
demo.osx: go1.18beta2
	path	command-line-arguments
	dep	golang.org/x/text	v0.0.0-20170915032832-14c0d48ead0c	h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=
	dep	rsc.io/quote	v1.5.2	h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y=
	dep	rsc.io/sampler	v1.3.0	h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
	build	-compiler=gc
	build	CGO_ENABLED=1
	build	CGO_CFLAGS=
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS=
	build	CGO_LDFLAGS=
	build	GOARCH=amd64
	build	GOOS=darwin
	build	GOAMD64=v1
Output from go install
$ go version -m /Users/james/go/bin/debug-module-version-demo
/Users/james/go/bin/debug-module-version-demo: go1.18beta2
	path	github.com/mark-rushakoff/debug-module-version-demo
	mod	github.com/mark-rushakoff/debug-module-version-demo	(devel)	
	dep	golang.org/x/text	v0.0.0-20170915032832-14c0d48ead0c	h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=
	dep	rsc.io/quote	v1.5.2	h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y=
	dep	rsc.io/sampler	v1.3.0	h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
	build	-compiler=gc
	build	CGO_ENABLED=1
	build	CGO_CFLAGS=
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS=
	build	CGO_LDFLAGS=
	build	GOARCH=amd64
	build	GOOS=darwin
	build	GOAMD64=v1
	build	vcs=git
	build	vcs.revision=f3f34e10b35e88a6f6998d8c1938a5998c33cb64
	build	vcs.time=2018-12-13T20:11:42Z
	build	vcs.modified=true

What did you expect to see?

I expected to see vcs.revision/vcs.modified/etc populated in the runtime/debug.ReadBuildInfo() of the binaries produced by go build -o demo.osx *.go and go install.

What did you see instead?

I saw vcs.revision/vcs.modified/etc populated only in the runtime/debug.ReadBuildInfo() of the binary produced by go install, but not the binary produced by go build -o demo.osx *.go.

@carbocation
Copy link
Author

With additional testing, non-population of vcs.revision/etc in runtime/debug.ReadBuildInfo() seems to only affect go build when the specific go files (in this case, *.go) are specified. When they are not specified, the tags are populated as expected.

E.g:

# note *.go not specified
$ go build -o demo.osx
$ go version -m demo.osx                        
demo.osx: go1.18beta2
	path	github.com/mark-rushakoff/debug-module-version-demo
	mod	github.com/mark-rushakoff/debug-module-version-demo	(devel)	
	dep	golang.org/x/text	v0.0.0-20170915032832-14c0d48ead0c	h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=
	dep	rsc.io/quote	v1.5.2	h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y=
	dep	rsc.io/sampler	v1.3.0	h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
	build	-compiler=gc
	build	CGO_ENABLED=1
	build	CGO_CFLAGS=
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS=
	build	CGO_LDFLAGS=
	build	GOARCH=amd64
	build	GOOS=darwin
	build	GOAMD64=v1
	build	vcs=git
	build	vcs.revision=f3f34e10b35e88a6f6998d8c1938a5998c33cb64
	build	vcs.time=2018-12-13T20:11:42Z
	build	vcs.modified=true

So the bug I am reporting may be intended behavior when files are specified, whose description I have just missed in the documentation.

@carbocation carbocation changed the title runtime/debug: vcs.modified populated for go install but not go build runtime/debug: vcs.modified populated in ReadBuildInfo for go install but not go build Mar 12, 2022
@seankhliao
Copy link
Member

Duplicate of #51279

@seankhliao seankhliao marked this as a duplicate of #51279 Mar 12, 2022
@golang golang locked and limited conversation to collaborators Mar 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants