From 6eb8076961310649ce02604edaec6d161d25c88f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 31 Oct 2017 15:15:22 -0400 Subject: [PATCH] cmd/dist: reach fixed point in rebuild during run.bash This is basically a mini-bootstrap, to reach a fixed point. Change-Id: I88abad3d3ac961c3d11a48cb64d625d458684ef7 Reviewed-on: https://go-review.googlesource.com/74792 Run-TryBot: Russ Cox Reviewed-by: David Crawshaw --- src/cmd/dist/build.go | 15 ++++++++------- src/cmd/dist/test.go | 12 ++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 0a397a18af..f0679be54c 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -1044,6 +1044,8 @@ func timelog(op, name string) { fmt.Fprintf(timeLogFile, "%s %+.1fs %s %s\n", t.Format(time.UnixDate), t.Sub(timeLogStart).Seconds(), op, name) } +var toolchain = []string{"cmd/asm", "cmd/cgo", "cmd/compile", "cmd/link"} + // The bootstrap command runs a build from scratch, // stopping at having installed the go_bootstrap command. // @@ -1151,8 +1153,7 @@ func cmdbootstrap() { // chosen $CC_FOR_TARGET in this case. os.Setenv("CC", defaultcctarget) } - toolchain := []string{"cmd/asm", "cmd/cgo", "cmd/compile", "cmd/link", "cmd/buildid"} - goInstall(toolchain...) + goInstall(goBootstrap, toolchain...) if debug { run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch)) @@ -1180,7 +1181,7 @@ func cmdbootstrap() { xprintf("\n") } xprintf("Building Go toolchain3 using go_bootstrap and Go toolchain2.\n") - goInstall(append([]string{"-a"}, toolchain...)...) + goInstall(goBootstrap, append([]string{"-a"}, toolchain...)...) if debug { run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch)) @@ -1204,7 +1205,7 @@ func cmdbootstrap() { xprintf("\n") } xprintf("Building packages and commands for host, %s/%s.\n", goos, goarch) - goInstall("std", "cmd") + goInstall(goBootstrap, "std", "cmd") checkNotStale(goBootstrap, "std", "cmd") checkNotStale(cmdGo, "std", "cmd") @@ -1219,7 +1220,7 @@ func cmdbootstrap() { os.Setenv("CC", defaultcctarget) xprintf("Building packages and commands for target, %s/%s.\n", goos, goarch) } - goInstall("std", "cmd") + goInstall(goBootstrap, "std", "cmd") checkNotStale(goBootstrap, "std", "cmd") checkNotStale(cmdGo, "std", "cmd") if debug { @@ -1252,8 +1253,8 @@ func cmdbootstrap() { } } -func goInstall(args ...string) { - installCmd := []string{pathf("%s/go_bootstrap", tooldir), "install", "-gcflags=" + gogcflags, "-ldflags=" + goldflags} +func goInstall(goBinary string, args ...string) { + installCmd := []string{goBinary, "install", "-gcflags=" + gogcflags, "-ldflags=" + goldflags} if vflag > 0 { installCmd = append(installCmd, "-v") } diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 72d0277a91..30f5bd7466 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -116,12 +116,12 @@ func (t *tester) run() { if t.rebuild { t.out("Building packages and commands.") - cmd := exec.Command("go", "install", "-a", "-v", "std", "cmd") - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { - log.Fatalf("building packages and commands: %v", err) - } + // Rebuilding is a shortened bootstrap. + // See cmdbootstrap for a description of the overall process. + goInstall("go", toolchain...) + goInstall("go", toolchain...) + goInstall("go", "std", "cmd") + checkNotStale("go", "std", "cmd") } if t.iOS() { -- 2.48.1