mirror of https://github.com/golang/go.git
cmd/go: enable -pgo=auto by default
Updates #58099. Updates #55022. Change-Id: I32eacdf9f008d16566e0b30230ecc25d110a9811 Reviewed-on: https://go-review.googlesource.com/c/go/+/474236 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
3d28e0ebb9
commit
0aa14fca8c
|
|
@ -206,7 +206,7 @@
|
|||
// build, the go command selects a file named "default.pgo" in the package's
|
||||
// directory if that file exists, and applies it to the (transitive)
|
||||
// dependencies of the main package (other packages are not affected).
|
||||
// Special name "off" turns off PGO.
|
||||
// Special name "off" turns off PGO. The default is "auto".
|
||||
// -pkgdir dir
|
||||
// install and load all packages from dir instead of the usual locations.
|
||||
// For example, when building with a non-standard configuration,
|
||||
|
|
|
|||
|
|
@ -2939,8 +2939,6 @@ func PackagesAndErrors(ctx context.Context, opts PackageOpts, patterns []string)
|
|||
// In -pgo=auto mode, it finds the default PGO profile.
|
||||
func setPGOProfilePath(pkgs []*Package) {
|
||||
switch cfg.BuildPGO {
|
||||
case "":
|
||||
fallthrough // default to "off"
|
||||
case "off":
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ and test commands:
|
|||
build, the go command selects a file named "default.pgo" in the package's
|
||||
directory if that file exists, and applies it to the (transitive)
|
||||
dependencies of the main package (other packages are not affected).
|
||||
Special name "off" turns off PGO.
|
||||
Special name "off" turns off PGO. The default is "auto".
|
||||
-pkgdir dir
|
||||
install and load all packages from dir instead of the usual locations.
|
||||
For example, when building with a non-standard configuration,
|
||||
|
|
@ -318,7 +318,7 @@ func AddBuildFlags(cmd *base.Command, mask BuildFlagMask) {
|
|||
cmd.Flag.StringVar(&cfg.BuildContext.InstallSuffix, "installsuffix", "", "")
|
||||
cmd.Flag.Var(&load.BuildLdflags, "ldflags", "")
|
||||
cmd.Flag.BoolVar(&cfg.BuildLinkshared, "linkshared", false, "")
|
||||
cmd.Flag.StringVar(&cfg.BuildPGO, "pgo", "", "")
|
||||
cmd.Flag.StringVar(&cfg.BuildPGO, "pgo", "auto", "")
|
||||
cmd.Flag.StringVar(&cfg.BuildPkgdir, "pkgdir", "", "")
|
||||
cmd.Flag.BoolVar(&cfg.BuildRace, "race", false, "")
|
||||
cmd.Flag.BoolVar(&cfg.BuildMSan, "msan", false, "")
|
||||
|
|
|
|||
|
|
@ -34,6 +34,21 @@ go list -test -pgo=auto ./a/a1
|
|||
|
||||
go list -deps -pgo=auto ./a/a1
|
||||
|
||||
# -pgo=auto is the default. Commands without explicit -pgo=auto
|
||||
# should work as -pgo=auto.
|
||||
go build -n ./a/a1
|
||||
stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
|
||||
stderr 'compile.*-p test/dep.*-pgoprofile=.*default\.pgo'
|
||||
|
||||
go build -n -o nopgo.exe ./nopgo
|
||||
stderr 'compile.*nopgo.go'
|
||||
! stderr '-pgoprofile'
|
||||
|
||||
# -pgo=off should turn off PGO.
|
||||
go build -n -pgo=off ./a/a1
|
||||
stderr 'compile.*a1.go'
|
||||
! stderr '-pgoprofile'
|
||||
|
||||
-- go.mod --
|
||||
module test
|
||||
go 1.20
|
||||
|
|
|
|||
Loading…
Reference in New Issue