diff options
author | Caroline Tice <cmtice@google.com> | 2019-01-22 12:43:33 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-01-24 00:51:50 -0800 |
commit | 1f3c5d01027b8925ad4287d0afef4d25af165699 (patch) | |
tree | 861d7cb70171672910c21a58b0493c2dee83fbb2 /go | |
parent | 42199fae69016e15d6840646fac13a540aeb59ce (diff) | |
download | toolchain-utils-1f3c5d01027b8925ad4287d0afef4d25af165699.tar.gz |
toolchain-utils: Fix the testing patches for Go.
The Go testing instructions include applying 7 patches. The patches
applied cleanly to 1.10.2, but not to any later version of Go. This
CL updates that patches for the later versions of Go.
BUG=chromium:924271
TEST=patches apply cleanly to their versions; re-ran tests to make
sure nothing broke.
Change-Id: I3ffe87876f215bfb6d37cc6a9f0fbc88325d13c1
Reviewed-on: https://chromium-review.googlesource.com/1427342
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Caroline Tice <cmtice@chromium.org>
Reviewed-by: Luis Lozano <llozano@chromium.org>
Diffstat (limited to 'go')
21 files changed, 3061 insertions, 0 deletions
diff --git a/go/patch/go0.patch b/go/patch/go-1.10.2/go0.patch index c539865e..c539865e 100644 --- a/go/patch/go0.patch +++ b/go/patch/go-1.10.2/go0.patch diff --git a/go/patch/go1.patch b/go/patch/go-1.10.2/go1.patch index e32268ac..e32268ac 100644 --- a/go/patch/go1.patch +++ b/go/patch/go-1.10.2/go1.patch diff --git a/go/patch/go2.patch b/go/patch/go-1.10.2/go2.patch index 20f04791..20f04791 100644 --- a/go/patch/go2.patch +++ b/go/patch/go-1.10.2/go2.patch diff --git a/go/patch/go3.patch b/go/patch/go-1.10.2/go3.patch index 62247a03..62247a03 100644 --- a/go/patch/go3.patch +++ b/go/patch/go-1.10.2/go3.patch diff --git a/go/patch/go4.patch b/go/patch/go-1.10.2/go4.patch index 290de390..290de390 100644 --- a/go/patch/go4.patch +++ b/go/patch/go-1.10.2/go4.patch diff --git a/go/patch/go5.patch b/go/patch/go-1.10.2/go5.patch index 7189c89e..7189c89e 100644 --- a/go/patch/go5.patch +++ b/go/patch/go-1.10.2/go5.patch diff --git a/go/patch/go6.patch b/go/patch/go-1.10.2/go6.patch index 9f32ed84..9f32ed84 100644 --- a/go/patch/go6.patch +++ b/go/patch/go-1.10.2/go6.patch diff --git a/go/patch/go-1.10.3/go0.patch b/go/patch/go-1.10.3/go0.patch new file mode 100644 index 00000000..f80045c0 --- /dev/null +++ b/go/patch/go-1.10.3/go0.patch @@ -0,0 +1,27 @@ +diff --git src/go/build/deps_test.go src/go/build/deps_test.go +index 29dbe47d29..53e0e287bc 100644 +--- src/go/build/deps_test.go ++++ src/go/build/deps_test.go +@@ -191,7 +191,7 @@ var pkgDeps = map[string][]string{ + "testing": {"L2", "flag", "fmt", "internal/race", "os", "runtime/debug", "runtime/pprof", "runtime/trace", "time"}, + "testing/iotest": {"L2", "log"}, + "testing/quick": {"L2", "flag", "fmt", "reflect", "time"}, +- "internal/testenv": {"L2", "OS", "flag", "testing", "syscall"}, ++ "internal/testenv": {"L2", "OS", "os.exec", "flag", "testing", "syscall"}, + + // L4 is defined as L3+fmt+log+time, because in general once + // you're using L3 packages, use of fmt, log, or time is not a big deal. +diff --git src/internal/testenv/testenv.go src/internal/testenv/testenv.go +index 8f69fe0da5..d52b85e122 100644 +--- src/internal/testenv/testenv.go ++++ src/internal/testenv/testenv.go +@@ -48,6 +48,9 @@ func HasGoBuild() bool { + return false + } + } ++ if _, err := exec.LookPath("go"); err != nil { ++ return false ++ } + return true + } + diff --git a/go/patch/go-1.10.3/go1.patch b/go/patch/go-1.10.3/go1.patch new file mode 100644 index 00000000..e05fcce4 --- /dev/null +++ b/go/patch/go-1.10.3/go1.patch @@ -0,0 +1,50 @@ +diff --git test/chanlinear.go test/chanlinear.go +index 55fee4ab9b..89533da282 100644 +--- test/chanlinear.go ++++ test/chanlinear.go +@@ -1,4 +1,4 @@ +-// +build darwin linux ++// +build darwin linux android + // run + + // Copyright 2014 The Go Authors. All rights reserved. +diff --git a/test/fixedbugs/bug385_64.go b/test/fixedbugs/bug385_64.go +index 0f941ca2f4..3bcd62f3ad 100644 +--- test/fixedbugs/bug385_64.go ++++ test/fixedbugs/bug385_64.go +@@ -1,4 +1,4 @@ +-// +build amd64 ++// +build amd64 arm64 + // errorcheck + + // Copyright 2011 The Go Authors. All rights reserved. +diff --git test/fixedbugs/issue10607.go test/fixedbugs/issue10607.go +index 8831547da8..9ee6c72bc6 100644 +--- test/fixedbugs/issue10607.go ++++ test/fixedbugs/issue10607.go +@@ -1,4 +1,4 @@ +-// +build linux,!ppc64 ++// +build linux,!ppc64 android + // run + + // Copyright 2015 The Go Authors. All rights reserved. +diff --git test/maplinear.go test/maplinear.go +index 34d0914914..afddab627d 100644 +--- test/maplinear.go ++++ test/maplinear.go +@@ -1,4 +1,4 @@ +-// +build darwin linux ++// +build darwin linux android + // run + + // Copyright 2013 The Go Authors. All rights reserved. +diff --git test/recover4.go test/recover4.go +index 67ed970ecb..95a89dab00 100644 +--- test/recover4.go ++++ test/recover4.go +@@ -1,4 +1,4 @@ +-// +build linux darwin ++// +build linux android darwin + // run + + // Copyright 2015 The Go Authors. All rights reserved. diff --git a/go/patch/go-1.10.3/go2.patch b/go/patch/go-1.10.3/go2.patch new file mode 100644 index 00000000..bbd2b744 --- /dev/null +++ b/go/patch/go-1.10.3/go2.patch @@ -0,0 +1,267 @@ +diff --git test/run.go test/run.go +index 22ec7576f8..ac5d3c3e8d 100644 +--- test/run.go ++++ test/run.go +@@ -39,9 +39,9 @@ var ( + summary = flag.Bool("summary", false, "show summary of results") + showSkips = flag.Bool("show_skips", false, "show skipped tests") + runSkips = flag.Bool("run_skips", false, "run skipped tests (ignore skip and build tags)") +- linkshared = flag.Bool("linkshared", false, "") + updateErrors = flag.Bool("update_errors", false, "update error messages in test file based on compiler output") + runoutputLimit = flag.Int("l", defaultRunOutputLimit(), "number of parallel runoutput tests to run") ++ target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") + + shard = flag.Int("shard", 0, "shard index to run. Only applicable if -shards is non-zero.") + shards = flag.Int("shards", 0, "number of shards. If 0, all tests are run. This is used by the continuous build.") +@@ -194,21 +194,15 @@ func goFiles(dir string) []string { + type runCmd func(...string) ([]byte, error) + + func compileFile(runcmd runCmd, longname string, flags []string) (out []byte, err error) { +- cmd := []string{"go", "tool", "compile", "-e"} ++ cmd := []string{findGoCmd(), "tool", "compile", "-e"} + cmd = append(cmd, flags...) +- if *linkshared { +- cmd = append(cmd, "-dynlink", "-installsuffix=dynlink") +- } + cmd = append(cmd, longname) + return runcmd(cmd...) + } + + func compileInDir(runcmd runCmd, dir string, flags []string, names ...string) (out []byte, err error) { +- cmd := []string{"go", "tool", "compile", "-e", "-D", ".", "-I", "."} ++ cmd := []string{findGoCmd(), "tool", "compile", "-e", "-D", ".", "-I", "."} + cmd = append(cmd, flags...) +- if *linkshared { +- cmd = append(cmd, "-dynlink", "-installsuffix=dynlink") +- } + for _, name := range names { + cmd = append(cmd, filepath.Join(dir, name)) + } +@@ -217,15 +211,24 @@ func compileInDir(runcmd runCmd, dir string, flags []string, names ...string) (o + + func linkFile(runcmd runCmd, goname string) (err error) { + pfile := strings.Replace(goname, ".go", ".o", -1) +- cmd := []string{"go", "tool", "link", "-w", "-o", "a.exe", "-L", "."} +- if *linkshared { +- cmd = append(cmd, "-linkshared", "-installsuffix=dynlink") +- } +- cmd = append(cmd, pfile) +- _, err = runcmd(cmd...) ++ cmd := []string{findGoCmd, "tool", "link", "-w", "-o", "a.exe", "-L", "."} ++ _, err = runcmd(findGoCmd(), "tool", "link", "-w", "-o", "a.exe", "-L", ".", pfile) + return + } + ++ ++func goRun(runcmd runCmd, flags []string, goname string, args ...string) (out []byte, err error) { ++ cmd := []string{findGoCmd(), "run", goGcflags()} ++ if len(findExecCmd()) > 0 { ++ cmd = append(cmd, "-exec") ++ cmd = append(cmd, findExecCmd()...) ++ } ++ cmd = append(cmd, flags...) ++ cmd = append(cmd, goname) ++ cmd = append(cmd, args...) ++ return runcmd(cmd...) ++} ++ + // skipError describes why a test was skipped. + type skipError string + +@@ -595,7 +598,7 @@ func (t *test) run() { + + case "errorcheck": + // TODO(gri) remove need for -C (disable printing of columns in error messages) +- cmdline := []string{"go", "tool", "compile", "-C", "-e", "-o", "a.o"} ++ cmdline := []string{findGoCmd(), "tool", "compile", "-C", "-e", "-o", "a.o"} + // No need to add -dynlink even if linkshared if we're just checking for errors... + cmdline = append(cmdline, flags...) + cmdline = append(cmdline, long) +@@ -709,7 +712,7 @@ func (t *test) run() { + } + + case "build": +- _, err := runcmd("go", "build", goGcflags(), "-o", "a.exe", long) ++ _, err := runcmd(findGoCmd(), "build", goGcflags(), "-o", "a.exe", long) + if err != nil { + t.err = err + } +@@ -735,7 +738,7 @@ func (t *test) run() { + + } + var objs []string +- cmd := []string{"go", "tool", "compile", "-e", "-D", ".", "-I", ".", "-o", "go.o"} ++ cmd := []string{findGoCmd(), "tool", "compile", "-e", "-D", ".", "-I", ".", "-o", "go.o"} + if len(asms) > 0 { + cmd = append(cmd, "-asmhdr", "go_asm.h") + } +@@ -749,7 +752,7 @@ func (t *test) run() { + } + objs = append(objs, "go.o") + if len(asms) > 0 { +- cmd = []string{"go", "tool", "asm", "-e", "-I", ".", "-o", "asm.o"} ++ cmd = []string{findGoCmd(), "tool", "asm", "-e", "-I", ".", "-o", "asm.o"} + for _, file := range asms { + cmd = append(cmd, filepath.Join(longdir, file.Name())) + } +@@ -760,14 +763,14 @@ func (t *test) run() { + } + objs = append(objs, "asm.o") + } +- cmd = []string{"go", "tool", "pack", "c", "all.a"} ++ cmd = []string{findGoCmd(), "tool", "pack", "c", "all.a"} + cmd = append(cmd, objs...) + _, err = runcmd(cmd...) + if err != nil { + t.err = err + break + } +- cmd = []string{"go", "tool", "link", "all.a"} ++ cmd = []string{findGoCmd(), "tool", "link", "-o", "a.exe", "all.a"} + _, err = runcmd(cmd...) + if err != nil { + t.err = err +@@ -777,10 +780,7 @@ func (t *test) run() { + case "buildrun": // build binary, then run binary, instead of go run. Useful for timeout tests where failure mode is infinite loop. + // TODO: not supported on NaCl + useTmp = true +- cmd := []string{"go", "build", goGcflags(), "-o", "a.exe"} +- if *linkshared { +- cmd = append(cmd, "-linkshared") +- } ++ cmd := []string{findGoCmd(), "build", goGcflags(), "-o", "a.exe"} + longdirgofile := filepath.Join(filepath.Join(cwd, t.dir), t.gofile) + cmd = append(cmd, flags...) + cmd = append(cmd, longdirgofile) +@@ -789,7 +789,12 @@ func (t *test) run() { + t.err = err + return + } +- cmd = []string{"./a.exe"} ++ cmd = []string{} ++ if len(findExecCmd()) > 0 { ++ cmd = append(cmd, findExecCmd()...) ++ } ++ cmd = append(cmd, "./a.exe") ++ + out, err = runcmd(append(cmd, args...)...) + if err != nil { + t.err = err +@@ -802,38 +807,7 @@ func (t *test) run() { + + case "run": + useTmp = false +- var out []byte +- var err error +- if len(flags)+len(args) == 0 && goGcflags() == "" && !*linkshared { +- // If we're not using special go command flags, +- // skip all the go command machinery. +- // This avoids any time the go command would +- // spend checking whether, for example, the installed +- // package runtime is up to date. +- // Because we run lots of trivial test programs, +- // the time adds up. +- pkg := filepath.Join(t.tempDir, "pkg.a") +- if _, err := runcmd("go", "tool", "compile", "-o", pkg, t.goFileName()); err != nil { +- t.err = err +- return +- } +- exe := filepath.Join(t.tempDir, "test.exe") +- cmd := []string{"go", "tool", "link", "-s", "-w"} +- cmd = append(cmd, "-o", exe, pkg) +- if _, err := runcmd(cmd...); err != nil { +- t.err = err +- return +- } +- out, err = runcmd(append([]string{exe}, args...)...) +- } else { +- cmd := []string{"go", "run", goGcflags()} +- if *linkshared { +- cmd = append(cmd, "-linkshared") +- } +- cmd = append(cmd, flags...) +- cmd = append(cmd, t.goFileName()) +- out, err = runcmd(append(cmd, args...)...) +- } ++ out, err := goRun(runcmd, flags, t.goFileName(), args...) + if err != nil { + t.err = err + return +@@ -848,12 +822,7 @@ func (t *test) run() { + <-rungatec + }() + useTmp = false +- cmd := []string{"go", "run", goGcflags()} +- if *linkshared { +- cmd = append(cmd, "-linkshared") +- } +- cmd = append(cmd, t.goFileName()) +- out, err := runcmd(append(cmd, args...)...) ++ out, err := goRun(runcmd, nil, t.goFileName(), args...) + if err != nil { + t.err = err + return +@@ -863,12 +832,7 @@ func (t *test) run() { + t.err = fmt.Errorf("write tempfile:%s", err) + return + } +- cmd = []string{"go", "run", goGcflags()} +- if *linkshared { +- cmd = append(cmd, "-linkshared") +- } +- cmd = append(cmd, tfile) +- out, err = runcmd(cmd...) ++ out, err = goRun(runcmd, nil, tfile) + if err != nil { + t.err = err + return +@@ -879,12 +843,7 @@ func (t *test) run() { + + case "errorcheckoutput": + useTmp = false +- cmd := []string{"go", "run", goGcflags()} +- if *linkshared { +- cmd = append(cmd, "-linkshared") +- } +- cmd = append(cmd, t.goFileName()) +- out, err := runcmd(append(cmd, args...)...) ++ out, err := goRun(runcmd, nil, t.goFileName(), args...) + if err != nil { + t.err = err + return +@@ -895,7 +854,7 @@ func (t *test) run() { + t.err = fmt.Errorf("write tempfile:%s", err) + return + } +- cmdline := []string{"go", "tool", "compile", "-e", "-o", "a.o"} ++ cmdline := []string{findGoCmd(), "tool", "compile", "-e", "-o", "a.o"} + cmdline = append(cmdline, flags...) + cmdline = append(cmdline, tfile) + out, err = runcmd(cmdline...) +@@ -922,6 +881,11 @@ func findExecCmd() []string { + return execCmd + } + execCmd = []string{} // avoid work the second time ++ if *target != "" { ++ execCmd = []string{"go_" + *target + "_exec"} ++ return execCmd ++ } ++ + if goos == runtime.GOOS && goarch == runtime.GOARCH { + return execCmd + } +@@ -932,6 +896,14 @@ func findExecCmd() []string { + return execCmd + } + ++func findGoCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++ + func (t *test) String() string { + return filepath.Join(t.dir, t.gofile) + } diff --git a/go/patch/go-1.10.3/go3.patch b/go/patch/go-1.10.3/go3.patch new file mode 100644 index 00000000..223ccb85 --- /dev/null +++ b/go/patch/go-1.10.3/go3.patch @@ -0,0 +1,732 @@ +diff --git test/fixedbugs/bug302.go test/fixedbugs/bug302.go +index e4de25d5d0..ea566e6e44 100644 +--- test/fixedbugs/bug302.go ++++ test/fixedbugs/bug302.go +@@ -1,5 +1,5 @@ + // +build !nacl +-// run ++// runtarget + + // Copyright 2010 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -8,16 +8,27 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" + "path/filepath" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ + func main() { +- run("go", "tool", "compile", filepath.Join("fixedbugs", "bug302.dir", "p.go")) +- run("go", "tool", "pack", "grc", "pp.a", "p.o") +- run("go", "tool", "compile", "-I", ".", filepath.Join("fixedbugs", "bug302.dir", "main.go")) ++ flag.Parse() ++ run(goCmd(), "tool", "compile", filepath.Join("fixedbugs", "bug302.dir", "p.go")) ++ run(goCmd(), "tool", "pack", "grc", "pp.a", "p.o") ++ run(goCmd(), "tool", "compile", "-I", ".", filepath.Join("fixedbugs", "bug302.dir", "main.go")) + os.Remove("p.o") + os.Remove("pp.a") + os.Remove("main.o") +diff --git test/fixedbugs/bug369.go test/fixedbugs/bug369.go +index 60162ab1cb..4470d5a076 100644 +--- test/fixedbugs/bug369.go ++++ test/fixedbugs/bug369.go +@@ -1,5 +1,5 @@ + // +build !nacl,!windows +-// run ++// runtarget + + // Copyright 2011 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -10,21 +10,40 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" + "path/filepath" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(cmd ...string) { ++ if *target == "" { ++ run(cmd[0], cmd[1:]...) ++ } else { ++ run("go_"+*target+"_exec", cmd...) ++ } ++} ++ + func main() { ++ flag.Parse() + err := os.Chdir(filepath.Join(".", "fixedbugs", "bug369.dir")) + check(err) + +- run("go", "tool", "compile", "-N", "-o", "slow.o", "pkg.go") +- run("go", "tool", "compile", "-o", "fast.o", "pkg.go") +- run("go", "tool", "compile", "-o", "main.o", "main.go") +- run("go", "tool", "link", "-o", "a.exe", "main.o") +- run("." + string(filepath.Separator) + "a.exe") ++ run(goCmd(), "tool", "compile", "-N", "-o", "slow.o", "pkg.go") ++ run(goCmd(), "tool", "compile", "-o", "fast.o", "pkg.go") ++ run(goCmd(), "tool", "compile", "-o", "main.o", "main.go") ++ run(goCmd(), "tool", "link", "-o", "a.exe", "main.o") ++ goRun("." + string(filepath.Separator) + "a.exe") + + os.Remove("slow.o") + os.Remove("fast.o") +diff --git test/fixedbugs/bug429_run.go test/fixedbugs/bug429_run.go +index 284033d1f7..e8d18b13e8 100644 +--- test/fixedbugs/bug429_run.go ++++ test/fixedbugs/bug429_run.go +@@ -1,5 +1,5 @@ + // +build !nacl +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -10,6 +10,7 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" +@@ -17,8 +18,27 @@ import ( + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(args ...string) *exec.Cmd { ++ cmd := []string{"run"} ++ if *target != "" { ++ cmd = append(cmd, "-exec", "go_"+*target+"_exec") ++ } ++ cmd = append(cmd, args...) ++ return exec.Command(goCmd(), cmd...) ++} ++ + func main() { +- cmd := exec.Command("go", "run", filepath.Join("fixedbugs", "bug429.go")) ++ flag.Parse() ++ cmd := goRun(filepath.Join("fixedbugs", "bug429.go")) + out, err := cmd.CombinedOutput() + if err == nil { + fmt.Println("expected deadlock") +diff --git test/fixedbugs/issue10607.go test/fixedbugs/issue10607.go +index 9ee6c72bc6..e819a3085a 100644 +--- test/fixedbugs/issue10607.go ++++ test/fixedbugs/issue10607.go +@@ -1,5 +1,5 @@ + // +build linux,!ppc64 android +-// run ++// runtarget + + // Copyright 2015 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -11,19 +11,39 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" + "path/filepath" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(args ...string) *exec.Cmd { ++ cmd := []string{"run"} ++ if *target != "" { ++ cmd = append(cmd, "-exec", "go_"+*target+"_exec") ++ } ++ cmd = append(cmd, args...) ++ return exec.Command(goCmd(), cmd...) ++} ++ + func main() { +- test("internal") ++ flag.Parse() ++ //test("internal") + test("external") + } + + func test(linkmode string) { +- out, err := exec.Command("go", "run", "-ldflags", "-B=0x12345678 -linkmode="+linkmode, filepath.Join("fixedbugs", "issue10607a.go")).CombinedOutput() ++ out, err := goRun("-ldflags", "-B=0x12345678 -linkmode="+linkmode, filepath.Join("fixedbugs", "issue10607a.go")).CombinedOutput() + if err != nil { + fmt.Printf("BUG: linkmode=%s %v\n%s\n", linkmode, err, out) + os.Exit(1) +diff --git test/fixedbugs/issue11771.go test/fixedbugs/issue11771.go +index d91fc5d966..4f55ce6982 100644 +--- test/fixedbugs/issue11771.go ++++ test/fixedbugs/issue11771.go +@@ -1,5 +1,5 @@ + // +build !nacl +-// run ++// runtarget + + // Copyright 2015 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -11,6 +11,7 @@ package main + + import ( + "bytes" ++ "flag" + "fmt" + "io/ioutil" + "log" +@@ -20,7 +21,17 @@ import ( + "runtime" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ + func main() { ++ flag.Parse() + if runtime.Compiler != "gc" { + return + } +@@ -52,7 +63,7 @@ func x() { + log.Fatal(err) + } + +- cmd := exec.Command("go", "tool", "compile", "x.go") ++ cmd := exec.Command(goCmd(), "tool", "compile", "x.go") + cmd.Dir = dir + output, err := cmd.CombinedOutput() + if err == nil { +diff --git test/fixedbugs/issue9355.go test/fixedbugs/issue9355.go +index 10f8c73069..87356c7402 100644 +--- test/fixedbugs/issue9355.go ++++ test/fixedbugs/issue9355.go +@@ -1,4 +1,4 @@ +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -7,6 +7,7 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" +@@ -15,7 +16,17 @@ import ( + "runtime" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ + func main() { ++ flag.Parse() + if runtime.Compiler != "gc" || runtime.GOOS == "nacl" { + return + } +@@ -23,7 +34,7 @@ func main() { + err := os.Chdir(filepath.Join("fixedbugs", "issue9355.dir")) + check(err) + +- out := run("go", "tool", "compile", "-S", "a.go") ++ out := run(goCmd(), "tool", "compile", "-S", "a.go") + os.Remove("a.o") + + // 6g/8g print the offset as dec, but 5g/9g print the offset as hex. +diff --git test/fixedbugs/issue9862_run.go test/fixedbugs/issue9862_run.go +index be22f40580..a72a59fda2 100644 +--- test/fixedbugs/issue9862_run.go ++++ test/fixedbugs/issue9862_run.go +@@ -1,5 +1,5 @@ + // +build !nacl +-// run ++// runtarget + + // Copyright 2015 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -10,12 +10,32 @@ + package main + + import ( ++ "flag" + "os/exec" + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(args ...string) *exec.Cmd { ++ cmd := []string{"run"} ++ if *target != "" { ++ cmd = append(cmd, "-exec", "go_"+*target+"_exec") ++ } ++ cmd = append(cmd, args...) ++ return exec.Command(goCmd(), cmd...) ++} ++ + func main() { +- out, err := exec.Command("go", "run", "fixedbugs/issue9862.go").CombinedOutput() ++ flag.Parse() ++ out, err := goRun("fixedbugs/issue9862.go").CombinedOutput() + outstr := string(out) + if err == nil { + println("go run issue9862.go succeeded, should have failed\n", outstr) +diff --git test/linkmain_run.go test/linkmain_run.go +index 55de481a81..03666e6b29 100644 +--- test/linkmain_run.go ++++ test/linkmain_run.go +@@ -1,5 +1,5 @@ + // +build !nacl +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -10,12 +10,22 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ + func cleanup() { + os.Remove("linkmain.o") + os.Remove("linkmain.a") +@@ -51,16 +61,17 @@ func runFail(cmdline string) { + } + + func main() { ++ flag.Parse() + // helloworld.go is package main +- run("go tool compile -o linkmain.o helloworld.go") +- run("go tool compile -pack -o linkmain.a helloworld.go") +- run("go tool link -o linkmain.exe linkmain.o") +- run("go tool link -o linkmain.exe linkmain.a") ++ run(goCmd() + " tool compile -o linkmain.o helloworld.go") ++ run(goCmd() + " tool compile -pack -o linkmain.a helloworld.go") ++ run(goCmd() + " tool link -o linkmain.exe linkmain.o") ++ run(goCmd() + " tool link -o linkmain.exe linkmain.a") + + // linkmain.go is not +- run("go tool compile -o linkmain1.o linkmain.go") +- run("go tool compile -pack -o linkmain1.a linkmain.go") +- runFail("go tool link -o linkmain.exe linkmain1.o") +- runFail("go tool link -o linkmain.exe linkmain1.a") ++ run(goCmd() + " tool compile -o linkmain1.o linkmain.go") ++ run(goCmd() + " tool compile -pack -o linkmain1.a linkmain.go") ++ runFail(goCmd() + " tool link -o linkmain.exe linkmain1.o") ++ runFail(goCmd() + " tool link -o linkmain.exe linkmain1.a") + cleanup() + } +diff --git test/linkobj.go test/linkobj.go +index 8a86aa872f..0d1964e7fb 100644 +--- test/linkobj.go ++++ test/linkobj.go +@@ -1,5 +1,5 @@ + // +build !nacl +-// run ++// runtarget + + // Copyright 2016 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -10,6 +10,7 @@ + package main + + import ( ++ "flag" + "fmt" + "io/ioutil" + "log" +@@ -18,9 +19,27 @@ import ( + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(cmd ...string) string { ++ if *target == "" { ++ return run(cmd...) ++ } else { ++ return run(append([]string{"go_"+*target+"_exec"}, cmd...)...) ++ } ++} ++ + var pwd, tmpdir string + + func main() { ++ flag.Parse() + dir, err := ioutil.TempDir("", "go-test-linkobj-") + if err != nil { + log.Fatal(err) +@@ -37,28 +56,28 @@ func main() { + + writeFile("p1.go", ` + package p1 +- ++ + func F() { + println("hello from p1") + } + `) + writeFile("p2.go", ` + package p2 +- ++ + import "./p1" + + func F() { + p1.F() + println("hello from p2") + } +- ++ + func main() {} + `) + writeFile("p3.go", ` + package main + + import "./p2" +- ++ + func main() { + p2.F() + println("hello from main") +@@ -76,9 +95,9 @@ func main() { + } + + // inlining is disabled to make sure that the link objects contain needed code. +- run("go", "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p1."+o, "-linkobj", "p1.lo", "p1.go") +- run("go", "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p2."+o, "-linkobj", "p2.lo", "p2.go") +- run("go", "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p3."+o, "-linkobj", "p3.lo", "p3.go") ++ run(goCmd(), "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p1."+o, "-linkobj", "p1.lo", "p1.go") ++ run(goCmd(), "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p2."+o, "-linkobj", "p2.lo", "p2.go") ++ run(goCmd(), "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p3."+o, "-linkobj", "p3.lo", "p3.go") + + cp("p1."+o, "p1.oo") + cp("p2."+o, "p2.oo") +@@ -86,13 +105,13 @@ func main() { + cp("p1.lo", "p1."+o) + cp("p2.lo", "p2."+o) + cp("p3.lo", "p3."+o) +- out := runFail("go", "tool", "link", "p2."+o) ++ out := runFail(goCmd(), "tool", "link", "p2."+o) + if !strings.Contains(out, "not package main") { + fatalf("link p2.o failed but not for package main:\n%s", out) + } + +- run("go", "tool", "link", "-L", ".", "-o", "a.out.exe", "p3."+o) +- out = run("./a.out.exe") ++ run(goCmd(), "tool", "link", "-L", ".", "-o", "a.out.exe", "p3."+o) ++ out = goRun("./a.out.exe") + if !strings.Contains(out, "hello from p1\nhello from p2\nhello from main\n") { + fatalf("running main, incorrect output:\n%s", out) + } +diff --git test/linkx_run.go test/linkx_run.go +index cc249c9cfc..530159ab9d 100644 +--- test/linkx_run.go ++++ test/linkx_run.go +@@ -1,5 +1,5 @@ + // +build !nacl +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -11,20 +11,40 @@ package main + + import ( + "bytes" ++ "flag" + "fmt" + "os" + "os/exec" + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(args ...string) *exec.Cmd { ++ cmd := []string{"run"} ++ if *target != "" { ++ cmd = append(cmd, "-exec", "go_"+*target+"_exec") ++ } ++ cmd = append(cmd, args...) ++ return exec.Command(goCmd(), cmd...) ++} ++ + func main() { ++ flag.Parse() + // test(" ") // old deprecated & removed syntax + test("=") // new syntax + } + + func test(sep string) { + // Successful run +- cmd := exec.Command("go", "run", "-ldflags=-X main.tbd"+sep+"hello -X main.overwrite"+sep+"trumped -X main.nosuchsymbol"+sep+"neverseen", "linkx.go") ++ cmd := goRun("-ldflags=-X main.tbd"+sep+"hello -X main.overwrite"+sep+"trumped -X main.nosuchsymbol"+sep+"neverseen", "linkx.go") + var out, errbuf bytes.Buffer + cmd.Stdout = &out + cmd.Stderr = &errbuf +@@ -44,7 +64,7 @@ func test(sep string) { + } + + // Issue 8810 +- cmd = exec.Command("go", "run", "-ldflags=-X main.tbd", "linkx.go") ++ cmd = goRun("-ldflags=-X main.tbd", "linkx.go") + _, err = cmd.CombinedOutput() + if err == nil { + fmt.Println("-X linker flag should not accept keys without values") +@@ -52,7 +72,7 @@ func test(sep string) { + } + + // Issue 9621 +- cmd = exec.Command("go", "run", "-ldflags=-X main.b=false -X main.x=42", "linkx.go") ++ cmd = goRun("-ldflags=-X main.b=false -X main.x=42", "linkx.go") + outx, err := cmd.CombinedOutput() + if err == nil { + fmt.Println("-X linker flag should not overwrite non-strings") +diff --git test/nosplit.go test/nosplit.go +index e6cecebde3..fed1c0e510 100644 +--- test/nosplit.go ++++ test/nosplit.go +@@ -1,5 +1,5 @@ + // +build !nacl +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -9,6 +9,7 @@ package main + + import ( + "bytes" ++ "flag" + "fmt" + "io/ioutil" + "log" +@@ -21,6 +22,24 @@ import ( + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goArch() string { ++ goarch, err := exec.Command(goCmd(), "env", "GOARCH").Output() ++ if err != nil { ++ bug() ++ fmt.Printf("running go env GOARCH: %v\n", err) ++ } ++ return strings.TrimSpace(string(goarch)) ++} ++ + var tests = ` + # These are test cases for the linker analysis that detects chains of + # nosplit functions that would cause a stack overflow. +@@ -194,12 +213,13 @@ var ( + ) + + func main() { +- goarch := os.Getenv("GOARCH") ++ flag.Parse() ++ goarch := goArch() + if goarch == "" { +- goarch = runtime.GOARCH ++ return + } + +- version, err := exec.Command("go", "tool", "compile", "-V").Output() ++ version, err := exec.Command(goCmd(), "tool", "compile", "-V").Output() + if err != nil { + bug() + fmt.Printf("running go tool compile -V: %v\n", err) +@@ -345,7 +365,7 @@ TestCases: + log.Fatal(err) + } + +- cmd := exec.Command("go", "build") ++ cmd := exec.Command(goCmd(), "build") + cmd.Dir = dir + output, err := cmd.CombinedOutput() + if err == nil { +diff --git test/run.go test/run.go +index ac5d3c3e8d..62041226b0 100644 +--- test/run.go ++++ test/run.go +@@ -229,6 +229,16 @@ func goRun(runcmd runCmd, flags []string, goname string, args ...string) (out [] + return runcmd(cmd...) + } + ++func goRunTarget(runcmd runCmd, goname string, args ...string) (out []byte, err error) { ++ cmd := []string{"go_local", "run"} ++ cmd = append(cmd, goname) ++ if *target != "" { ++ cmd = append(cmd, "-target", *target) ++ } ++ cmd = append(cmd, args...) ++ return runcmd(cmd...) ++} ++ + // skipError describes why a test was skipped. + type skipError string + +@@ -491,7 +501,7 @@ func (t *test) run() { + action = "rundir" + case "cmpout": + action = "run" // the run case already looks for <dir>/<test>.out files +- case "compile", "compiledir", "build", "builddir", "run", "buildrun", "runoutput", "rundir": ++ case "compile", "compiledir", "build", "builddir", "run", "runtarget", "buildrun", "runoutput", "rundir": + // nothing to do + case "errorcheckandrundir": + wantError = false // should be no error if also will run +@@ -816,6 +826,17 @@ func (t *test) run() { + t.err = fmt.Errorf("incorrect output\n%s", out) + } + ++ case "runtarget": ++ useTmp = false ++ out, err := goRunTarget(runcmd, t.goFileName(), args...) ++ if err != nil { ++ t.err = err ++ return ++ } ++ if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() { ++ t.err = fmt.Errorf("incorrect output\n%s", out) ++ } ++ + case "runoutput": + rungatec <- true + defer func() { +diff --git test/sinit_run.go test/sinit_run.go +index c9afd3b777..dc885ecffd 100644 +--- test/sinit_run.go ++++ test/sinit_run.go +@@ -1,5 +1,5 @@ + // +build !nacl +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -11,13 +11,24 @@ package main + + import ( + "bytes" ++ "flag" + "fmt" + "os" + "os/exec" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ + func main() { +- cmd := exec.Command("go", "tool", "compile", "-S", "sinit.go") ++ flag.Parse() ++ cmd := exec.Command(goCmd(), "tool", "compile", "-S", "sinit.go") + out, err := cmd.CombinedOutput() + if err != nil { + fmt.Println(string(out)) diff --git a/go/patch/go-1.10.3/go4.patch b/go/patch/go-1.10.3/go4.patch new file mode 100644 index 00000000..290de390 --- /dev/null +++ b/go/patch/go-1.10.3/go4.patch @@ -0,0 +1,199 @@ +runtime, crypto/x509: add -target flag. + +--- src/crypto/x509/x509_test.go ++++ src/crypto/x509/x509_test.go +@@ -13,29 +13,32 @@ import ( + "crypto/rsa" + _ "crypto/sha256" + _ "crypto/sha512" + "crypto/x509/pkix" + "encoding/asn1" + "encoding/base64" + "encoding/hex" + "encoding/pem" ++ "flag" + "fmt" + "internal/testenv" + "math/big" + "net" + "net/url" + "os/exec" + "reflect" + "runtime" + "strings" + "testing" + "time" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ + func TestParsePKCS1PrivateKey(t *testing.T) { + block, _ := pem.Decode([]byte(pemPrivateKey)) + priv, err := ParsePKCS1PrivateKey(block.Bytes) + if err != nil { + t.Errorf("Failed to parse private key: %s", err) + return + } + if priv.PublicKey.N.Cmp(rsaPrivateKey.PublicKey.N) != 0 || +@@ -1089,17 +1092,23 @@ func TestParsePEMCRL(t *testing.T) { + } + + // Can't check the signature here without a package cycle. + } + + func TestImports(t *testing.T) { + testenv.MustHaveGoRun(t) + +- if err := exec.Command(testenv.GoToolPath(t), "run", "x509_test_import.go").Run(); err != nil { ++ var cmd *exec.Cmd ++ if *target == "" { ++ cmd = exec.Command(testenv.GoToolPath(t), "run", "x509_test_import.go") ++ } else { ++ cmd = exec.Command("go_"+*target, "run", "-exec", "go_"+*target+"_exec", "x509_test_import.go") ++ } ++ if err := cmd.Run(); err != nil { + t.Errorf("failed to run x509_test_import.go: %s", err) + } + } + + const derCRLBase64 = "MIINqzCCDJMCAQEwDQYJKoZIhvcNAQEFBQAwVjEZMBcGA1UEAxMQUEtJIEZJTk1FQ0NBTklDQTEVMBMGA1UEChMMRklOTUVDQ0FOSUNBMRUwEwYDVQQLEwxGSU5NRUNDQU5JQ0ExCzAJBgNVBAYTAklUFw0xMTA1MDQxNjU3NDJaFw0xMTA1MDQyMDU3NDJaMIIMBzAhAg4Ze1od49Lt1qIXBydAzhcNMDkwNzE2MDg0MzIyWjAAMCECDl0HSL9bcZ1Ci/UHJ0DPFw0wOTA3MTYwODQzMTNaMAAwIQIOESB9tVAmX3cY7QcnQNAXDTA5MDcxNjA4NDUyMlowADAhAg4S1tGAQ3mHt8uVBydA1RcNMDkwODA0MTUyNTIyWjAAMCECDlQ249Y7vtC25ScHJ0DWFw0wOTA4MDQxNTI1MzdaMAAwIQIOISMop3NkA4PfYwcnQNkXDTA5MDgwNDExMDAzNFowADAhAg56/BMoS29KEShTBydA2hcNMDkwODA0MTEwMTAzWjAAMCECDnBp/22HPH5CSWoHJ0DbFw0wOTA4MDQxMDU0NDlaMAAwIQIOV9IP+8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RDQkRRU0IyTVRFdU1Dd0dDU3FHDQpTSWIzRFFFSkFSWWZjbk5oYTJWdmJuSnZiM1J6YVdkdVFISnpZWE5sWTNWeWFYUjVMbU52YlJjTk1URXdNakl6DQpNVGt5T0RNd1doY05NVEV3T0RJeU1Ua3lPRE13V2pDQmpEQktBaEVBckRxb2g5RkhKSFhUN09QZ3V1bjQrQmNODQpNRGt4TVRBeU1UUXlOekE1V2pBbU1Bb0dBMVVkRlFRRENnRUpNQmdHQTFVZEdBUVJHQTh5TURBNU1URXdNakUwDQpNalExTlZvd1BnSVJBTEd6blowOTVQQjVhQU9MUGc1N2ZNTVhEVEF5TVRBeU16RTBOVEF4TkZvd0dqQVlCZ05WDQpIUmdFRVJnUE1qQXdNakV3TWpNeE5EVXdNVFJhb0RBd0xqQWZCZ05WSFNNRUdEQVdnQlQxVERGNlVRTS9MTmVMDQpsNWx2cUhHUXEzZzltekFMQmdOVkhSUUVCQUlDQUlRd0RRWUpLb1pJaHZjTkFRRUZCUUFEZ1lFQUZVNUFzNk16DQpxNVBSc2lmYW9iUVBHaDFhSkx5QytNczVBZ2MwYld5QTNHQWR4dXI1U3BQWmVSV0NCamlQL01FSEJXSkNsQkhQDQpHUmNxNXlJZDNFakRrYUV5eFJhK2k2N0x6dmhJNmMyOUVlNks5cFNZd2ppLzdSVWhtbW5Qclh0VHhsTDBsckxyDQptUVFKNnhoRFJhNUczUUE0Q21VZHNITnZicnpnbUNZcHZWRT0NCi0tLS0tRU5EIFg1MDkgQ1JMLS0tLS0NCg0K" + +--- src/runtime/crash_cgo_test.go ++++ src/runtime/crash_cgo_test.go +@@ -279,17 +279,17 @@ func testCgoPprof(t *testing.T, buildArg, runArg string) { + } + testenv.MustHaveGoRun(t) + + exe, err := buildTestProg(t, "testprogcgo", buildArg) + if err != nil { + t.Fatal(err) + } + +- got, err := testenv.CleanCmdEnv(exec.Command(exe, runArg)).CombinedOutput() ++ got, err := testenv.CleanCmdEnv(goExecCmd(exe, runArg)).CombinedOutput() + if err != nil { + if testenv.Builder() == "linux-amd64-alpine" { + // See Issue 18243 and Issue 19938. + t.Skipf("Skipping failing test on Alpine (golang.org/issue/18243). Ignoring error: %v", err) + } + t.Fatal(err) + } + fn := strings.TrimSpace(string(got)) +--- src/runtime/crash_test.go ++++ src/runtime/crash_test.go +@@ -17,16 +17,35 @@ import ( + "runtime" + "strconv" + "strings" + "sync" + "testing" + "time" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd(t *testing.T) string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return testenv.GoToolPath(t) ++} ++ ++func goExecCmd(name string, arg ...string) *exec.Cmd { ++ var cmd []string ++ if *target != "" { ++ cmd = append(cmd, "go_"+*target+"_exec") ++ } ++ cmd = append(cmd, name) ++ cmd = append(cmd, arg...) ++ return exec.Command(cmd[0], cmd[1:]...) ++} ++ + var toRemove []string + + func TestMain(m *testing.M) { + status := m.Run() + for _, file := range toRemove { + os.RemoveAll(file) + } + os.Exit(status) +@@ -50,17 +69,17 @@ func runTestProg(t *testing.T, binary, name string, env ...string) string { + + testenv.MustHaveGoBuild(t) + + exe, err := buildTestProg(t, binary) + if err != nil { + t.Fatal(err) + } + +- cmd := testenv.CleanCmdEnv(exec.Command(exe, name)) ++ cmd := testenv.CleanCmdEnv(goExecCmd(exe, name)) + cmd.Env = append(cmd.Env, env...) + if testing.Short() { + cmd.Env = append(cmd.Env, "RUNTIME_TEST_SHORT=1") + } + var b bytes.Buffer + cmd.Stdout = &b + cmd.Stderr = &b + if err := cmd.Start(); err != nil { +@@ -125,17 +144,17 @@ func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) + name += "_" + strings.Join(flags, "_") + } + target, ok := testprog.target[name] + if ok { + return target.exe, target.err + } + + exe := filepath.Join(testprog.dir, name+".exe") +- cmd := exec.Command(testenv.GoToolPath(t), append([]string{"build", "-o", exe}, flags...)...) ++ cmd := exec.Command(goCmd(t), append([]string{"build", "-o", exe}, flags...)...) + cmd.Dir = "testdata/" + binary + out, err := testenv.CleanCmdEnv(cmd).CombinedOutput() + if err != nil { + target.err = fmt.Errorf("building %s %v: %v\n%s", binary, flags, err, out) + testprog.target[name] = target + return "", target.err + } + target.exe = exe +@@ -456,17 +475,17 @@ func TestPanicLoop(t *testing.T) { + func TestMemPprof(t *testing.T) { + testenv.MustHaveGoRun(t) + + exe, err := buildTestProg(t, "testprog") + if err != nil { + t.Fatal(err) + } + +- got, err := testenv.CleanCmdEnv(exec.Command(exe, "MemProf")).CombinedOutput() ++ got, err := testenv.CleanCmdEnv(goExecCmd(exe, "MemProf")).CombinedOutput() + if err != nil { + t.Fatal(err) + } + fn := strings.TrimSpace(string(got)) + defer os.Remove(fn) + + for try := 0; try < 2; try++ { + cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), "tool", "pprof", "-alloc_space", "-top")) +--- src/runtime/crash_unix_test.go ++++ src/runtime/crash_unix_test.go +@@ -244,17 +244,17 @@ func testPanicSystemstackInternal() { + } + + func TestSignalExitStatus(t *testing.T) { + testenv.MustHaveGoBuild(t) + exe, err := buildTestProg(t, "testprog") + if err != nil { + t.Fatal(err) + } +- err = testenv.CleanCmdEnv(exec.Command(exe, "SignalExitStatus")).Run() ++ err = testenv.CleanCmdEnv(goExecCmd(exe, "SignalExitStatus")).Run() + if err == nil { + t.Error("test program succeeded unexpectedly") + } else if ee, ok := err.(*exec.ExitError); !ok { + t.Errorf("error (%v) has type %T; expected exec.ExitError", err, err) + } else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok { + t.Errorf("error.Sys (%v) has type %T; expected syscall.WaitStatus", ee.Sys(), ee.Sys()) + } else if !ws.Signaled() || ws.Signal() != syscall.SIGTERM { + t.Errorf("got %v; expected SIGTERM", ee) diff --git a/go/patch/go-1.10.3/go5.patch b/go/patch/go-1.10.3/go5.patch new file mode 100644 index 00000000..658b0346 --- /dev/null +++ b/go/patch/go-1.10.3/go5.patch @@ -0,0 +1,106 @@ +diff --git src/runtime/crash_test.go src/runtime/crash_test.go +index e34f0fa95f..ea1eb4150a 100644 +--- src/runtime/crash_test.go ++++ src/runtime/crash_test.go +@@ -219,22 +219,27 @@ func testDeadlock(t *testing.T, name string) { + } + + func TestSimpleDeadlock(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + testDeadlock(t, "SimpleDeadlock") + } + + func TestInitDeadlock(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + testDeadlock(t, "InitDeadlock") + } + + func TestLockedDeadlock(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + testDeadlock(t, "LockedDeadlock") + } + + func TestLockedDeadlock2(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + testDeadlock(t, "LockedDeadlock2") + } + + func TestGoexitDeadlock(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + output := runTestProg(t, "testprog", "GoexitDeadlock") + want := "no goroutines (main called runtime.Goexit) - deadlock!" + if !strings.Contains(output, want) { +@@ -271,6 +276,7 @@ panic: again + } + + func TestGoexitCrash(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + output := runTestProg(t, "testprog", "GoexitExit") + want := "no goroutines (main called runtime.Goexit) - deadlock!" + if !strings.Contains(output, want) { +@@ -329,6 +335,7 @@ func TestBreakpoint(t *testing.T) { + } + + func TestGoexitInPanic(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + // see issue 8774: this code used to trigger an infinite recursion + output := runTestProg(t, "testprog", "GoexitInPanic") + want := "fatal error: no goroutines (main called runtime.Goexit) - deadlock!" +@@ -393,6 +400,7 @@ func TestPanicAfterGoexit(t *testing.T) { + } + + func TestRecoveredPanicAfterGoexit(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + output := runTestProg(t, "testprog", "RecoveredPanicAfterGoexit") + want := "fatal error: no goroutines (main called runtime.Goexit) - deadlock!" + if !strings.HasPrefix(output, want) { +diff --git src/runtime/proc_test.go src/runtime/proc_test.go +index 2ece829071..942d65eedb 100644 +--- src/runtime/proc_test.go ++++ src/runtime/proc_test.go +@@ -354,9 +354,10 @@ func TestGCFairness2(t *testing.T) { + + func TestNumGoroutine(t *testing.T) { + output := runTestProg(t, "testprog", "NumGoroutine") +- want := "1\n" +- if output != want { +- t.Fatalf("want %q, got %q", want, output) ++ want1 := "1\n" ++ want2 := "2\n" ++ if output != want1 && output != want2 { ++ t.Fatalf("want %q, got %q", want1, output) + } + + buf := make([]byte, 1<<20) +diff --git test/fixedbugs/bug429_run.go test/fixedbugs/bug429_run.go +index e8d18b13e8..6a555286cf 100644 +--- test/fixedbugs/bug429_run.go ++++ test/fixedbugs/bug429_run.go +@@ -1,5 +1,5 @@ + // +build !nacl +-// runtarget ++// skip + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +diff --git test/goprint.go test/goprint.go +index 0648c77e7d..147f0c91db 100644 +--- test/goprint.go ++++ test/goprint.go +@@ -8,14 +8,9 @@ + + package main + +-import ( +- "runtime" +- "time" +-) ++import "time" + + func main() { + go println(42, true, false, true, 1.5, "world", (chan int)(nil), []int(nil), (map[string]int)(nil), (func())(nil), byte(255)) +- for runtime.NumGoroutine() > 1 { +- time.Sleep(10*time.Millisecond) +- } ++ time.Sleep(100*time.Millisecond) + } diff --git a/go/patch/go-1.10.3/go6.patch b/go/patch/go-1.10.3/go6.patch new file mode 100644 index 00000000..5fb512a9 --- /dev/null +++ b/go/patch/go-1.10.3/go6.patch @@ -0,0 +1,142 @@ +diff --git src/encoding/gob/encoder_test.go src/encoding/gob/encoder_test.go +index a1ca252ccd..c66e623499 100644 +--- src/encoding/gob/encoder_test.go ++++ src/encoding/gob/encoder_test.go +@@ -1130,10 +1130,7 @@ func TestBadData(t *testing.T) { + + // TestHugeWriteFails tests that enormous messages trigger an error. + func TestHugeWriteFails(t *testing.T) { +- if testing.Short() { +- // Requires allocating a monster, so don't do this from all.bash. +- t.Skip("skipping huge allocation in short mode") +- } ++ t.Skip("skipping test due to huge memory requirement") + huge := make([]byte, tooBig) + huge[0] = 7 // Make sure it's not all zeros. + buf := new(bytes.Buffer) +diff --git src/runtime/crash_cgo_test.go src/runtime/crash_cgo_test.go +index 998055972a..60fe2a52d2 100644 +--- src/runtime/crash_cgo_test.old ++++ src/runtime/crash_cgo_test.go +@@ -251,10 +251,7 @@ func TestCgoCCodeSIGPROF(t *testing.T) { + } + + func TestCgoCrashTraceback(t *testing.T) { +- t.Parallel() +- if runtime.GOOS != "linux" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "ppc64le") { +- t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH) +- } ++ t.Skipf("skip running remotely") + got := runTestProg(t, "testprogcgo", "CrashTraceback") + for i := 1; i <= 3; i++ { + if !strings.Contains(got, fmt.Sprintf("cgo symbolizer:%d", i)) { +@@ -273,10 +270,7 @@ func TestCgoTracebackContext(t *testing.T) { + } + + func testCgoPprof(t *testing.T, buildArg, runArg string) { +- t.Parallel() +- if runtime.GOOS != "linux" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "ppc64le") { +- t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH) +- } ++ t.Skipf("skip pprof test") + testenv.MustHaveGoRun(t) + + exe, err := buildTestProg(t, "testprogcgo", buildArg) +diff --git src/runtime/crash_test.go src/runtime/crash_test.go +index 3607992788..e53ffb6a81 100644 +--- src/runtime/crash_test.go ++++ src/runtime/crash_test.go +@@ -481,6 +481,7 @@ func TestPanicLoop(t *testing.T) { + } + + func TestMemPprof(t *testing.T) { ++ t.Skipf("skip pprof test") + testenv.MustHaveGoRun(t) + + exe, err := buildTestProg(t, "testprog") +diff --git src/runtime/crash_unix_test.go src/runtime/crash_unix_test.go +index 02891ec1ad..fd2723f16e 100644 +--- src/runtime/crash_unix_test.go ++++ src/runtime/crash_unix_test.go +@@ -174,9 +174,7 @@ func TestPanicSystemstack(t *testing.T) { + // The GOTRACEBACK=crash handler takes 0.1 seconds even if + // it's not writing a core file and potentially much longer if + // it is. Skip in short mode. +- if testing.Short() { +- t.Skip("Skipping in short mode (GOTRACEBACK=crash is slow)") +- } ++ t.Skip("Skipping (GOTRACEBACK=crash hangs on arm)") + + if runtime.Sigisblocked(int(syscall.SIGQUIT)) { + t.Skip("skipping; SIGQUIT is blocked, see golang.org/issue/19196") +@@ -244,6 +242,7 @@ func testPanicSystemstackInternal() { + } + + func TestSignalExitStatus(t *testing.T) { ++ t.Skipf("skip running remotely") + testenv.MustHaveGoBuild(t) + exe, err := buildTestProg(t, "testprog") + if err != nil { +diff --git src/runtime/fastlog2_test.go src/runtime/fastlog2_test.go +index ae0f40b2bb..a93933d7ac 100644 +--- src/runtime/fastlog2_test.go ++++ src/runtime/fastlog2_test.go +@@ -16,11 +16,7 @@ func TestFastLog2(t *testing.T) { + const randomBitCount = 26 + var e float64 + +- inc := 1 +- if testing.Short() { +- // Check 1K total values, down from 64M. +- inc = 1 << 16 +- } ++ inc := 1 << 16 + for i := 1; i < 1<<randomBitCount; i += inc { + l, fl := math.Log2(float64(i)), runtime.Fastlog2(float64(i)) + d := l - fl +diff --git src/runtime/hash_test.go src/runtime/hash_test.go +index 1400579cda..4c5de7fbef 100644 +--- src/runtime/hash_test.go ++++ src/runtime/hash_test.go +@@ -161,9 +161,7 @@ func TestSmhasherZeros(t *testing.T) { + + // Strings with up to two nonzero bytes all have distinct hashes. + func TestSmhasherTwoNonzero(t *testing.T) { +- if testing.Short() { +- t.Skip("Skipping in short mode") +- } ++ t.Skip("skipping test due to huge memory requirement") + h := newHashSet() + for n := 2; n <= 16; n++ { + twoNonZero(h, n) +@@ -264,9 +262,7 @@ func setbits(h *HashSet, b []byte, i int, k int) { + // Test all possible combinations of n blocks from the set s. + // "permutation" is a bad name here, but it is what Smhasher uses. + func TestSmhasherPermutation(t *testing.T) { +- if testing.Short() { +- t.Skip("Skipping in short mode") +- } ++ t.Skip("skipping test due to huge memory requirement") + permutation(t, []uint32{0, 1, 2, 3, 4, 5, 6, 7}, 8) + permutation(t, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 8) + permutation(t, []uint32{0, 1}, 20) +diff --git src/runtime/pprof/pprof_test.go src/runtime/pprof/pprof_test.go +index 44d514393e..f46f00894c 100644 +--- src/runtime/pprof/pprof_test.go ++++ src/runtime/pprof/pprof_test.go +@@ -283,14 +283,7 @@ func profileOk(t *testing.T, need []string, prof bytes.Buffer, duration time.Dur + func TestCPUProfileWithFork(t *testing.T) { + testenv.MustHaveExec(t) + +- heap := 1 << 30 +- if runtime.GOOS == "android" { +- // Use smaller size for Android to avoid crash. +- heap = 100 << 20 +- } +- if testing.Short() { +- heap = 100 << 20 +- } ++ heap = 100 << 20 + // This makes fork slower. + garbage := make([]byte, heap) + // Need to touch the slice, otherwise it won't be paged in. diff --git a/go/patch/go-1.11.2/go0.patch b/go/patch/go-1.11.2/go0.patch new file mode 100644 index 00000000..f80045c0 --- /dev/null +++ b/go/patch/go-1.11.2/go0.patch @@ -0,0 +1,27 @@ +diff --git src/go/build/deps_test.go src/go/build/deps_test.go +index 29dbe47d29..53e0e287bc 100644 +--- src/go/build/deps_test.go ++++ src/go/build/deps_test.go +@@ -191,7 +191,7 @@ var pkgDeps = map[string][]string{ + "testing": {"L2", "flag", "fmt", "internal/race", "os", "runtime/debug", "runtime/pprof", "runtime/trace", "time"}, + "testing/iotest": {"L2", "log"}, + "testing/quick": {"L2", "flag", "fmt", "reflect", "time"}, +- "internal/testenv": {"L2", "OS", "flag", "testing", "syscall"}, ++ "internal/testenv": {"L2", "OS", "os.exec", "flag", "testing", "syscall"}, + + // L4 is defined as L3+fmt+log+time, because in general once + // you're using L3 packages, use of fmt, log, or time is not a big deal. +diff --git src/internal/testenv/testenv.go src/internal/testenv/testenv.go +index 8f69fe0da5..d52b85e122 100644 +--- src/internal/testenv/testenv.go ++++ src/internal/testenv/testenv.go +@@ -48,6 +48,9 @@ func HasGoBuild() bool { + return false + } + } ++ if _, err := exec.LookPath("go"); err != nil { ++ return false ++ } + return true + } + diff --git a/go/patch/go-1.11.2/go1.patch b/go/patch/go-1.11.2/go1.patch new file mode 100644 index 00000000..e05fcce4 --- /dev/null +++ b/go/patch/go-1.11.2/go1.patch @@ -0,0 +1,50 @@ +diff --git test/chanlinear.go test/chanlinear.go +index 55fee4ab9b..89533da282 100644 +--- test/chanlinear.go ++++ test/chanlinear.go +@@ -1,4 +1,4 @@ +-// +build darwin linux ++// +build darwin linux android + // run + + // Copyright 2014 The Go Authors. All rights reserved. +diff --git a/test/fixedbugs/bug385_64.go b/test/fixedbugs/bug385_64.go +index 0f941ca2f4..3bcd62f3ad 100644 +--- test/fixedbugs/bug385_64.go ++++ test/fixedbugs/bug385_64.go +@@ -1,4 +1,4 @@ +-// +build amd64 ++// +build amd64 arm64 + // errorcheck + + // Copyright 2011 The Go Authors. All rights reserved. +diff --git test/fixedbugs/issue10607.go test/fixedbugs/issue10607.go +index 8831547da8..9ee6c72bc6 100644 +--- test/fixedbugs/issue10607.go ++++ test/fixedbugs/issue10607.go +@@ -1,4 +1,4 @@ +-// +build linux,!ppc64 ++// +build linux,!ppc64 android + // run + + // Copyright 2015 The Go Authors. All rights reserved. +diff --git test/maplinear.go test/maplinear.go +index 34d0914914..afddab627d 100644 +--- test/maplinear.go ++++ test/maplinear.go +@@ -1,4 +1,4 @@ +-// +build darwin linux ++// +build darwin linux android + // run + + // Copyright 2013 The Go Authors. All rights reserved. +diff --git test/recover4.go test/recover4.go +index 67ed970ecb..95a89dab00 100644 +--- test/recover4.go ++++ test/recover4.go +@@ -1,4 +1,4 @@ +-// +build linux darwin ++// +build linux android darwin + // run + + // Copyright 2015 The Go Authors. All rights reserved. diff --git a/go/patch/go-1.11.2/go2.patch b/go/patch/go-1.11.2/go2.patch new file mode 100644 index 00000000..362a53fe --- /dev/null +++ b/go/patch/go-1.11.2/go2.patch @@ -0,0 +1,277 @@ +diff --git test/run.go test/run.go +index ad38d420c9..e2b93d35da 100644 +--- test/run.go ++++ test/run.go +@@ -36,13 +36,13 @@ var ( + summary = flag.Bool("summary", false, "show summary of results") + showSkips = flag.Bool("show_skips", false, "show skipped tests") + runSkips = flag.Bool("run_skips", false, "run skipped tests (ignore skip and build tags)") +- linkshared = flag.Bool("linkshared", false, "") + updateErrors = flag.Bool("update_errors", false, "update error messages in test file based on compiler output") + runoutputLimit = flag.Int("l", defaultRunOutputLimit(), "number of parallel runoutput tests to run") + + shard = flag.Int("shard", 0, "shard index to run. Only applicable if -shards is non-zero.") + shards = flag.Int("shards", 0, "number of shards. If 0, all tests are run. This is used by the continuous build.") + ) ++ target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") + + var ( + goos, goarch string +@@ -207,25 +207,19 @@ func goFiles(dir string) []string { + type runCmd func(...string) ([]byte, error) + + func compileFile(runcmd runCmd, longname string, flags []string) (out []byte, err error) { +- cmd := []string{goTool(), "tool", "compile", "-e"} ++ cmd := []string{findGoCmd, "tool", "compile", "-e"} + cmd = append(cmd, flags...) +- if *linkshared { +- cmd = append(cmd, "-dynlink", "-installsuffix=dynlink") +- } + cmd = append(cmd, longname) + return runcmd(cmd...) + } + + func compileInDir(runcmd runCmd, dir string, flags []string, localImports bool, names ...string) (out []byte, err error) { +- cmd := []string{goTool(), "tool", "compile", "-e"} ++ cmd := []string{findGoCmd(), "tool", "compile", "-e"} + if localImports { + // Set relative path for local imports and import search path to current dir. + cmd = append(cmd, "-D", ".", "-I", ".") + } + cmd = append(cmd, flags...) +- if *linkshared { +- cmd = append(cmd, "-dynlink", "-installsuffix=dynlink") +- } + for _, name := range names { + cmd = append(cmd, filepath.Join(dir, name)) + } +@@ -234,15 +228,28 @@ func compileInDir(runcmd runCmd, dir string, flags []string, localImports bool, + + func linkFile(runcmd runCmd, goname string) (err error) { + pfile := strings.Replace(goname, ".go", ".o", -1) +- cmd := []string{goTool(), "tool", "link", "-w", "-o", "a.exe", "-L", "."} ++ cmd := []string{findGoCmd(), "tool", "link", "-w", "-o", "a.exe", "-L", "."} + if *linkshared { + cmd = append(cmd, "-linkshared", "-installsuffix=dynlink") + } + cmd = append(cmd, pfile) +- _, err = runcmd(cmd...) ++ _, err = runcmd(findGoCmd(), "tool", "link", "-w", "-o", "a.exe", "-L", ".", pfile) + return + } + ++ ++func goRun(runcmd runCmd, flags []string, goname string, args ...string) (out []byte, err error) { ++ cmd := []string{findGoCmd(), "run", goGcflags()} ++ if len(findExecCmd()) > 0 { ++ cmd = append(cmd, "-exec") ++ cmd = append(cmd, findExecCmd()...) ++ } ++ cmd = append(cmd, flags...) ++ cmd = append(cmd, goname) ++ cmd = append(cmd, args...) ++ return runcmd(cmd...) ++} ++ + // skipError describes why a test was skipped. + type skipError string + +@@ -646,7 +653,7 @@ func (t *test) run() { + // Fail if wantError is true and compilation was successful and vice versa. + // Match errors produced by gc against errors in comments. + // TODO(gri) remove need for -C (disable printing of columns in error messages) +- cmdline := []string{goTool(), "tool", "compile", "-C", "-e", "-o", "a.o"} ++ cmdline := []string{findGoCmd(), "tool", "compile", "-C", "-e", "-o", "a.o"} + // No need to add -dynlink even if linkshared if we're just checking for errors... + cmdline = append(cmdline, flags...) + cmdline = append(cmdline, long) +@@ -773,7 +780,7 @@ func (t *test) run() { + + case "build": + // Build Go file. +- _, err := runcmd(goTool(), "build", goGcflags(), "-o", "a.exe", long) ++ _, err := runcmd(findGoCmd(), "build", goGcflags(), "-o", "a.exe", long) + if err != nil { + t.err = err + } +@@ -799,7 +806,7 @@ func (t *test) run() { + + } + var objs []string +- cmd := []string{goTool(), "tool", "compile", "-e", "-D", ".", "-I", ".", "-o", "go.o"} ++ cmd := []string{findGoCmd(), "tool", "compile", "-e", "-D", ".", "-I", ".", "-o", "go.o"} + if len(asms) > 0 { + cmd = append(cmd, "-asmhdr", "go_asm.h") + } +@@ -813,7 +820,7 @@ func (t *test) run() { + } + objs = append(objs, "go.o") + if len(asms) > 0 { +- cmd = []string{goTool(), "tool", "asm", "-e", "-I", ".", "-o", "asm.o"} ++ cmd = []string{findGoCmd(), "tool", "asm", "-e", "-I", ".", "-o", "asm.o"} + for _, file := range asms { + cmd = append(cmd, filepath.Join(longdir, file.Name())) + } +@@ -857,14 +864,14 @@ func (t *test) run() { + } + objs = append(objs, "asm.o") + } +- cmd = []string{goTool(), "tool", "pack", "c", "all.a"} ++ cmd = []string{findGoCmd(), "tool", "pack", "c", "all.a"} + cmd = append(cmd, objs...) + _, err = runcmd(cmd...) + if err != nil { + t.err = err + break + } +- cmd = []string{goTool(), "tool", "link", "-o", "a.exe", "all.a"} ++ cmd = []string{findGoCmd(), "tool", "link", "-o", "a.exe", "all.a"} + _, err = runcmd(cmd...) + if err != nil { + t.err = err +@@ -886,10 +893,7 @@ func (t *test) run() { + // Build an executable from Go file, then run it, verify its output. + // Useful for timeout tests where failure mode is infinite loop. + // TODO: not supported on NaCl +- cmd := []string{goTool(), "build", goGcflags(), "-o", "a.exe"} +- if *linkshared { +- cmd = append(cmd, "-linkshared") +- } ++ cmd := []string{findGoCmd(), "build", goGcflags(), "-o", "a.exe"} + longdirgofile := filepath.Join(filepath.Join(cwd, t.dir), t.gofile) + cmd = append(cmd, flags...) + cmd = append(cmd, longdirgofile) +@@ -898,8 +902,13 @@ func (t *test) run() { + t.err = err + return + } +- cmd = []string{"./a.exe"} +- out, err = runcmd(append(cmd, args...)...) ++ cmd = []string{} ++ if len(findExecCmd()) > 0 { ++ cmd = append(cmd, findExecCmd()...) ++ } ++ cmd = append(cmd, "./a.exe") ++ ++ out, err = runcmd(append(cmd, args...)...) + if err != nil { + t.err = err + return +@@ -914,38 +923,7 @@ func (t *test) run() { + // otherwise build an executable and run it. + // Verify the output. + useTmp = false +- var out []byte +- var err error +- if len(flags)+len(args) == 0 && goGcflags() == "" && !*linkshared { +- // If we're not using special go command flags, +- // skip all the go command machinery. +- // This avoids any time the go command would +- // spend checking whether, for example, the installed +- // package runtime is up to date. +- // Because we run lots of trivial test programs, +- // the time adds up. +- pkg := filepath.Join(t.tempDir, "pkg.a") +- if _, err := runcmd(goTool(), "tool", "compile", "-o", pkg, t.goFileName()); err != nil { +- t.err = err +- return +- } +- exe := filepath.Join(t.tempDir, "test.exe") +- cmd := []string{goTool(), "tool", "link", "-s", "-w"} +- cmd = append(cmd, "-o", exe, pkg) +- if _, err := runcmd(cmd...); err != nil { +- t.err = err +- return +- } +- out, err = runcmd(append([]string{exe}, args...)...) +- } else { +- cmd := []string{goTool(), "run", goGcflags()} +- if *linkshared { +- cmd = append(cmd, "-linkshared") +- } +- cmd = append(cmd, flags...) +- cmd = append(cmd, t.goFileName()) +- out, err = runcmd(append(cmd, args...)...) +- } ++ out, err := goRun(runcmd, flags, t.goFileName(), args...) + if err != nil { + t.err = err + return +@@ -962,12 +940,7 @@ func (t *test) run() { + <-rungatec + }() + useTmp = false +- cmd := []string{goTool(), "run", goGcflags()} +- if *linkshared { +- cmd = append(cmd, "-linkshared") +- } +- cmd = append(cmd, t.goFileName()) +- out, err := runcmd(append(cmd, args...)...) ++ out, err := goRun(runcmd, nil, t.goFileName(), args...) + if err != nil { + t.err = err + return +@@ -977,12 +950,7 @@ func (t *test) run() { + t.err = fmt.Errorf("write tempfile:%s", err) + return + } +- cmd = []string{goTool(), "run", goGcflags()} +- if *linkshared { +- cmd = append(cmd, "-linkshared") +- } +- cmd = append(cmd, tfile) +- out, err = runcmd(cmd...) ++ out, err = goRun(runcmd, nil, tfile) + if err != nil { + t.err = err + return +@@ -995,12 +963,7 @@ func (t *test) run() { + // Run Go file and write its output into temporary Go file. + // Compile and errorCheck generated Go file. + useTmp = false +- cmd := []string{goTool(), "run", goGcflags()} +- if *linkshared { +- cmd = append(cmd, "-linkshared") +- } +- cmd = append(cmd, t.goFileName()) +- out, err := runcmd(append(cmd, args...)...) ++ out, err := goRun(runcmd, nil, t.goFileName(), args...) + if err != nil { + t.err = err + return +@@ -1011,7 +974,7 @@ func (t *test) run() { + t.err = fmt.Errorf("write tempfile:%s", err) + return + } +- cmdline := []string{goTool(), "tool", "compile", "-e", "-o", "a.o"} ++ cmdline := []string{findGoCmd(), "tool", "compile", "-e", "-o", "a.o"} + cmdline = append(cmdline, flags...) + cmdline = append(cmdline, tfile) + out, err = runcmd(cmdline...) +@@ -1038,6 +1001,11 @@ func findExecCmd() []string { + return execCmd + } + execCmd = []string{} // avoid work the second time ++ if *target != "" { ++ execCmd = []string{"go_" + *target + "_exec"} ++ return execCmd ++ } ++ + if goos == runtime.GOOS && goarch == runtime.GOARCH { + return execCmd + } +@@ -1048,6 +1016,14 @@ func findExecCmd() []string { + return execCmd + } + ++func findGoCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++ + func (t *test) String() string { + return filepath.Join(t.dir, t.gofile) + } diff --git a/go/patch/go-1.11.2/go3.patch b/go/patch/go-1.11.2/go3.patch new file mode 100644 index 00000000..c97cd302 --- /dev/null +++ b/go/patch/go-1.11.2/go3.patch @@ -0,0 +1,730 @@ +diff --git test/fixedbugs/bug302.go test/fixedbugs/bug302.go +index c763b87786..470841f676 100644 +--- test/fixedbugs/bug302.go ++++ test/fixedbugs/bug302.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js +-// run ++// runtarget + + // Copyright 2010 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -8,16 +8,28 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" + "path/filepath" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++ + func main() { +- run("go", "tool", "compile", filepath.Join("fixedbugs", "bug302.dir", "p.go")) +- run("go", "tool", "pack", "grc", "pp.a", "p.o") +- run("go", "tool", "compile", "-I", ".", filepath.Join("fixedbugs", "bug302.dir", "main.go")) ++ flag.Parse() ++ run(goCmd(), "tool", "compile", filepath.Join("fixedbugs", "bug302.dir", "p.go")) ++ run(goCmd(), "tool", "pack", "grc", "pp.a", "p.o") ++ run(goCmd(), "tool", "compile", "-I", ".", filepath.Join("fixedbugs", "bug302.dir", "main.go")) + os.Remove("p.o") + os.Remove("pp.a") + os.Remove("main.o") +diff --git test/fixedbugs/bug369.go test/fixedbugs/bug369.go +index e2a1147735..769364d503 100644 +--- test/fixedbugs/bug369.go ++++ test/fixedbugs/bug369.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js,!windows +-// run ++// runtarget + + // Copyright 2011 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -10,21 +10,40 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" + "path/filepath" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(cmd ...string) { ++ if *target == "" { ++ run(cmd[0], cmd[1:]...) ++ } else { ++ run("go_"+*target+"_exec", cmd...) ++ } ++} ++ + func main() { ++ flag.Parse() + err := os.Chdir(filepath.Join(".", "fixedbugs", "bug369.dir")) + check(err) + +- run("go", "tool", "compile", "-N", "-o", "slow.o", "pkg.go") +- run("go", "tool", "compile", "-o", "fast.o", "pkg.go") +- run("go", "tool", "compile", "-o", "main.o", "main.go") +- run("go", "tool", "link", "-o", "a.exe", "main.o") +- run("." + string(filepath.Separator) + "a.exe") ++ run(goCmd(), "tool", "compile", "-N", "-o", "slow.o", "pkg.go") ++ run(goCmd(), "tool", "compile", "-o", "fast.o", "pkg.go") ++ run(goCmd(), "tool", "compile", "-o", "main.o", "main.go") ++ run(goCmd(), "tool", "link", "-o", "a.exe", "main.o") ++ goRun("." + string(filepath.Separator) + "a.exe") + + os.Remove("slow.o") + os.Remove("fast.o") +diff --git test/fixedbugs/bug429_run.go test/fixedbugs/bug429_run.go +index c6a02aae5e..30298de97b 100644 +--- test/fixedbugs/bug429_run.go ++++ test/fixedbugs/bug429_run.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -10,6 +10,7 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" +@@ -17,8 +18,27 @@ import ( + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(args ...string) *exec.Cmd { ++ cmd := []string{"run"} ++ if *target != "" { ++ cmd = append(cmd, "-exec", "go_"+*target+"_exec") ++ } ++ cmd = append(cmd, args...) ++ return exec.Command(goCmd(), cmd...) ++} ++ + func main() { +- cmd := exec.Command("go", "run", filepath.Join("fixedbugs", "bug429.go")) ++ flag.Parse() ++ cmd := goRun(filepath.Join("fixedbugs", "bug429.go")) + out, err := cmd.CombinedOutput() + if err == nil { + fmt.Println("expected deadlock") +diff --git test/fixedbugs/issue10607.go test/fixedbugs/issue10607.go +index 9ee6c72bc6..e819a3085a 100644 +--- test/fixedbugs/issue10607.go ++++ test/fixedbugs/issue10607.go +@@ -1,5 +1,5 @@ + // +build linux,!ppc64 android +-// run ++// runtarget + + // Copyright 2015 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -11,19 +11,39 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" + "path/filepath" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(args ...string) *exec.Cmd { ++ cmd := []string{"run"} ++ if *target != "" { ++ cmd = append(cmd, "-exec", "go_"+*target+"_exec") ++ } ++ cmd = append(cmd, args...) ++ return exec.Command(goCmd(), cmd...) ++} ++ + func main() { +- test("internal") ++ flag.Parse() ++ //test("internal") + test("external") + } + + func test(linkmode string) { +- out, err := exec.Command("go", "run", "-ldflags", "-B=0x12345678 -linkmode="+linkmode, filepath.Join("fixedbugs", "issue10607a.go")).CombinedOutput() ++ out, err := goRun("-ldflags", "-B=0x12345678 -linkmode="+linkmode, filepath.Join("fixedbugs", "issue10607a.go")).CombinedOutput() + if err != nil { + fmt.Printf("BUG: linkmode=%s %v\n%s\n", linkmode, err, out) + os.Exit(1) +diff --git test/fixedbugs/issue11771.go test/fixedbugs/issue11771.go +index 99d7060d44..777cb7b9c4 100644 +--- test/fixedbugs/issue11771.go ++++ test/fixedbugs/issue11771.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js +-// run ++// runtarget + + // Copyright 2015 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -11,6 +11,7 @@ package main + + import ( + "bytes" ++ "flag" + "fmt" + "io/ioutil" + "log" +@@ -19,8 +20,17 @@ import ( + "path/filepath" + "runtime" + ) ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} + + func main() { ++ flag.Parse() + if runtime.Compiler != "gc" { + return + } +@@ -52,7 +62,7 @@ func x() { + log.Fatal(err) + } + +- cmd := exec.Command("go", "tool", "compile", "x.go") ++ cmd := exec.Command(goCmd(), "tool", "compile", "x.go") + cmd.Dir = dir + output, err := cmd.CombinedOutput() + if err == nil { +diff --git test/fixedbugs/issue9355.go test/fixedbugs/issue9355.go +index 9657e64491..bad099f440 100644 +--- test/fixedbugs/issue9355.go ++++ test/fixedbugs/issue9355.go +@@ -1,4 +1,4 @@ +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -7,6 +7,7 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" +@@ -15,7 +16,17 @@ import ( + "runtime" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ + func main() { ++ flag.Parse() + if runtime.Compiler != "gc" || runtime.GOOS == "nacl" || runtime.GOOS == "js" { + return + } +@@ -23,7 +34,7 @@ func main() { + err := os.Chdir(filepath.Join("fixedbugs", "issue9355.dir")) + check(err) + +- out := run("go", "tool", "compile", "-S", "a.go") ++ out := run(goCmd(), "tool", "compile", "-S", "a.go") + os.Remove("a.o") + + // 6g/8g print the offset as dec, but 5g/9g print the offset as hex. +diff --git test/fixedbugs/issue9862_run.go test/fixedbugs/issue9862_run.go +index 299e809545..02b8ea83c2 100644 +--- test/fixedbugs/issue9862_run.go ++++ test/fixedbugs/issue9862_run.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js +-// run ++// runtarget + + // Copyright 2015 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -10,12 +10,32 @@ + package main + + import ( ++ "flag" + "os/exec" + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(args ...string) *exec.Cmd { ++ cmd := []string{"run"} ++ if *target != "" { ++ cmd = append(cmd, "-exec", "go_"+*target+"_exec") ++ } ++ cmd = append(cmd, args...) ++ return exec.Command(goCmd(), cmd...) ++} ++ + func main() { +- out, err := exec.Command("go", "run", "fixedbugs/issue9862.go").CombinedOutput() ++ flag.Parse() ++ out, err := goRun("fixedbugs/issue9862.go").CombinedOutput() + outstr := string(out) + if err == nil { + println("go run issue9862.go succeeded, should have failed\n", outstr) +diff --git test/linkmain_run.go test/linkmain_run.go +index 68d53e8cad..0aa5e0fe2d 100644 +--- test/linkmain_run.go ++++ test/linkmain_run.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -10,12 +10,22 @@ + package main + + import ( ++ "flag" + "fmt" + "os" + "os/exec" + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ + func cleanup() { + os.Remove("linkmain.o") + os.Remove("linkmain.a") +@@ -51,16 +61,18 @@ func runFail(cmdline string) { + } + + func main() { ++ flag.Parse() ++ + // helloworld.go is package main +- run("go tool compile -o linkmain.o helloworld.go") +- run("go tool compile -pack -o linkmain.a helloworld.go") +- run("go tool link -o linkmain.exe linkmain.o") +- run("go tool link -o linkmain.exe linkmain.a") ++ run(goCmd() + " tool compile -o linkmain.o helloworld.go") ++ run(goCmd() + " tool compile -pack -o linkmain.a helloworld.go") ++ run(goCmd() + " tool link -o linkmain.exe linkmain.o") ++ run(goCmd() + " tool link -o linkmain.exe linkmain.a") + + // linkmain.go is not +- run("go tool compile -o linkmain1.o linkmain.go") +- run("go tool compile -pack -o linkmain1.a linkmain.go") +- runFail("go tool link -o linkmain.exe linkmain1.o") +- runFail("go tool link -o linkmain.exe linkmain1.a") ++ run(goCmd() + " tool compile -o linkmain1.o linkmain.go") ++ run(goCmd() + " tool compile -pack -o linkmain1.a linkmain.go") ++ runFail(goCmd() + " tool link -o linkmain.exe linkmain1.o") ++ runFail(goCmd() + " tool link -o linkmain.exe linkmain1.a") + cleanup() + } +diff --git test/linkobj.go test/linkobj.go +index 2902d23f4b..c17dfd3da9 100644 +--- test/linkobj.go ++++ test/linkobj.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js +-// run ++// runtarget + + // Copyright 2016 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -10,6 +10,7 @@ + package main + + import ( ++ "flag" + "fmt" + "io/ioutil" + "log" +@@ -18,9 +19,27 @@ import ( + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(cmd ...string) string { ++ if *target == "" { ++ return run(cmd...) ++ } else { ++ return run(append([]string{"go_"+*target+"_exec"}, cmd...)...) ++ } ++} ++ + var pwd, tmpdir string + + func main() { ++ flag.Parse() + dir, err := ioutil.TempDir("", "go-test-linkobj-") + if err != nil { + log.Fatal(err) +@@ -37,28 +56,28 @@ func main() { + + writeFile("p1.go", ` + package p1 +- ++ + func F() { + println("hello from p1") + } + `) + writeFile("p2.go", ` + package p2 +- ++ + import "./p1" + + func F() { + p1.F() + println("hello from p2") + } +- ++ + func main() {} + `) + writeFile("p3.go", ` + package main + + import "./p2" +- ++ + func main() { + p2.F() + println("hello from main") +@@ -76,9 +95,9 @@ func main() { + } + + // inlining is disabled to make sure that the link objects contain needed code. +- run("go", "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p1."+o, "-linkobj", "p1.lo", "p1.go") +- run("go", "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p2."+o, "-linkobj", "p2.lo", "p2.go") +- run("go", "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p3."+o, "-linkobj", "p3.lo", "p3.go") ++ run(goCmd(), "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p1."+o, "-linkobj", "p1.lo", "p1.go") ++ run(goCmd(), "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p2."+o, "-linkobj", "p2.lo", "p2.go") ++ run(goCmd(), "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p3."+o, "-linkobj", "p3.lo", "p3.go") + + cp("p1."+o, "p1.oo") + cp("p2."+o, "p2.oo") +@@ -86,13 +105,13 @@ func main() { + cp("p1.lo", "p1."+o) + cp("p2.lo", "p2."+o) + cp("p3.lo", "p3."+o) +- out := runFail("go", "tool", "link", "p2."+o) ++ out := runFail(goCmd(), "tool", "link", "p2."+o) + if !strings.Contains(out, "not package main") { + fatalf("link p2.o failed but not for package main:\n%s", out) + } + +- run("go", "tool", "link", "-L", ".", "-o", "a.out.exe", "p3."+o) +- out = run("./a.out.exe") ++ run(goCmd(), "tool", "link", "-L", ".", "-o", "a.out.exe", "p3."+o) ++ out = goRun("./a.out.exe") + if !strings.Contains(out, "hello from p1\nhello from p2\nhello from main\n") { + fatalf("running main, incorrect output:\n%s", out) + } +diff --git test/linkx_run.go test/linkx_run.go +index ca9d31612a..631b95ee67 100644 +--- test/linkx_run.go ++++ test/linkx_run.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -11,20 +11,40 @@ package main + + import ( + "bytes" ++ "flag" + "fmt" + "os" + "os/exec" + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goRun(args ...string) *exec.Cmd { ++ cmd := []string{"run"} ++ if *target != "" { ++ cmd = append(cmd, "-exec", "go_"+*target+"_exec") ++ } ++ cmd = append(cmd, args...) ++ return exec.Command(goCmd(), cmd...) ++} ++ + func main() { ++ flag.Parse() + // test(" ") // old deprecated & removed syntax + test("=") // new syntax + } + + func test(sep string) { + // Successful run +- cmd := exec.Command("go", "run", "-ldflags=-X main.tbd"+sep+"hello -X main.overwrite"+sep+"trumped -X main.nosuchsymbol"+sep+"neverseen", "linkx.go") ++ cmd := goRun("-ldflags=-X main.tbd"+sep+"hello -X main.overwrite"+sep+"trumped -X main.nosuchsymbol"+sep+"neverseen", "linkx.go") + var out, errbuf bytes.Buffer + cmd.Stdout = &out + cmd.Stderr = &errbuf +@@ -44,7 +64,7 @@ func test(sep string) { + } + + // Issue 8810 +- cmd = exec.Command("go", "run", "-ldflags=-X main.tbd", "linkx.go") ++ cmd = goRun("-ldflags=-X main.tbd", "linkx.go") + _, err = cmd.CombinedOutput() + if err == nil { + fmt.Println("-X linker flag should not accept keys without values") +@@ -52,7 +72,7 @@ func test(sep string) { + } + + // Issue 9621 +- cmd = exec.Command("go", "run", "-ldflags=-X main.b=false -X main.x=42", "linkx.go") ++ cmd = goRun("-ldflags=-X main.b=false -X main.x=42", "linkx.go") + outx, err := cmd.CombinedOutput() + if err == nil { + fmt.Println("-X linker flag should not overwrite non-strings") +diff --git test/nosplit.go test/nosplit.go +index e6cd04e563..baeea80e37 100644 +--- test/nosplit.go ++++ test/nosplit.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -9,6 +9,7 @@ package main + + import ( + "bytes" ++ "flag" + "fmt" + "io/ioutil" + "log" +@@ -21,6 +22,24 @@ import ( + "strings" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ ++func goArch() string { ++ goarch, err := exec.Command(goCmd(), "env", "GOARCH").Output() ++ if err != nil { ++ bug() ++ fmt.Printf("running go env GOARCH: %v\n", err) ++ } ++ return strings.TrimSpace(string(goarch)) ++} ++ + var tests = ` + # These are test cases for the linker analysis that detects chains of + # nosplit functions that would cause a stack overflow. +@@ -194,12 +213,13 @@ var ( + ) + + func main() { +- goarch := os.Getenv("GOARCH") ++ flag.Parse() ++ goarch := goArch() + if goarch == "" { +- goarch = runtime.GOARCH ++ return + } + +- version, err := exec.Command("go", "tool", "compile", "-V").Output() ++ version, err := exec.Command(goCmd(), "tool", "compile", "-V").Output() + if err != nil { + bug() + fmt.Printf("running go tool compile -V: %v\n", err) +@@ -345,7 +365,7 @@ TestCases: + log.Fatal(err) + } + +- cmd := exec.Command("go", "build") ++ cmd := exec.Command(goCmd(), "build") + cmd.Dir = dir + output, err := cmd.CombinedOutput() + if err == nil { +diff --git test/run.go test/run.go +index 2af3ee43ba..28c87c3583 100644 +--- test/run.go ++++ test/run.go +@@ -246,6 +246,16 @@ func goRun(runcmd runCmd, flags []string, goname string, args ...string) (out [] + } + + ++func goRunTarget(runcmd runCmd, goname string, args ...string) (out []byte, err error) { ++ cmd := []string{"go_local", "run"} ++ cmd = append(cmd, goname) ++ if *target != "" { ++ cmd = append(cmd, "-target", *target) ++ } ++ cmd = append(cmd, args...) ++ return runcmd(cmd...) ++} ++ + // skipError describes why a test was skipped. + type skipError string + +@@ -505,7 +515,7 @@ func (t *test) run() { + + // TODO: Clean up/simplify this switch statement. + switch action { +- case "compile", "compiledir", "build", "builddir", "buildrundir", "run", "buildrun", "runoutput", "rundir", "asmcheck": ++ case "compile", "compiledir", "build", "builddir", "buildrundir", "run", "runtarget", "buildrun", "runoutput", "rundir", "asmcheck": + // nothing to do + case "errorcheckandrundir": + wantError = false // should be no error if also will run +@@ -894,6 +904,17 @@ func (t *test) run() { + t.err = fmt.Errorf("incorrect output\n%s", out) + } + ++ case "runtarget": ++ useTmp = false ++ out, err := goRunTarget(runcmd, t.goFileName(), args...) ++ if err != nil { ++ t.err = err ++ return ++ } ++ if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() { ++ t.err = fmt.Errorf("incorrect output\n%s", out) ++ } ++ + case "runoutput": + // Run Go file and write its output into temporary Go file. + // Run generated Go file and verify its output. +diff --git test/sinit_run.go test/sinit_run.go +index fdd19c492f..0b3cb76083 100644 +--- test/sinit_run.go ++++ test/sinit_run.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js +-// run ++// runtarget + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +@@ -11,11 +11,21 @@ package main + + import ( + "bytes" ++ "flag" + "fmt" + "os" + "os/exec" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd() string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return "go" ++} ++ + func main() { + cmd := exec.Command("go", "tool", "compile", "-S", "sinit.go") + out, err := cmd.CombinedOutput() diff --git a/go/patch/go-1.11.2/go4.patch b/go/patch/go-1.11.2/go4.patch new file mode 100644 index 00000000..290de390 --- /dev/null +++ b/go/patch/go-1.11.2/go4.patch @@ -0,0 +1,199 @@ +runtime, crypto/x509: add -target flag. + +--- src/crypto/x509/x509_test.go ++++ src/crypto/x509/x509_test.go +@@ -13,29 +13,32 @@ import ( + "crypto/rsa" + _ "crypto/sha256" + _ "crypto/sha512" + "crypto/x509/pkix" + "encoding/asn1" + "encoding/base64" + "encoding/hex" + "encoding/pem" ++ "flag" + "fmt" + "internal/testenv" + "math/big" + "net" + "net/url" + "os/exec" + "reflect" + "runtime" + "strings" + "testing" + "time" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ + func TestParsePKCS1PrivateKey(t *testing.T) { + block, _ := pem.Decode([]byte(pemPrivateKey)) + priv, err := ParsePKCS1PrivateKey(block.Bytes) + if err != nil { + t.Errorf("Failed to parse private key: %s", err) + return + } + if priv.PublicKey.N.Cmp(rsaPrivateKey.PublicKey.N) != 0 || +@@ -1089,17 +1092,23 @@ func TestParsePEMCRL(t *testing.T) { + } + + // Can't check the signature here without a package cycle. + } + + func TestImports(t *testing.T) { + testenv.MustHaveGoRun(t) + +- if err := exec.Command(testenv.GoToolPath(t), "run", "x509_test_import.go").Run(); err != nil { ++ var cmd *exec.Cmd ++ if *target == "" { ++ cmd = exec.Command(testenv.GoToolPath(t), "run", "x509_test_import.go") ++ } else { ++ cmd = exec.Command("go_"+*target, "run", "-exec", "go_"+*target+"_exec", "x509_test_import.go") ++ } ++ if err := cmd.Run(); err != nil { + t.Errorf("failed to run x509_test_import.go: %s", err) + } + } + + const derCRLBase64 = "MIINqzCCDJMCAQEwDQYJKoZIhvcNAQEFBQAwVjEZMBcGA1UEAxMQUEtJIEZJTk1FQ0NBTklDQTEVMBMGA1UEChMMRklOTUVDQ0FOSUNBMRUwEwYDVQQLEwxGSU5NRUNDQU5JQ0ExCzA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NCamlQL01FSEJXSkNsQkhQDQpHUmNxNXlJZDNFakRrYUV5eFJhK2k2N0x6dmhJNmMyOUVlNks5cFNZd2ppLzdSVWhtbW5Qclh0VHhsTDBsckxyDQptUVFKNnhoRFJhNUczUUE0Q21VZHNITnZicnpnbUNZcHZWRT0NCi0tLS0tRU5EIFg1MDkgQ1JMLS0tLS0NCg0K" + +--- src/runtime/crash_cgo_test.go ++++ src/runtime/crash_cgo_test.go +@@ -279,17 +279,17 @@ func testCgoPprof(t *testing.T, buildArg, runArg string) { + } + testenv.MustHaveGoRun(t) + + exe, err := buildTestProg(t, "testprogcgo", buildArg) + if err != nil { + t.Fatal(err) + } + +- got, err := testenv.CleanCmdEnv(exec.Command(exe, runArg)).CombinedOutput() ++ got, err := testenv.CleanCmdEnv(goExecCmd(exe, runArg)).CombinedOutput() + if err != nil { + if testenv.Builder() == "linux-amd64-alpine" { + // See Issue 18243 and Issue 19938. + t.Skipf("Skipping failing test on Alpine (golang.org/issue/18243). Ignoring error: %v", err) + } + t.Fatal(err) + } + fn := strings.TrimSpace(string(got)) +--- src/runtime/crash_test.go ++++ src/runtime/crash_test.go +@@ -17,16 +17,35 @@ import ( + "runtime" + "strconv" + "strings" + "sync" + "testing" + "time" + ) + ++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries") ++ ++func goCmd(t *testing.T) string { ++ if *target != "" { ++ return "go_" + *target ++ } ++ return testenv.GoToolPath(t) ++} ++ ++func goExecCmd(name string, arg ...string) *exec.Cmd { ++ var cmd []string ++ if *target != "" { ++ cmd = append(cmd, "go_"+*target+"_exec") ++ } ++ cmd = append(cmd, name) ++ cmd = append(cmd, arg...) ++ return exec.Command(cmd[0], cmd[1:]...) ++} ++ + var toRemove []string + + func TestMain(m *testing.M) { + status := m.Run() + for _, file := range toRemove { + os.RemoveAll(file) + } + os.Exit(status) +@@ -50,17 +69,17 @@ func runTestProg(t *testing.T, binary, name string, env ...string) string { + + testenv.MustHaveGoBuild(t) + + exe, err := buildTestProg(t, binary) + if err != nil { + t.Fatal(err) + } + +- cmd := testenv.CleanCmdEnv(exec.Command(exe, name)) ++ cmd := testenv.CleanCmdEnv(goExecCmd(exe, name)) + cmd.Env = append(cmd.Env, env...) + if testing.Short() { + cmd.Env = append(cmd.Env, "RUNTIME_TEST_SHORT=1") + } + var b bytes.Buffer + cmd.Stdout = &b + cmd.Stderr = &b + if err := cmd.Start(); err != nil { +@@ -125,17 +144,17 @@ func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) + name += "_" + strings.Join(flags, "_") + } + target, ok := testprog.target[name] + if ok { + return target.exe, target.err + } + + exe := filepath.Join(testprog.dir, name+".exe") +- cmd := exec.Command(testenv.GoToolPath(t), append([]string{"build", "-o", exe}, flags...)...) ++ cmd := exec.Command(goCmd(t), append([]string{"build", "-o", exe}, flags...)...) + cmd.Dir = "testdata/" + binary + out, err := testenv.CleanCmdEnv(cmd).CombinedOutput() + if err != nil { + target.err = fmt.Errorf("building %s %v: %v\n%s", binary, flags, err, out) + testprog.target[name] = target + return "", target.err + } + target.exe = exe +@@ -456,17 +475,17 @@ func TestPanicLoop(t *testing.T) { + func TestMemPprof(t *testing.T) { + testenv.MustHaveGoRun(t) + + exe, err := buildTestProg(t, "testprog") + if err != nil { + t.Fatal(err) + } + +- got, err := testenv.CleanCmdEnv(exec.Command(exe, "MemProf")).CombinedOutput() ++ got, err := testenv.CleanCmdEnv(goExecCmd(exe, "MemProf")).CombinedOutput() + if err != nil { + t.Fatal(err) + } + fn := strings.TrimSpace(string(got)) + defer os.Remove(fn) + + for try := 0; try < 2; try++ { + cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), "tool", "pprof", "-alloc_space", "-top")) +--- src/runtime/crash_unix_test.go ++++ src/runtime/crash_unix_test.go +@@ -244,17 +244,17 @@ func testPanicSystemstackInternal() { + } + + func TestSignalExitStatus(t *testing.T) { + testenv.MustHaveGoBuild(t) + exe, err := buildTestProg(t, "testprog") + if err != nil { + t.Fatal(err) + } +- err = testenv.CleanCmdEnv(exec.Command(exe, "SignalExitStatus")).Run() ++ err = testenv.CleanCmdEnv(goExecCmd(exe, "SignalExitStatus")).Run() + if err == nil { + t.Error("test program succeeded unexpectedly") + } else if ee, ok := err.(*exec.ExitError); !ok { + t.Errorf("error (%v) has type %T; expected exec.ExitError", err, err) + } else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok { + t.Errorf("error.Sys (%v) has type %T; expected syscall.WaitStatus", ee.Sys(), ee.Sys()) + } else if !ws.Signaled() || ws.Signal() != syscall.SIGTERM { + t.Errorf("got %v; expected SIGTERM", ee) diff --git a/go/patch/go-1.11.2/go5.patch b/go/patch/go-1.11.2/go5.patch new file mode 100644 index 00000000..c0807e9b --- /dev/null +++ b/go/patch/go-1.11.2/go5.patch @@ -0,0 +1,106 @@ +diff --git src/runtime/crash_test.go src/runtime/crash_test.go +index 81cf5df42d..3607992788 100644 +--- src/runtime/crash_test.go ++++ src/runtime/crash_test.go +@@ -219,22 +219,27 @@ func testDeadlock(t *testing.T, name string) { + } + + func TestSimpleDeadlock(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + testDeadlock(t, "SimpleDeadlock") + } + + func TestInitDeadlock(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + testDeadlock(t, "InitDeadlock") + } + + func TestLockedDeadlock(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + testDeadlock(t, "LockedDeadlock") + } + + func TestLockedDeadlock2(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + testDeadlock(t, "LockedDeadlock2") + } + + func TestGoexitDeadlock(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + output := runTestProg(t, "testprog", "GoexitDeadlock") + want := "no goroutines (main called runtime.Goexit) - deadlock!" + if !strings.Contains(output, want) { +@@ -271,6 +276,7 @@ panic: again + } + + func TestGoexitCrash(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + output := runTestProg(t, "testprog", "GoexitExit") + want := "no goroutines (main called runtime.Goexit) - deadlock!" + if !strings.Contains(output, want) { +@@ -329,6 +335,7 @@ func TestBreakpoint(t *testing.T) { + } + + func TestGoexitInPanic(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + // see issue 8774: this code used to trigger an infinite recursion + output := runTestProg(t, "testprog", "GoexitInPanic") + want := "fatal error: no goroutines (main called runtime.Goexit) - deadlock!" +@@ -393,6 +400,7 @@ func TestPanicAfterGoexit(t *testing.T) { + } + + func TestRecoveredPanicAfterGoexit(t *testing.T) { ++ t.Skip("deadlock detection fails with external linker") + output := runTestProg(t, "testprog", "RecoveredPanicAfterGoexit") + want := "fatal error: no goroutines (main called runtime.Goexit) - deadlock!" + if !strings.HasPrefix(output, want) { +diff --git src/runtime/proc_test.go src/runtime/proc_test.go +index ad325987ac..d9d6feb498 100644 +--- src/runtime/proc_test.go ++++ src/runtime/proc_test.go +@@ -373,9 +373,10 @@ func TestGCFairness2(t *testing.T) { + + func TestNumGoroutine(t *testing.T) { + output := runTestProg(t, "testprog", "NumGoroutine") +- want := "1\n" +- if output != want { +- t.Fatalf("want %q, got %q", want, output) ++ want1 := "1\n" ++ want2 := "2\n" ++ if output != want1 && out != want2 { ++ t.Fatalf("want %q, got %q", want1, output) + } + + buf := make([]byte, 1<<20) +diff --git test/fixedbugs/bug429_run.go test/fixedbugs/bug429_run.go +index 30298de97b..3301a11ad9 100644 +--- test/fixedbugs/bug429_run.go ++++ test/fixedbugs/bug429_run.go +@@ -1,5 +1,5 @@ + // +build !nacl,!js +-// runtarget ++// skip + + // Copyright 2014 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style +diff --git test/goprint.go test/goprint.go +index 57eeac53a8..5951d4694f 100644 +--- test/goprint.go ++++ test/goprint.go +@@ -8,14 +8,9 @@ + + package main + +-import ( +- "runtime" +- "time" +-) ++import "time" + + func main() { + go println(42, true, false, true, 1.5, "world", (chan int)(nil), []int(nil), (map[string]int)(nil), (func())(nil), byte(255)) +- for runtime.NumGoroutine() > 1 { +- time.Sleep(10*time.Millisecond) +- } ++ time.Sleep(100*time.Millisecond) + } diff --git a/go/patch/go-1.11.2/go6.patch b/go/patch/go-1.11.2/go6.patch new file mode 100644 index 00000000..04134c77 --- /dev/null +++ b/go/patch/go-1.11.2/go6.patch @@ -0,0 +1,149 @@ +diff --git src/encoding/gob/encoder_test.go src/encoding/gob/encoder_test.go +index dc9bbcf35d..10c30a91af 100644 +--- src/encoding/gob/encoder_test.go ++++ src/encoding/gob/encoder_test.go +@@ -1131,13 +1131,7 @@ func TestBadData(t *testing.T) { + + // TestHugeWriteFails tests that enormous messages trigger an error. + func TestHugeWriteFails(t *testing.T) { +- if runtime.GOARCH == "wasm" { +- t.Skip("out of memory on wasm") +- } +- if testing.Short() { +- // Requires allocating a monster, so don't do this from all.bash. +- t.Skip("skipping huge allocation in short mode") +- } ++ t.Skip("skipping test due to huge memory requirement") + huge := make([]byte, tooBig) + huge[0] = 7 // Make sure it's not all zeros. + buf := new(bytes.Buffer) +diff --git src/runtime/crash_cgo_test.go src/runtime/crash_cgo_test.go +index 9ff4bbe121..5fa1340cb2 100644 +--- src/runtime/crash_cgo_test.go ++++ src/runtime/crash_cgo_test.go +@@ -238,14 +238,7 @@ func TestCgoCCodeSIGPROF(t *testing.T) { + } + + func TestCgoCrashTraceback(t *testing.T) { +- t.Parallel() +- switch platform := runtime.GOOS + "/" + runtime.GOARCH; platform { +- case "darwin/amd64": +- case "linux/amd64": +- case "linux/ppc64le": +- default: +- t.Skipf("not yet supported on %s", platform) +- } ++ t.Skipf("skip running remotely") + got := runTestProg(t, "testprogcgo", "CrashTraceback") + for i := 1; i <= 3; i++ { + if !strings.Contains(got, fmt.Sprintf("cgo symbolizer:%d", i)) { +@@ -264,10 +257,7 @@ func TestCgoTracebackContext(t *testing.T) { + } + + func testCgoPprof(t *testing.T, buildArg, runArg string) { +- t.Parallel() +- if runtime.GOOS != "linux" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "ppc64le") { +- t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH) +- } ++ t.Skipf("skip pprof test") + testenv.MustHaveGoRun(t) + + exe, err := buildTestProg(t, "testprogcgo", buildArg) +diff --git src/runtime/crash_test.go src/runtime/crash_test.go +index 3607992788..e53ffb6a81 100644 +--- src/runtime/crash_test.go ++++ src/runtime/crash_test.go +@@ -481,6 +481,7 @@ func TestPanicLoop(t *testing.T) { + } + + func TestMemPprof(t *testing.T) { ++ t.Skipf("skip pprof test") + testenv.MustHaveGoRun(t) + + exe, err := buildTestProg(t, "testprog") +diff --git src/runtime/crash_unix_test.go src/runtime/crash_unix_test.go +index 02891ec1ad..fd2723f16e 100644 +--- src/runtime/crash_unix_test.go ++++ src/runtime/crash_unix_test.go +@@ -174,9 +174,7 @@ func TestPanicSystemstack(t *testing.T) { + // The GOTRACEBACK=crash handler takes 0.1 seconds even if + // it's not writing a core file and potentially much longer if + // it is. Skip in short mode. +- if testing.Short() { +- t.Skip("Skipping in short mode (GOTRACEBACK=crash is slow)") +- } ++ t.Skip("Skipping (GOTRACEBACK=crash hangs on arm)") + + if runtime.Sigisblocked(int(syscall.SIGQUIT)) { + t.Skip("skipping; SIGQUIT is blocked, see golang.org/issue/19196") +@@ -244,6 +242,7 @@ func testPanicSystemstackInternal() { + } + + func TestSignalExitStatus(t *testing.T) { ++ t.Skipf("skip running remotely") + testenv.MustHaveGoBuild(t) + exe, err := buildTestProg(t, "testprog") + if err != nil { +diff --git src/runtime/fastlog2_test.go src/runtime/fastlog2_test.go +index ae0f40b2bb..a93933d7ac 100644 +--- src/runtime/fastlog2_test.go ++++ src/runtime/fastlog2_test.go +@@ -16,11 +16,7 @@ func TestFastLog2(t *testing.T) { + const randomBitCount = 26 + var e float64 + +- inc := 1 +- if testing.Short() { +- // Check 1K total values, down from 64M. +- inc = 1 << 16 +- } ++ inc := 1 << 16 + for i := 1; i < 1<<randomBitCount; i += inc { + l, fl := math.Log2(float64(i)), runtime.Fastlog2(float64(i)) + d := l - fl +diff --git src/runtime/hash_test.go src/runtime/hash_test.go +index 7b8ebc4f3c..9fc5b995fc 100644 +--- src/runtime/hash_test.go ++++ src/runtime/hash_test.go +@@ -164,9 +164,7 @@ func TestSmhasherTwoNonzero(t *testing.T) { + if GOARCH == "wasm" { + t.Skip("Too slow on wasm") + } +- if testing.Short() { +- t.Skip("Skipping in short mode") +- } ++ t.Skip("skipping test due to huge memory requirement") + h := newHashSet() + for n := 2; n <= 16; n++ { + twoNonZero(h, n) +@@ -273,9 +271,7 @@ func TestSmhasherPermutation(t *testing.T) { + if GOARCH == "wasm" { + t.Skip("Too slow on wasm") + } +- if testing.Short() { +- t.Skip("Skipping in short mode") +- } ++ t.Skip("skipping test due to huge memory requirement") + permutation(t, []uint32{0, 1, 2, 3, 4, 5, 6, 7}, 8) + permutation(t, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 8) + permutation(t, []uint32{0, 1}, 20) +diff --git src/runtime/pprof/pprof_test.go src/runtime/pprof/pprof_test.go +index 44d514393e..f46f00894c 100644 +--- src/runtime/pprof/pprof_test.go ++++ src/runtime/pprof/pprof_test.go +@@ -283,14 +283,7 @@ func profileOk(t *testing.T, need []string, prof bytes.Buffer, duration time.Dur + func TestCPUProfileWithFork(t *testing.T) { + testenv.MustHaveExec(t) + +- heap := 1 << 30 +- if runtime.GOOS == "android" { +- // Use smaller size for Android to avoid crash. +- heap = 100 << 20 +- } +- if testing.Short() { +- heap = 100 << 20 +- } ++ heap = 100 << 20 + // This makes fork slower. + garbage := make([]byte, heap) + // Need to touch the slice, otherwise it won't be paged in. |