]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: reach fixed point in rebuild during run.bash
authorRuss Cox <rsc@golang.org>
Tue, 31 Oct 2017 19:15:22 +0000 (15:15 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 31 Oct 2017 23:50:25 +0000 (23:50 +0000)
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 <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/cmd/dist/build.go
src/cmd/dist/test.go

index 0a397a18af68db3248c9022327c05ebb1421214e..f0679be54c262f3e37fa8c38c4cb9a058e34e24c 100644 (file)
@@ -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")
        }
index 72d0277a915961b7c5067216d16c0c9b9b331f31..30f5bd74665d1664d8d3b19708f48fd19f202cd1 100644 (file)
@@ -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() {