d40cd88
diff -up go/src/cmd/dist/buildtool.go.bootstrap go/src/cmd/dist/buildtool.go
d36359a
--- go/src/cmd/dist/buildtool.go.bootstrap	2016-06-06 14:26:37.638374670 +0200
d36359a
+++ go/src/cmd/dist/buildtool.go	2016-06-06 14:30:33.873262307 +0200
d36359a
@@ -111,15 +111,23 @@ func bootstrapBuildTools() {
d36359a
 	defer os.Setenv("GOBIN", os.Getenv("GOBIN"))
8d165df
 	os.Setenv("GOBIN", "")
8d165df
 
8d165df
+	hostos := os.Getenv("GOHOSTOS")
8d165df
+	hostarch := os.Getenv("GOHOSTARCH")
d36359a
+
d36359a
 	os.Setenv("GOOS", "")
d36359a
 	os.Setenv("GOHOSTOS", "")
d36359a
 	os.Setenv("GOARCH", "")
8d165df
 	os.Setenv("GOHOSTARCH", "")
8d165df
 
8d165df
+	bingopath := pathf("%s/bin/%s_%s/go", goroot_bootstrap, hostos, hostarch)
8d165df
+	if _, err := os.Stat(bingopath); os.IsNotExist(err) {
8d165df
+		bingopath = pathf("%s/bin/go", goroot_bootstrap)
8d165df
+	}
8d165df
+
d36359a
 	// Run Go 1.4 to build binaries. Use -gcflags=-l to disable inlining to
d36359a
 	// workaround bugs in Go 1.4's compiler. See discussion thread:
d36359a
 	// https://groups.google.com/d/msg/golang-dev/Ss7mCKsvk8w/Gsq7VYI0AwAJ
d36359a
-	run(workspace, ShowOutput|CheckExit, pathf("%s/bin/go", goroot_bootstrap), "install", "-gcflags=-l", "-v", "bootstrap/...")
d36359a
+	run(workspace, ShowOutput|CheckExit, bingopath, "install", "-gcflags=-l", "-v", "bootstrap/...")
8d165df
 
8d165df
 	// Copy binaries into tool binary directory.
8d165df
 	for _, name := range bootstrapDirs {
d40cd88
diff -up go/src/make.bash.bootstrap go/src/make.bash
d36359a
--- go/src/make.bash.bootstrap	2016-06-06 14:26:37.628374633 +0200
d36359a
+++ go/src/make.bash	2016-06-06 14:26:37.638374670 +0200
d36359a
@@ -118,8 +118,15 @@ echo '##### Building Go bootstrap tool.'
8d165df
 echo cmd/dist
8d165df
 export GOROOT="$(cd .. && pwd)"
8d165df
 GOROOT_BOOTSTRAP=${GOROOT_BOOTSTRAP:-$HOME/go1.4}
8d165df
-if [ ! -x "$GOROOT_BOOTSTRAP/bin/go" ]; then
8d165df
-	echo "ERROR: Cannot find $GOROOT_BOOTSTRAP/bin/go." >&2
8d165df
+if [ -x "$GOROOT_BOOTSTRAP/bin/${GOHOSTOS}_${GOHOSTARCH}/go" ]; then
8d165df
+	rm -f cmd/dist/dist
8d165df
+	GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" "$GOROOT_BOOTSTRAP/bin/${GOHOSTOS}_${GOHOSTARCH}/go" build -o cmd/dist/dist ./cmd/dist
8d165df
+elif [ -x "$GOROOT_BOOTSTRAP/bin/go" ]; then
8d165df
+	rm -f cmd/dist/dist
8d165df
+	GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist
8d165df
+else
8d165df
+	echo "ERROR: Cannot find $GOROOT_BOOTSTRAP/bin/${GOHOSTOS}_${GOHOSTARCH}/go." >&2
8d165df
+	echo "ERROR: or $GOROOT_BOOTSTRAP/bin/${GOHOSTOS}_${GOHOSTARCH}/go." >&2
8d165df
 	echo "Set \$GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4." >&2
d40cd88
 	exit 1
8d165df
 fi
d36359a
@@ -128,8 +135,6 @@ if [ "$GOROOT_BOOTSTRAP" == "$GOROOT" ];
d36359a
 	echo "Set \$GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4." >&2
d36359a
 	exit 1
d36359a
 fi
d36359a
-rm -f cmd/dist/dist
d36359a
-GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist
d36359a
 
d36359a
 # -e doesn't propagate out of eval, so check success by hand.
d36359a
 eval $(./cmd/dist/dist env -p || echo FAIL=true)