Skip to content

Commit

Permalink
go/packages: pass -pgo=off on go1.21 and later
Browse files Browse the repository at this point in the history
PGO variants can be costly to compute, and can result in unnecessary
packages for the caller. They are also unlikely to be useful.

Disable these variants by default, setting -pgo=off on go1.21 and later.
If someone wants to see PGO variants we can have a NeedPGO flag, but
that should be a separate proposal.

Fixes golang/go#60456

Change-Id: Ifc706fe7503f841cbe4fa4326b08717a70b4368b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/498557
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
  • Loading branch information
findleyr committed May 26, 2023
1 parent 5f74ec7 commit f3faea1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions go/packages/golist.go
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,15 @@ func golistargs(cfg *Config, words []string, goVersion int) []string {
// probably because you'd just get the TestMain.
fmt.Sprintf("-find=%t", !cfg.Tests && cfg.Mode&findFlags == 0 && !usesExportData(cfg)),
}

// golang/go#60456: with go1.21 and later, go list serves pgo variants, which
// can be costly to compute and may result in redundant processing for the
// caller. Disable these variants. If someone wants to add e.g. a NeedPGO
// mode flag, that should be a separate proposal.
if goVersion >= 21 {
fullargs = append(fullargs, "-pgo=off")
}

fullargs = append(fullargs, cfg.BuildFlags...)
fullargs = append(fullargs, "--")
fullargs = append(fullargs, words...)
Expand Down

0 comments on commit f3faea1

Please sign in to comment.