sweet: force -pgo=off for non-PGO builds
As of CL 497455, cmd/compile has a default.pgo that is applied
automatically. This means that `sweet run -pgo -run go-build` is
actually going to compare default.pgo vs a new profile, rather than no
pgo vs a new profile, which is what folks will expect.
Thus when not in a PGO build, force PGO off.
Change-Id: Ica1da2d2d8a4348cc3b8fa2e7b5bdbe9ac00e2ee
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/498276
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
diff --git a/sweet/cmd/sweet/benchmark.go b/sweet/cmd/sweet/benchmark.go
index 3c33803..b3a1d6e 100644
--- a/sweet/cmd/sweet/benchmark.go
+++ b/sweet/cmd/sweet/benchmark.go
@@ -224,15 +224,18 @@
}
}
- // Add PGO if profile specified for this benchmark.
- if pgo, ok := cfg.PGOFiles[b.name]; ok {
- goflags, ok := cfg.BuildEnv.Lookup("GOFLAGS")
- if ok {
- goflags += " "
- }
- goflags += fmt.Sprintf("-pgo=%s", pgo)
- cfg.BuildEnv.Env = cfg.BuildEnv.MustSet("GOFLAGS=" + goflags)
+ // Add PGO if profile specified for this benchmark, otherwise
+ // explicitly disable it to avoid default.pgo files.
+ pgo, ok := cfg.PGOFiles[b.name]
+ if !ok {
+ pgo = "off"
}
+ goflags, ok := cfg.BuildEnv.Lookup("GOFLAGS")
+ if ok {
+ goflags += " "
+ }
+ goflags += fmt.Sprintf("-pgo=%s", pgo)
+ cfg.BuildEnv.Env = cfg.BuildEnv.MustSet("GOFLAGS=" + goflags)
// Build the benchmark (application and any other necessary components).
bcfg := common.BuildConfig{