dashboard, cmd/coordinator: add -racecompile builder

Change-Id: Idc5756f82081de6b5dfd17036f2bfc9cf11c5659
Reviewed-on: https://go-review.googlesource.com/41414
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
diff --git a/cmd/coordinator/coordinator.go b/cmd/coordinator/coordinator.go
index acd2b47..8e5fb0b 100644
--- a/cmd/coordinator/coordinator.go
+++ b/cmd/coordinator/coordinator.go
@@ -1795,13 +1795,13 @@
 	makeSpan.done(nil)
 
 	// Need to run "go install -race std" before the snapshot + tests.
-	if st.conf.IsRace() {
+	if pkgs := st.conf.GoInstallRacePackages(); len(pkgs) > 0 {
 		sp := st.createSpan("install_race_std")
 		remoteErr, err = bc.Exec(path.Join(goroot, "bin/go"), buildlet.ExecOpts{
 			Output:   w,
 			ExtraEnv: append(st.conf.Env(), "GOBIN="),
 			Debug:    true,
-			Args:     []string{"install", "-race", "std"},
+			Args:     append([]string{"install", "-race"}, pkgs...),
 		})
 		if err != nil {
 			sp.done(err)
diff --git a/dashboard/builders.go b/dashboard/builders.go
index 105e136..fe6817c 100644
--- a/dashboard/builders.go
+++ b/dashboard/builders.go
@@ -460,6 +460,12 @@
 	// BuildConfig.SplitMakeRun returns true.
 	StopAfterMake bool
 
+	// InstallRacePackages controls which packages to "go install
+	// -race <pkgs>" after running make.bash (or equivalent).  If
+	// the builder ends in "-race", the default if non-nil is just
+	// "std".
+	InstallRacePackages []string
+
 	// numTestHelpers is the number of _additional_ buildlets
 	// past the first one to help out with sharded tests.
 	// For trybots, the numTryHelpers value is used, unless it's
@@ -530,6 +536,16 @@
 	return strings.HasSuffix(c.Name, "-race")
 }
 
+func (c *BuildConfig) GoInstallRacePackages() []string {
+	if c.InstallRacePackages != nil {
+		return append([]string(nil), c.InstallRacePackages...)
+	}
+	if c.IsRace() {
+		return []string{"std"}
+	}
+	return nil
+}
+
 // AllScript returns the relative path to the operating system's script to
 // do the build and run its standard set of tests.
 // Example values are "src/all.bash", "src/all.bat", "src/all.rc".
@@ -837,6 +853,13 @@
 		env:         []string{"GO_GCFLAGS=-d=ssa/check/on,dclstack"},
 	})
 	addBuilder(BuildConfig{
+		Name:                "linux-amd64-racecompile",
+		HostType:            "host-linux-kubestd",
+		CompileOnly:         true,
+		InstallRacePackages: []string{"cmd/compile"},
+		Notes:               "race-enabled cmd/compile",
+	})
+	addBuilder(BuildConfig{
 		Name:              "linux-amd64-race",
 		HostType:          "host-linux-kubestd",
 		TryBot:            true,