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: list with -export flag does not show the the correct BuildID when the -cover flag is present #60755

Closed
cixel opened this issue Jun 12, 2023 · 4 comments
Assignees
Labels
GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@cixel
Copy link
Contributor

cixel commented Jun 12, 2023

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

$ go version
go version go1.20.4 darwin/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="~/gobin"
GOCACHE="~/Library/Caches/go-build"
GOENV="~/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="~/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="~/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xs/zkk2d6w14450r_zrhkxycpnm0000gp/T/go-build1879129486=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.20.4 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.20.4
uname -v: Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000
ProductName:		macOS
ProductVersion:		13.3.1
BuildVersion:		22E261
lldb --version: lldb-1403.0.17.64
Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)

What did you do?

go list -export -f {{.BuildID}} cmd/nm        # _tyi3hDRTM966tQL-lDR/LVpI-0_na9f-uQ5ySyRo
go list -export -f {{.BuildID}} -cover cmd/nm # nx0pe6n6Sn3FVP9XHsWh/LVpI-0_na9f-uQ5ySyRo

go build -o nm cmd/nm
go tool buildid nm       # actionID(binary)/_tyi3hDRTM966tQL-lDR/LVpI-0_na9f-uQ5ySyRo/contentID(binary)
go build -o nm-cover -cover cmd/nm
go tool buildid nm-cover # actionID(binary)/bZSqHNhfxHe4or9gncU5/0V_2bXo19x4hFJWTxIcL/contentID(binary)

What did you expect to see?

go tool buildid should show the same buildID as go list -export -f {{.BuildID}} when the -cover flag is present (ignoring binary action/content IDs).

What did you see instead?

go tool buildid shows a different action and content ID than go list -export -f {{.BuildID}} when the -cover flag is provided.

The basic issue is that go list does not seem to work for describing the output of a build with-cover (at least not the way it works without the -cover flag).

On further inspection, the cover tool doesn't seem to run for go list at all, so coverage instrumentation isn't happening, hence the lack of change in contentID.

@prattmic prattmic added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Jun 13, 2023
@prattmic
Copy link
Member

cc @bcmills @matloob @thanm

@prattmic prattmic added this to the Backlog milestone Jun 13, 2023
@thanm thanm self-assigned this Jun 13, 2023
@thanm
Copy link
Contributor

thanm commented Jun 13, 2023

Thanks for the report. I'll take a look.

@gopherbot
Copy link

Change https://go.dev/cl/502877 mentions this issue: cmd/go: fix build config for 'go list -cover'

@gopherbot
Copy link

Change https://go.dev/cl/503315 mentions this issue: cmd/go/internal/script: augment "env" command to capture stdout

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 20, 2023
@dmitshur dmitshur modified the milestones: Backlog, Go1.21 Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants