d40cd88
diff -up go/src/cmd/dist/buildtool.go.bootstrap go/src/cmd/dist/buildtool.go
100fcef
--- go/src/cmd/dist/buildtool.go.bootstrap	2016-10-24 12:54:57.620563325 +0200
100fcef
+++ go/src/cmd/dist/buildtool.go	2016-10-24 13:12:25.036466602 +0200
100fcef
@@ -131,17 +131,25 @@ 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
100fcef
 	// Use the math_big_pure_go build tag to disable the assembly in math/big
100fcef
 	// which may contain unsupported instructions.
100fcef
-	run(workspace, ShowOutput|CheckExit, pathf("%s/bin/go", goroot_bootstrap), "install", "-gcflags=-l", "-tags=math_big_pure_go", "-v", "bootstrap/cmd/...")
100fcef
+	run(workspace, ShowOutput|CheckExit, bingopath, "install", "-gcflags=-l", "-v", "-tags=math_big_pure_go", "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
100fcef
--- go/src/make.bash.bootstrap	2016-10-24 12:54:57.606563267 +0200
100fcef
+++ go/src/make.bash	2016-10-24 12:54:57.620563325 +0200
100fcef
@@ -120,8 +120,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
100fcef
@@ -130,8 +137,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)