-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
GoCommandcmd/gocmd/goNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ToolSpeedcompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.21.0 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
$ go env GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/home/lizf/.cache/go-build' GOENV='/home/lizf/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/home/lizf/hny/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/lizf/hny/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/snap/go/current' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/snap/go/current/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.21.0' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='gcc' CXX='g++' 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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build522135516=/tmp/go-build -gno-record-gcc-switches'
What did you do?
Run go test ./... where one directory (which has no tests in it) contains a default.pgo file, but a subdirectory contains tests. eg:
cmd/bar/main.go
cmd/foo/default.pgo
cmd/foo/main.go
cmd/foo/internal/foo_test.go
shared_libs/some_libraries.go
...
What did you expect to see?
Build should be fast because all intermediate build artifacts are reused since no *_test.go files are directly located in a directory containing default.pgo
$ go test ./cmd/foo/...
(pause while shared libs are compiled)
? cmd/bar [no test files]
(no pause)
? cmd/foo [no test files]
(no pause)
ok cmd/foo/internal 0.013s
What did you see instead?
A custom build was done for cmd/app with default.pgo in use (even if no tests were found for that directory), forcing recompilation of everything to ensure complete optimization.
$ go test ./cmd/...
(pause while shared libs are compiled)
? cmd/bar [no test files]
(long pause while shared libs are recompiled with pgo even if cmd/foo has no tests)
? cmd/foo [no test files]
(no pause)
ok cmd/foo/internal 0.013s
However, running with pgo explicitly turned off does proceed quickly:
$ go test -pgo=off ./cmd/...
(pause while shared libs are compiled)
? cmd/bar [no test files]
(no pause)
? cmd/foo [no test files]
(no pause)
ok cmd/foo/internal 0.013s
Metadata
Metadata
Assignees
Labels
GoCommandcmd/gocmd/goNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ToolSpeedcompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
Status
Todo