Skip to content

cmd/go: go list prints unexpected compiler output for non-stale targets #56375

@bcmills

Description

@bcmills

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

~/x/tools$ gotip version
go version devel go1.20-867babe1b1 Fri Oct 21 16:23:01 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
~/x/tools$ gotip env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/bcmills/.cache/go-build"
GOENV="/usr/local/google/home/bcmills/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/usr/local/google/home/bcmills/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/usr/local/google/home/bcmills"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/google/home/bcmills/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/google/home/bcmills/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.20-867babe1b1 Fri Oct 21 16:23:01 2022 +0000"
GCCGO="/usr/local/google/home/bcmills/bin/gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/usr/local/google/home/bcmills/x/tools/go.mod"
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3491113060=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Use go install to build a binary in a way that produces output to stdout or stderr, then go list -json=Stale to verify that that binary is not, in fact, stale.

What did you expect to see?

Compiler output from go install and go build, and no compiler output from go list (unless, perhaps, the -export or -compiled flag is set).

What did you see instead?

The go list command, with neither -export nor -compiled repeats all of the stdout / stderr output from the compiler for the go install command, even though it should have no possibility of actually running the compiler!

~/x/tools$ gotip install -gcflags=-m ./cmd/goyacc
# golang.org/x/tools/cmd/goyacc
cmd/goyacc/yacc.go:138:6: can inline ASSOC
cmd/goyacc/yacc.go:140:6: can inline PLEVEL
cmd/goyacc/yacc.go:142:6: can inline TYPE
cmd/goyacc/yacc.go:145:6: can inline SETASC
cmd/goyacc/yacc.go:147:6: can inline SETPLEV
cmd/goyacc/yacc.go:149:6: can inline SETTYPE
cmd/goyacc/yacc.go:166:16: inlining call to flag.StringVar
cmd/goyacc/yacc.go:167:16: inlining call to flag.StringVar
cmd/goyacc/yacc.go:168:16: inlining call to flag.StringVar
cmd/goyacc/yacc.go:169:14: inlining call to flag.BoolVar
…

~/x/tools$ gotip list -gcflags=-m -json=Stale ./cmd/goyacc
# golang.org/x/tools/cmd/goyacc
cmd/goyacc/yacc.go:138:6: can inline ASSOC
cmd/goyacc/yacc.go:140:6: can inline PLEVEL
cmd/goyacc/yacc.go:142:6: can inline TYPE
cmd/goyacc/yacc.go:145:6: can inline SETASC
cmd/goyacc/yacc.go:147:6: can inline SETPLEV
cmd/goyacc/yacc.go:149:6: can inline SETTYPE
cmd/goyacc/yacc.go:166:16: inlining call to flag.StringVar
cmd/goyacc/yacc.go:167:16: inlining call to flag.StringVar
cmd/goyacc/yacc.go:168:16: inlining call to flag.StringVar
cmd/goyacc/yacc.go:169:14: inlining call to flag.BoolVar
…
{}

I noticed this existing bug while reviewing CL 444619 (CC @matloob)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeGoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions