// 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,
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,
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, "")
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