From a164a2f5357ed5635cbda1fd4e8dacb835248cd0 Mon Sep 17 00:00:00 2001 From: Wei Congrui Date: Tue, 22 Aug 2017 13:36:19 +0800 Subject: build: add `go env GOROOT` as default GOROOT_BOOTSTRAP value This change also added the same check in make.bash to make.rc, which makes sure $GOROOT_BOOTSTRAP != $GOROOT. Fixes #14339 Change-Id: I2758f4a845bae42ace02492fc6a911f6d6247d26 Reviewed-on: https://go-review.googlesource.com/57753 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/make.bash | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/make.bash') diff --git a/src/make.bash b/src/make.bash index 71e75318f2..3804b46b03 100755 --- a/src/make.bash +++ b/src/make.bash @@ -119,7 +119,15 @@ rm -f ./runtime/runtime_defs.go echo '##### Building Go bootstrap tool.' echo cmd/dist export GOROOT="$(cd .. && pwd)" -GOROOT_BOOTSTRAP=${GOROOT_BOOTSTRAP:-$HOME/go1.4} +export GOROOT_BOOTSTRAP=${GOROOT_BOOTSTRAP:-$HOME/go1.4} +for go_exe in $(type -ap go); do + if [ ! -x "$GOROOT_BOOTSTRAP/bin/go" ]; then + goroot=$(GOROOT='' $go_exe env GOROOT) + if [ "$goroot" != "$GOROOT" ]; then + GOROOT_BOOTSTRAP=$goroot + fi + fi +done if [ ! -x "$GOROOT_BOOTSTRAP/bin/go" ]; then echo "ERROR: Cannot find $GOROOT_BOOTSTRAP/bin/go." >&2 echo "Set \$GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4." >&2 -- cgit v1.3