all: build and use go tool compile, go tool link

This CL fixes the build to use the newly created go tool compile
and go tool link in place of go tool 5g, go tool 5l, and so on.

See golang-dev thread titled "go tool compile, etc" for background.

Although it was not a primary motivation, this conversion does
reduce the wall clock time and cpu time required for make.bash
by about 10%.

Change-Id: I79cbbdb676cab029db8aeefb99a53178ff55f98d
Reviewed-on: https://go-review.googlesource.com/10288
Reviewed-by: Rob Pike <r@golang.org>
diff --git a/test/bench/shootout/timing.sh b/test/bench/shootout/timing.sh
index a06c326..b15825c 100755
--- a/test/bench/shootout/timing.sh
+++ b/test/bench/shootout/timing.sh
@@ -7,8 +7,8 @@
 
 eval $(go tool dist env)
 O=$GOCHAR
-GC="go tool ${O}g"
-LD="go tool ${O}l"
+GC="go tool compile"
+LD="go tool link"
 
 gccm=""
 case "$O" in
diff --git a/test/fixedbugs/bug248.go b/test/fixedbugs/bug248.go
index 3d9a408..2dad1bc 100644
--- a/test/fixedbugs/bug248.go
+++ b/test/fixedbugs/bug248.go
@@ -26,11 +26,11 @@
 	err = os.Chdir(filepath.Join("fixedbugs", "bug248.dir"))
 	check(err)
 
-	run("go", "tool", a+"g", "bug0.go")
-	run("go", "tool", a+"g", "bug1.go")
-	run("go", "tool", a+"g", "bug2.go")
-	run(errchk, "go", "tool", a+"g", "-e", "bug3.go")
-	run("go", "tool", a+"l", "bug2."+a)
+	run("go", "tool", "compile", "bug0.go")
+	run("go", "tool", "compile", "bug1.go")
+	run("go", "tool", "compile", "bug2.go")
+	run(errchk, "go", "tool", "compile", "-e", "bug3.go")
+	run("go", "tool", "link", "bug2."+a)
 	run(fmt.Sprintf(".%c%s.out", filepath.Separator, a))
 
 	os.Remove("bug0." + a)
diff --git a/test/fixedbugs/bug302.go b/test/fixedbugs/bug302.go
index 327d522..faae665 100644
--- a/test/fixedbugs/bug302.go
+++ b/test/fixedbugs/bug302.go
@@ -23,9 +23,9 @@
 		os.Exit(1)
 	}
 
-	run("go", "tool", a+"g", filepath.Join("fixedbugs", "bug302.dir", "p.go"))
+	run("go", "tool", "compile", filepath.Join("fixedbugs", "bug302.dir", "p.go"))
 	run("go", "tool", "pack", "grc", "pp.a", "p."+a)
-	run("go", "tool", a+"g", "-I", ".", filepath.Join("fixedbugs", "bug302.dir", "main.go"))
+	run("go", "tool", "compile", "-I", ".", filepath.Join("fixedbugs", "bug302.dir", "main.go"))
 	os.Remove("p."+a)
 	os.Remove("pp.a")
 	os.Remove("main."+a)
diff --git a/test/fixedbugs/bug345.go b/test/fixedbugs/bug345.go
index 745144f..3ef57bd 100644
--- a/test/fixedbugs/bug345.go
+++ b/test/fixedbugs/bug345.go
@@ -26,8 +26,8 @@
 	err = os.Chdir(filepath.Join(".", "fixedbugs", "bug345.dir"))
 	check(err)
 
-	run("go", "tool", a+"g", "io.go")
-	run(errchk, "go", "tool", a+"g", "-e", "main.go")
+	run("go", "tool", "compile", "io.go")
+	run(errchk, "go", "tool", "compile", "-e", "main.go")
 	os.Remove("io." + a)
 }
 
diff --git a/test/fixedbugs/bug369.go b/test/fixedbugs/bug369.go
index 519703f..b85428b 100644
--- a/test/fixedbugs/bug369.go
+++ b/test/fixedbugs/bug369.go
@@ -24,10 +24,10 @@
 	err = os.Chdir(filepath.Join(".", "fixedbugs", "bug369.dir"))
 	check(err)
 
-	run("go", "tool", a+"g", "-N", "-o", "slow."+a, "pkg.go")
-	run("go", "tool", a+"g", "-o", "fast."+a, "pkg.go")
-	run("go", "tool", a+"g", "-o", "main."+a, "main.go")
-	run("go", "tool", a+"l", "-o", "a.exe", "main."+a)
+	run("go", "tool", "compile", "-N", "-o", "slow."+a, "pkg.go")
+	run("go", "tool", "compile", "-o", "fast."+a, "pkg.go")
+	run("go", "tool", "compile", "-o", "main."+a, "main.go")
+	run("go", "tool", "link", "-o", "a.exe", "main."+a)
 	run("." + string(filepath.Separator) + "a.exe")
 
 	os.Remove("slow." + a)
diff --git a/test/fixedbugs/issue9355.go b/test/fixedbugs/issue9355.go
index bdc0dd0..a841f77 100644
--- a/test/fixedbugs/issue9355.go
+++ b/test/fixedbugs/issue9355.go
@@ -26,7 +26,7 @@
 	err = os.Chdir(filepath.Join("fixedbugs", "issue9355.dir"))
 	check(err)
 
-	out := run("go", "tool", a+"g", "-S", "a.go")
+	out := run("go", "tool", "compile", "-S", "a.go")
 	os.Remove("a." + a)
 
 	// 6g/8g print the offset as dec, but 5g/9g print the offset as hex.
diff --git a/test/nosplit.go b/test/nosplit.go
index bd7a8dd..0fc8dc4 100644
--- a/test/nosplit.go
+++ b/test/nosplit.go
@@ -193,7 +193,7 @@
 		thechar = strings.TrimSpace(string(gochar))
 	}
 
-	version, err := exec.Command("go", "tool", thechar+"g", "-V").Output()
+	version, err := exec.Command("go", "tool", "compile", "-V").Output()
 	if err != nil {
 		bug()
 		fmt.Printf("running go tool %sg -V: %v\n", thechar, err)
diff --git a/test/run.go b/test/run.go
index 10ba7a8..a3124bb 100644
--- a/test/run.go
+++ b/test/run.go
@@ -41,9 +41,6 @@
 )
 
 var (
-	// gc and ld are [568][gl].
-	gc, ld string
-
 	// letter is the build.ArchChar
 	letter string
 
@@ -87,8 +84,6 @@
 	var err error
 	letter, err = build.ArchChar(build.Default.GOARCH)
 	check(err)
-	gc = letter + "g"
-	ld = letter + "l"
 
 	var tests []*test
 	if flag.NArg() > 0 {
@@ -192,11 +187,11 @@
 type runCmd func(...string) ([]byte, error)
 
 func compileFile(runcmd runCmd, longname string) (out []byte, err error) {
-	return runcmd("go", "tool", gc, "-e", longname)
+	return runcmd("go", "tool", "compile", "-e", longname)
 }
 
 func compileInDir(runcmd runCmd, dir string, names ...string) (out []byte, err error) {
-	cmd := []string{"go", "tool", gc, "-e", "-D", ".", "-I", "."}
+	cmd := []string{"go", "tool", "compile", "-e", "-D", ".", "-I", "."}
 	for _, name := range names {
 		cmd = append(cmd, filepath.Join(dir, name))
 	}
@@ -205,7 +200,7 @@
 
 func linkFile(runcmd runCmd, goname string) (err error) {
 	pfile := strings.Replace(goname, ".go", "."+letter, -1)
-	_, err = runcmd("go", "tool", ld, "-w", "-o", "a.exe", "-L", ".", pfile)
+	_, err = runcmd("go", "tool", "link", "-w", "-o", "a.exe", "-L", ".", pfile)
 	return
 }
 
@@ -506,7 +501,7 @@
 		t.err = fmt.Errorf("unimplemented action %q", action)
 
 	case "errorcheck":
-		cmdline := []string{"go", "tool", gc, "-e", "-o", "a." + letter}
+		cmdline := []string{"go", "tool", "compile", "-e", "-o", "a." + letter}
 		cmdline = append(cmdline, flags...)
 		cmdline = append(cmdline, long)
 		out, err := runcmd(cmdline...)
@@ -669,7 +664,7 @@
 			t.err = fmt.Errorf("write tempfile:%s", err)
 			return
 		}
-		cmdline := []string{"go", "tool", gc, "-e", "-o", "a." + letter}
+		cmdline := []string{"go", "tool", "compile", "-e", "-o", "a." + letter}
 		cmdline = append(cmdline, flags...)
 		cmdline = append(cmdline, tfile)
 		out, err = runcmd(cmdline...)
diff --git a/test/sinit_run.go b/test/sinit_run.go
index b0a91ce..cc437bf 100644
--- a/test/sinit_run.go
+++ b/test/sinit_run.go
@@ -24,7 +24,7 @@
 		os.Exit(1)
 	}
 
-	cmd := exec.Command("go", "tool", letter+"g", "-S", "sinit.go")
+	cmd := exec.Command("go", "tool", "compile", "-S", "sinit.go")
 	out, err := cmd.CombinedOutput()
 	if err != nil {
 		fmt.Println(string(out))