sweet: rebuild cmd/compile and cmd/link for go-build benchmark

go-build is a subtly strange benchmark. For every other benchmark, sweet
builds the benchmarked program in set up, using Config.BuildEnv.
go-build does not do that because the benchmarked programs (cmd/compile,
cmd/link, and (to a lesser degree) cmd/go) are conveniently prebuilt in
GOROOT.

But this breaks the intuition that BuildEnv can control build flags for
the benchmarked program, particularly for sweet run -pgo, where sweet
itself expects a PGO flag in BuildEnv to impact the benchmarked program.

Adjust go-build to follow these standards by copying GOROOT for each
config and running `go install cmd/compile cmd/link` in the copied
GOROOT, allowing BuildEnv to take effect.

This fixes the general case for PGO, though it could use more work as
really cmd/compile and cmd/link should receive _different_ PGO profiles.

We also run the dummy build with the ExecEnv (matching how the actual
benchmark will run) to avoid passing -pgo to those builds.

For golang/go#55022.

Change-Id: I36e4486c79ee4200c2e10ccba913d559187bdad2
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/444895
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
1 file changed