[go] build: for default bootstrap, use Go 1.17 if present, falling back to Go 1.4

8 views
Skip to first unread message

Russ Cox (Gerrit)

unread,
Dec 7, 2021, 1:59:02 PM12/7/21
to Russ Cox, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Gopher Robot, Dmitri Shuralyov, Ian Lance Taylor, Cuong Manh Le, David Chase, golang-co...@googlegroups.com

Russ Cox submitted this change.

View Change



3 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: src/make.bash
Insertions: 1, Deletions: 1.

@@ -153,7 +153,7 @@
fi

goroot_bootstrap_set=${GOROOT_BOOTSTRAP+"true"}
-if [ "$GOROOT_BOOTSTRAP" = "" ]; then
+if [ -z "$GOROOT_BOOTSTRAP" ]; then
GOROOT_BOOTSTRAP="$HOME/go1.4"
for d in sdk/go1.17 go1.17; do
if [ -d "$HOME/$d" ]; then
```
```
The name of the file: src/cmd/dist/buildtool.go
Insertions: 3, Deletions: 2.

@@ -101,9 +101,10 @@
func bootstrapBuildTools() {
goroot_bootstrap := os.Getenv("GOROOT_BOOTSTRAP")
if goroot_bootstrap == "" {
- goroot_bootstrap = pathf("%s/go1.4", os.Getenv("HOME"))
+ home := os.Getenv("HOME")
+ goroot_bootstrap = pathf("%s/go1.4", home)
for _, d := range tryDirs {
- if p := pathf("%s/%s", os.Getenv("HOME"), d); isdir(p) {
+ if p := pathf("%s/%s", home, d); isdir(p) {
goroot_bootstrap = p
}
}
```

Approvals: Ian Lance Taylor: Looks good to me, approved Russ Cox: Trusted
build: for default bootstrap, use Go 1.17 if present, falling back to Go 1.4

Preparation for #44505, but safe for Go 1.18.
Also fixes the default build on Macs, at least for
people who have a $HOME/go1.17 or have run

go install golang.org/dl/go1.17@latest
go1.17 download

Change-Id: I822f93e75498620fad87db2436376148c42f6bff
Reviewed-on: https://go-review.googlesource.com/c/go/+/369914
Trust: Russ Cox <r...@golang.org>
Reviewed-by: Ian Lance Taylor <ia...@golang.org>
---
M src/cmd/dist/buildtool.go
M src/make.bash
M src/make.bat
M src/make.rc
4 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go
index 75f04a9..17538ad 100644
--- a/src/cmd/dist/buildtool.go
+++ b/src/cmd/dist/buildtool.go
@@ -93,10 +93,21 @@
"_test.go",
}

+var tryDirs = []string{
+ "sdk/go1.17",
+ "go1.17",
+}
+
func bootstrapBuildTools() {
goroot_bootstrap := os.Getenv("GOROOT_BOOTSTRAP")
if goroot_bootstrap == "" {
- goroot_bootstrap = pathf("%s/go1.4", os.Getenv("HOME"))
+ home := os.Getenv("HOME")
+ goroot_bootstrap = pathf("%s/go1.4", home)
+ for _, d := range tryDirs {
+ if p := pathf("%s/%s", home, d); isdir(p) {
+ goroot_bootstrap = p
+ }
+ }
}
xprintf("Building Go toolchain1 using %s.\n", goroot_bootstrap)

diff --git a/src/make.bash b/src/make.bash
index 3310692..2d6c472 100755
--- a/src/make.bash
+++ b/src/make.bash
@@ -153,7 +153,14 @@
fi

goroot_bootstrap_set=${GOROOT_BOOTSTRAP+"true"}
-export GOROOT_BOOTSTRAP=${GOROOT_BOOTSTRAP:-$HOME/go1.4}
+if [ -z "$GOROOT_BOOTSTRAP" ]; then
+ GOROOT_BOOTSTRAP="$HOME/go1.4"
+ for d in sdk/go1.17 go1.17; do
+ if [ -d "$HOME/$d" ]; then
+ GOROOT_BOOTSTRAP="$HOME/$d"
+ fi
+ done
+fi
export GOROOT="$(cd .. && pwd)"
IFS=$'\n'; for go_exe in $(type -ap go); do
if [ ! -x "$GOROOT_BOOTSTRAP/bin/go" ]; then
diff --git a/src/make.bat b/src/make.bat
index 8f2825b..6bffee0 100644
--- a/src/make.bat
+++ b/src/make.bat
@@ -83,6 +83,8 @@
)
)
)
+if "x%GOROOT_BOOTSTRAP%"=="x" if exist "%HOMEDRIVE%%HOMEPATH%\go1.17" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\go1.17
+if "x%GOROOT_BOOTSTRAP%"=="x" if exist "%HOMEDRIVE%%HOMEPATH%\sdk\go1.17" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\sdk\go1.17
if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4

:bootstrapset
diff --git a/src/make.rc b/src/make.rc
index ba8c5db..37087d6 100755
--- a/src/make.rc
+++ b/src/make.rc
@@ -55,6 +55,9 @@
if(! ~ $#GOROOT_BOOTSTRAP 1){
goroot_bootstrap_set = 'false'
GOROOT_BOOTSTRAP = $home/go1.4
+ for(d in sdk/go1.17 go1.17)
+ if(test -d $home/$d)
+ GOROOT_BOOTSTRAP = $home/$d
}
for(p in $path){
if(! test -x $GOROOT_BOOTSTRAP/bin/go){

To view, visit change 369914. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I822f93e75498620fad87db2436376148c42f6bff
Gerrit-Change-Number: 369914
Gerrit-PatchSet: 6
Gerrit-Owner: Russ Cox <r...@golang.org>
Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-CC: David Chase <drc...@google.com>
Gerrit-CC: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-MessageType: merged

Russ Cox (Gerrit)

unread,
Dec 8, 2021, 11:50:10 AM12/8/21
to Russ Cox, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Gopher Robot, Cuong Manh Le, Ian Lance Taylor, Michael Pratt, golang-co...@googlegroups.com

Russ Cox submitted this change.

View Change


Approvals: Cuong Manh Le: Looks good to me, approved Russ Cox: Trusted; Run TryBots Gopher Robot: TryBots succeeded
build: for default bootstrap, use Go 1.17 if present, falling back to Go 1.4

Preparation for #44505, but safe for Go 1.18.
Also fixes the default build on Macs, at least for
people who have a $HOME/go1.17 or have run

go install golang.org/dl/go1.17@latest
go1.17 download

Replay of CL 369914 after revert in CL 370138.
Only change is adding 'export GOROOT_BOOTSTRAP' in make.bash.

Change-Id: I8ced4e87a9dc0f05cc49095578b401ae6212ac85
Reviewed-on: https://go-review.googlesource.com/c/go/+/370274
Trust: Russ Cox <r...@golang.org>
Run-TryBot: Russ Cox <r...@golang.org>
Reviewed-by: Cuong Manh Le <cuong.m...@gmail.com>
TryBot-Result: Gopher Robot <go...@golang.org>

---
M src/cmd/dist/buildtool.go
M src/make.bash
M src/make.bat
M src/make.rc
4 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go
index 75f04a9..17538ad 100644
--- a/src/cmd/dist/buildtool.go
+++ b/src/cmd/dist/buildtool.go
@@ -93,10 +93,21 @@
"_test.go",
}

+var tryDirs = []string{
+ "sdk/go1.17",
+ "go1.17",
+}
+
func bootstrapBuildTools() {
goroot_bootstrap := os.Getenv("GOROOT_BOOTSTRAP")
if goroot_bootstrap == "" {
- goroot_bootstrap = pathf("%s/go1.4", os.Getenv("HOME"))
+ home := os.Getenv("HOME")
+ goroot_bootstrap = pathf("%s/go1.4", home)
+ for _, d := range tryDirs {
+ if p := pathf("%s/%s", home, d); isdir(p) {
+ goroot_bootstrap = p
+ }
+ }
}
xprintf("Building Go toolchain1 using %s.\n", goroot_bootstrap)

diff --git a/src/make.bash b/src/make.bash
index 3310692..9acf079 100755
--- a/src/make.bash
+++ b/src/make.bash
@@ -153,7 +153,16 @@

fi

goroot_bootstrap_set=${GOROOT_BOOTSTRAP+"true"}
-export GOROOT_BOOTSTRAP=${GOROOT_BOOTSTRAP:-$HOME/go1.4}
+if [ -z "$GOROOT_BOOTSTRAP" ]; then
+ GOROOT_BOOTSTRAP="$HOME/go1.4"
+ for d in sdk/go1.17 go1.17; do
+ if [ -d "$HOME/$d" ]; then
+ GOROOT_BOOTSTRAP="$HOME/$d"
+ fi
+ done
+fi
+export GOROOT_BOOTSTRAP
+

To view, visit change 370274. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8ced4e87a9dc0f05cc49095578b401ae6212ac85
Gerrit-Change-Number: 370274
Gerrit-PatchSet: 2
Gerrit-Owner: Russ Cox <r...@golang.org>
Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages