]> Cypherpunks repositories - gostls13.git/commit
cmd/go: support multiple main packages with -pgo=auto
authorCherry Mui <cherryyz@google.com>
Tue, 28 Feb 2023 23:43:14 +0000 (18:43 -0500)
committerCherry Mui <cherryyz@google.com>
Mon, 6 Mar 2023 19:22:18 +0000 (19:22 +0000)
commit74502e9bb4d732239fa684969ddb22e7b7345f3a
treeffe22011a8c9340cf35b446de5954219d3cd72c7
parent5987f3c2715d93cb52f05dcb1c29825507e1d625
cmd/go: support multiple main packages with -pgo=auto

In -pgo=auto mode, the go command finds a profile named
default.pgo in the main package's directly, and if found, use it
as the profile for the build. Currently we only support a single
main package when -pgo=auto is used.

When multiple main packages are included in a build, they may
have different default profiles (or some have profiles whereas
some don't), so a common dependent package would need to be built
multiple times, with different profiles (or lack of). This CL
handles this. To do so, we need to split (unshare) the dependency
graph so they can attach different profiles.

Fixes #58099.

Change-Id: I1ad21361967aafbf5089d8d5e89229f95fe31276
Reviewed-on: https://go-review.googlesource.com/c/go/+/472358
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/cmd/go/alldocs.go
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/work/build.go
src/cmd/go/testdata/script/build_pgo_auto.txt
src/cmd/go/testdata/script/build_pgo_auto_multi.txt [new file with mode: 0644]