cmd/bent: move toolchain key print to lower layer

CL 462956 added logging of the toolchain key to properly annotate build
/ after-build benchmarks. This worked fine for the perf dashboard, but
results also go to a file, which this logging did not do. Additionally,
it logged even in non-verbose mode, when benchmark results are not.

Move this logging down near the benchmarks themselves to fix these
inconsistencies.

For golang/go#57770.

Change-Id: I6502092bd93a2dd6932018989c69fba5b51adff8
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/463195
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
diff --git a/cmd/bent/bent.go b/cmd/bent/bent.go
index 67e3529..fb411c1 100644
--- a/cmd/bent/bent.go
+++ b/cmd/bent/bent.go
@@ -710,7 +710,6 @@
 						if config.Disabled {
 							continue
 						}
-						config.say("toolchain: " + config.Name + "\n")
 						s := todo.Configurations[ci].compileOne(&todo.Benchmarks[bi], dirs.wd, yyy)
 						if s != "" {
 							getAndBuildFailures = append(getAndBuildFailures, s)
@@ -737,7 +736,6 @@
 						if config.Disabled {
 							continue
 						}
-						config.say("toolchain: " + config.Name + "\n")
 						s := config.compileOne(&todo.Benchmarks[bi], dirs.wd, yyy)
 						if s != "" {
 							getAndBuildFailures = append(getAndBuildFailures, s)
@@ -763,7 +761,6 @@
 					if bench.Disabled || config.Disabled {
 						continue
 					}
-					config.say("toolchain: " + config.Name + "\n")
 					s := config.compileOne(bench, dirs.wd, yyy)
 					if s != "" {
 						getAndBuildFailures = append(getAndBuildFailures, s)
@@ -790,7 +787,6 @@
 				if bench.Disabled || config.Disabled {
 					continue
 				}
-				config.say("toolchain: " + config.Name + "\n")
 				s := config.compileOne(bench, dirs.wd, p.k)
 				if s != "" {
 					getAndBuildFailures = append(getAndBuildFailures, s)
diff --git a/cmd/bent/configuration.go b/cmd/bent/configuration.go
index c975347..bd192be 100644
--- a/cmd/bent/configuration.go
+++ b/cmd/bent/configuration.go
@@ -113,6 +113,12 @@
 			continue
 		}
 
+		s := fmt.Sprintf("toolchain: %s\n", config.Name)
+		if verbose > 0 {
+			fmt.Print(s)
+		}
+		f.Write([]byte(s))
+
 		if !strings.ContainsAny(cmd, "/") {
 			cmd = path.Join(cwd, cmd)
 		}
@@ -242,12 +248,15 @@
 	// Report and record build stats to testbin
 
 	buf := new(bytes.Buffer)
-	var s string
+	var goarchVal string
 	if configGoArch != runtime.GOARCH && configGoArch != "" {
-		s = fmt.Sprintf("goarch: %s-%s\n", runtime.GOARCH, configGoArch)
+		goarchVal = fmt.Sprintf("%s-%s", runtime.GOARCH, configGoArch)
 	} else {
-		s = fmt.Sprintf("goarch: %s\n", runtime.GOARCH)
+		goarchVal = runtime.GOARCH
 	}
+	var s string
+	s += fmt.Sprintf("goarch: %s\n", goarchVal)
+	s += fmt.Sprintf("toolchain: %s\n", config.Name)
 	if verbose > 0 {
 		fmt.Print(s)
 	}