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

cmd/go: debug.BuildInfo doesn't include VCS info when cross-compiling [1.18rc1] #51264

Closed
spyder-jeff opened this issue Feb 18, 2022 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@spyder-jeff
Copy link

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

$ go version
go version go1.18rc1 linux/arm64

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="arm64"
GOBIN=""
GOCACHE="/home/vagrant/.cache/go-build"
GOENV="/home/vagrant/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/vagrant/go/pkg/mod"
GONOPROXY="*"
GONOSUMDB="*"
GOOS="linux"
GOPATH="/home/vagrant/go"
GOPRIVATE="*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go1.18rc1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go1.18rc1/pkg/tool/linux_arm64"
GOVCS=""
GOVERSION="go1.18rc1"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/vagrant/spyderbat/aws_terraform/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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3002789791=/tmp/go-build -gno-record-gcc-switches"

What did you do?

building on arm64 for amd64:

	vcsrevision := "unknown"
	vcsdirty := ""
	vcstime := "unknown"

	if info, ok := debug.ReadBuildInfo(); ok {
		for _, v := range info.Settings {
			switch v.Key {
			case "vcs.revision":
				vcsrevision = v.Value
			case "vcs.modified":
				if v.Value == "true" {
					vcsdirty = " (dirty)"
				}
			case "vcs.time":
				vcstime = v.Value
			}
		}
	}

What did you expect to see?

vcs info, when cross-compiling to AMD64

What did you see instead?

"unknown"

(works when building for native arm64)

@spyder-jeff spyder-jeff changed the title runtime/debug: debug.BuildInfo doesn't include VCS info when cross-compiling runtime/debug: debug.BuildInfo doesn't include VCS info when cross-compiling [1.18rc1] Feb 18, 2022
@dmitshur
Copy link
Contributor

CC @bcmills, @rsc.

@dmitshur dmitshur added this to the Go1.18 milestone Feb 18, 2022
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 18, 2022
@bcmills bcmills changed the title runtime/debug: debug.BuildInfo doesn't include VCS info when cross-compiling [1.18rc1] cmd/go: debug.BuildInfo doesn't include VCS info when cross-compiling [1.18rc1] Feb 22, 2022
@bcmills
Copy link
Contributor

bcmills commented Feb 22, 2022

I don't see anything in the -buildvcs implementation that would vary based on whether you are cross-compiling.
What were the exact commands that you ran for the two builds?

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 22, 2022
@spyder-jeff
Copy link
Author

I'm sorry, I'm dumb. It wasn't cross-compiling that was doing it, it was an artifact of the way the Makefile was written. It turns out that if you do go build foo.go instead of just go build, you don't get vcs info. Maybe that's expected? I hope not.

Sample project: https://github.com/jnoxon/vcspoc

@seankhliao
Copy link
Member

Duplicate of #51279

@seankhliao seankhliao marked this as a duplicate of #51279 Feb 23, 2022
@golang golang locked and limited conversation to collaborators Feb 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants