diff options
Diffstat (limited to 'go/patch/go3.patch')
-rw-r--r-- | go/patch/go3.patch | 381 |
1 files changed, 325 insertions, 56 deletions
diff --git a/go/patch/go3.patch b/go/patch/go3.patch index 37bd562f..62247a03 100644 --- a/go/patch/go3.patch +++ b/go/patch/go3.patch @@ -2,14 +2,15 @@ test: add runtarget action. --- test/fixedbugs/bug248.go +++ test/fixedbugs/bug248.go -@@ -1,5 +1,5 @@ +@@ -1,38 +1,57 @@ // +build !nacl,!plan9,!windows -// run +// runtarget // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style -@@ -8,13 +8,32 @@ + // license that can be found in the LICENSE file. + package main import ( @@ -42,7 +43,7 @@ test: add runtarget action. // TODO: If we get rid of errchk, re-enable this test on Windows. errchk, err := filepath.Abs("errchk") check(err) -@@ -22,12 +41,12 @@ func main() { + err = os.Chdir(filepath.Join("fixedbugs", "bug248.dir")) check(err) @@ -61,16 +62,22 @@ test: add runtarget action. os.Remove("bug0.o") os.Remove("bug1.o") + os.Remove("bug2.o") + os.Remove("a.out") + } + + func run(name string, args ...string) { --- test/fixedbugs/bug302.go +++ test/fixedbugs/bug302.go -@@ -1,5 +1,5 @@ +@@ -1,28 +1,39 @@ // +build !nacl -// run +// runtarget - // Copyright 2010 The Go Authors. All rights reserved. + // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style -@@ -8,16 +8,27 @@ + // license that can be found in the LICENSE file. + package main import ( @@ -101,16 +108,22 @@ test: add runtarget action. os.Remove("p.o") os.Remove("pp.a") os.Remove("main.o") + } + + func run(cmd string, args ...string) { + out, err := exec.Command(cmd, args...).CombinedOutput() + if err != nil { --- test/fixedbugs/bug345.go +++ test/fixedbugs/bug345.go -@@ -1,5 +1,5 @@ +@@ -1,34 +1,45 @@ // +build !nacl,!plan9,!windows -// run +// runtarget - // Copyright 2011 The Go Authors. All rights reserved. + // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style -@@ -8,13 +8,24 @@ + // license that can be found in the LICENSE file. + package main import ( @@ -135,7 +148,7 @@ test: add runtarget action. // TODO: If we get rid of errchk, re-enable this test on Plan 9 and Windows. errchk, err := filepath.Abs("errchk") check(err) -@@ -22,8 +33,8 @@ func main() { + err = os.Chdir(filepath.Join(".", "fixedbugs", "bug345.dir")) check(err) @@ -146,16 +159,24 @@ test: add runtarget action. os.Remove("io.o") } + func run(name string, args ...string) { + cmd := exec.Command(name, args...) + out, err := cmd.CombinedOutput() + if err != nil { + fmt.Println(string(out)) --- test/fixedbugs/bug369.go +++ test/fixedbugs/bug369.go -@@ -1,5 +1,5 @@ +@@ -1,35 +1,54 @@ // +build !nacl,!windows -// run +// runtarget - // Copyright 2011 The Go Authors. All rights reserved. + // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style -@@ -10,21 +10,40 @@ + // license that can be found in the LICENSE file. + + // Test that compiling with optimization turned on produces faster code. + package main import ( @@ -201,16 +222,24 @@ test: add runtarget action. os.Remove("slow.o") os.Remove("fast.o") + os.Remove("main.o") + os.Remove("a.exe") + } + + func run(name string, args ...string) { --- test/fixedbugs/bug429_run.go +++ test/fixedbugs/bug429_run.go -@@ -1,5 +1,5 @@ +@@ -1,29 +1,49 @@ // +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 @@ + // license that can be found in the LICENSE file. + + // Run the bug429.go test. + package main import ( @@ -218,7 +247,7 @@ test: add runtarget action. "fmt" "os" "os/exec" -@@ -17,8 +18,27 @@ import ( + "path/filepath" "strings" ) @@ -247,16 +276,25 @@ test: add runtarget action. out, err := cmd.CombinedOutput() if err == nil { fmt.Println("expected deadlock") + os.Exit(1) + } + + want := "fatal error: all goroutines are asleep - deadlock!" + got := string(out) --- test/fixedbugs/issue10607.go +++ test/fixedbugs/issue10607.go -@@ -1,5 +1,5 @@ - // +build linux,!ppc64,!ppc64le,!mips64,!mips64le android +@@ -1,31 +1,51 @@ + // +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 @@ + // license that can be found in the LICENSE file. + + // Test that a -B option is passed through when using both internal + // and external linking mode. + package main import ( @@ -286,8 +324,9 @@ test: add runtarget action. +} + func main() { +- test("internal") + flag.Parse() - test("internal") ++ // test("internal") test("external") } @@ -297,16 +336,22 @@ test: add runtarget action. if err != nil { fmt.Printf("BUG: linkmode=%s %v\n%s\n", linkmode, err, out) os.Exit(1) + } + } --- test/fixedbugs/issue11771.go +++ test/fixedbugs/issue11771.go -@@ -1,5 +1,5 @@ +@@ -1,31 +1,42 @@ // +build !nacl -// run +// runtarget - // Copyright 2015 The Go Authors. All rights reserved. + // 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 + // license that can be found in the LICENSE file. + + // Issue 11771: Magic comments should ignore carriage returns. + + package main import ( "bytes" @@ -314,7 +359,9 @@ test: add runtarget action. "fmt" "io/ioutil" "log" -@@ -20,7 +21,17 @@ import ( + "os" + "os/exec" + "path/filepath" "runtime" ) @@ -332,7 +379,17 @@ test: add runtarget action. if runtime.Compiler != "gc" { return } -@@ -52,7 +63,7 @@ func x() { + + dir, err := ioutil.TempDir("", "go-issue11771") + if err != nil { + log.Fatalf("creating temp dir: %v\n", err) + } +@@ -47,17 +58,17 @@ func main() { + func x() { + } + `) + + if err := ioutil.WriteFile(filepath.Join(dir, "x.go"), buf.Bytes(), 0666); err != nil { log.Fatal(err) } @@ -341,15 +398,21 @@ test: add runtarget action. cmd.Dir = dir output, err := cmd.CombinedOutput() if err == nil { + log.Fatal("compile succeeded unexpectedly") + } + if !bytes.Contains(output, []byte("only allowed in runtime")) { + log.Fatalf("wrong error message from compiler; got:\n%s\n", output) + } --- test/fixedbugs/issue9355.go +++ test/fixedbugs/issue9355.go -@@ -1,4 +1,4 @@ +@@ -1,34 +1,45 @@ -// run +// runtarget - // Copyright 2014 The Go Authors. All rights reserved. + // Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style -@@ -7,6 +7,7 @@ + // license that can be found in the LICENSE file. + package main import ( @@ -357,7 +420,8 @@ test: add runtarget action. "fmt" "os" "os/exec" -@@ -15,7 +16,17 @@ import ( + "path/filepath" + "regexp" "runtime" ) @@ -375,7 +439,7 @@ test: add runtarget action. if runtime.Compiler != "gc" || runtime.GOOS == "nacl" { return } -@@ -23,7 +34,7 @@ func main() { + err := os.Chdir(filepath.Join("fixedbugs", "issue9355.dir")) check(err) @@ -384,16 +448,24 @@ test: add runtarget action. os.Remove("a.o") // 6g/8g print the offset as dec, but 5g/9g print the offset as hex. + patterns := []string{ + `rel 0\+\d t=1 \"\"\.x\+8\r?\n`, // y = &x.b + `rel 0\+\d t=1 \"\"\.x\+(28|1c)\r?\n`, // z = &x.d.q + `rel 0\+\d t=1 \"\"\.b\+5\r?\n`, // c = &b[5] + `rel 0\+\d t=1 \"\"\.x\+(88|58)\r?\n`, // w = &x.f[3].r --- test/fixedbugs/issue9862_run.go +++ test/fixedbugs/issue9862_run.go -@@ -1,5 +1,5 @@ +@@ -1,26 +1,46 @@ // +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 @@ + // license that can be found in the LICENSE file. + + // Check for compile or link error. + package main import ( @@ -427,16 +499,24 @@ test: add runtarget action. outstr := string(out) if err == nil { println("go run issue9862.go succeeded, should have failed\n", outstr) + return + } + if !strings.Contains(outstr, "symbol too large") { + println("go run issue9862.go gave unexpected error; want symbol too large:\n", outstr) + } --- test/linkmain_run.go +++ test/linkmain_run.go -@@ -1,5 +1,5 @@ +@@ -1,26 +1,36 @@ // +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 @@ + // license that can be found in the LICENSE file. + + // Run the sinit test. + package main import ( @@ -459,7 +539,17 @@ test: add runtarget action. func cleanup() { os.Remove("linkmain.o") os.Remove("linkmain.a") -@@ -51,16 +61,18 @@ func runFail(cmdline string) { + os.Remove("linkmain1.o") + os.Remove("linkmain1.a") + os.Remove("linkmain.exe") + } + +@@ -46,21 +56,23 @@ func runFail(cmdline string) { + fmt.Println(string(out)) + fmt.Println("SHOULD HAVE FAILED!") + cleanup() + os.Exit(1) + } } func main() { @@ -486,16 +576,114 @@ test: add runtarget action. + runFail(goCmd() + " tool link -o linkmain.exe linkmain1.a") cleanup() } +--- test/linkobj.go ++++ test/linkobj.go +@@ -1,31 +1,50 @@ + // +build !nacl +-// run ++// runtarget + + // Copyright 2016 The Go Authors. All rights reserved. + // Use of this source code is governed by a BSD-style + // license that can be found in the LICENSE file. + + // Test the compiler -linkobj flag. + + package main + + import ( ++ "flag" + "fmt" + "io/ioutil" + "log" + "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(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) + } + pwd, err = os.Getwd() + if err != nil { + log.Fatal(err) + } +@@ -71,33 +90,33 @@ func main() { + + // The compiler expects the files being read to have the right suffix. + o := "o" + if round == 1 { + o = "a" + } + + // 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") + cp("p3."+o, "p3.oo") + 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) + } + + // ensure that mistaken future round can't use these + os.Remove("p1.o") + os.Remove("a.out.exe") + } --- test/linkx_run.go +++ test/linkx_run.go -@@ -1,5 +1,5 @@ +@@ -1,35 +1,55 @@ // +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 + // license that can be found in the LICENSE file. + + // Run the linkx test. + + package main import ( "bytes" @@ -526,7 +714,7 @@ test: add runtarget action. + func main() { + flag.Parse() - test(" ") // old deprecated syntax + // test(" ") // old deprecated & removed syntax test("=") // new syntax } @@ -537,7 +725,17 @@ test: add runtarget action. var out, errbuf bytes.Buffer cmd.Stdout = &out cmd.Stderr = &errbuf -@@ -44,7 +64,7 @@ func test(sep string) { + err := cmd.Run() + if err != nil { + fmt.Println(errbuf.String()) + fmt.Println(out.String()) + fmt.Println(err) +@@ -39,25 +59,25 @@ func test(sep string) { + want := "hello\ntrumped\n" + got := out.String() + if got != want { + fmt.Printf("got %q want %q\n", got, want) + os.Exit(1) } // Issue 8810 @@ -546,7 +744,7 @@ test: add runtarget action. _, 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) { + os.Exit(1) } // Issue 9621 @@ -555,16 +753,23 @@ test: add runtarget action. outx, err := cmd.CombinedOutput() if err == nil { fmt.Println("-X linker flag should not overwrite non-strings") + os.Exit(1) + } + outstr := string(outx) + if !strings.Contains(outstr, "main.b") { + fmt.Printf("-X linker flag did not diagnose overwrite of main.b:\n%s\n", outstr) --- test/nosplit.go +++ test/nosplit.go -@@ -1,5 +1,5 @@ +@@ -1,31 +1,49 @@ // +build !nacl -// run +// runtarget - // Copyright 2014 The Go Authors. All rights reserved. + // 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 + // license that can be found in the LICENSE file. + + package main import ( "bytes" @@ -572,7 +777,7 @@ test: add runtarget action. "fmt" "io/ioutil" "log" -@@ -16,11 +17,28 @@ import ( + "os" "os/exec" "path/filepath" "regexp" @@ -602,7 +807,17 @@ test: add runtarget action. var tests = ` # These are test cases for the linker analysis that detects chains of # nosplit functions that would cause a stack overflow. -@@ -193,12 +211,13 @@ var ( + # + # Lines beginning with # are comments. + # + # Each test case describes a sequence of functions, one per line. + # Each function definition is the function name, then the frame size, +@@ -189,22 +207,23 @@ var ( + commentRE = regexp.MustCompile(`(?m)^#.*`) + rejectRE = regexp.MustCompile(`(?s)\A(.+?)((\n|; *)REJECT(.*))?\z`) + lineRE = regexp.MustCompile(`(\w+) (\d+)( nosplit)?(.*)`) + callRE = regexp.MustCompile(`\bcall (\w+)\b`) + callindRE = regexp.MustCompile(`\bcallind\b`) ) func main() { @@ -619,7 +834,17 @@ test: add runtarget action. if err != nil { bug() fmt.Printf("running go tool compile -V: %v\n", err) -@@ -338,7 +357,7 @@ TestCases: + return + } + if s := string(version); goarch == "amd64" && strings.Contains(s, "X:") && !strings.Contains(s, "framepointer") { + // Skip this test if framepointer is NOT enabled on AMD64 + return +@@ -340,17 +359,17 @@ TestCases: + + if err := ioutil.WriteFile(filepath.Join(dir, "asm.s"), buf.Bytes(), 0666); err != nil { + log.Fatal(err) + } + if err := ioutil.WriteFile(filepath.Join(dir, "main.go"), gobuf.Bytes(), 0666); err != nil { log.Fatal(err) } @@ -628,9 +853,19 @@ test: add runtarget action. cmd.Dir = dir output, err := cmd.CombinedOutput() if err == nil { + nok++ + if reject { + bug() + fmt.Printf("accepted incorrectly:\n\t%s\n", indent(strings.TrimSpace(stanza))) + } --- test/run.go +++ test/run.go -@@ -220,6 +220,16 @@ func goRun(runcmd runCmd, goname string, args ...string) (out []byte, err error) +@@ -222,16 +222,26 @@ func goRun(runcmd runCmd, flags []string, goname string, args ...string) (out [] + cmd = append(cmd, findExecCmd()...) + } + cmd = append(cmd, flags...) + cmd = append(cmd, goname) + cmd = append(cmd, args...) return runcmd(cmd...) } @@ -647,16 +882,36 @@ test: add runtarget action. // skipError describes why a test was skipped. type skipError string -@@ -469,7 +479,7 @@ func (t *test) run() { + func (s skipError) Error() string { return string(s) } + + func check(err error) { + if err != nil { + log.Fatal(err) +@@ -484,17 +494,17 @@ func (t *test) run() { + } + + // TODO: Clean up/simplify this switch statement. + switch action { + case "rundircmpout": + action = "rundir" case "cmpout": action = "run" // the run case already looks for <dir>/<test>.out files - fallthrough -- case "compile", "compiledir", "build", "run", "runoutput", "rundir": -+ case "compile", "compiledir", "build", "run", "runtarget", "runoutput", "rundir": - t.action = action +- 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 + case "errorcheckwithauto": + action = "errorcheck" + wantAuto = true + wantError = true case "errorcheck", "errorcheckdir", "errorcheckoutput": - t.action = action -@@ -653,6 +663,17 @@ func (t *test) run() { +@@ -807,16 +817,27 @@ func (t *test) run() { + 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) } @@ -674,16 +929,25 @@ test: add runtarget action. case "runoutput": rungatec <- true defer func() { + <-rungatec + }() + useTmp = false + out, err := goRun(runcmd, nil, t.goFileName(), args...) + if err != nil { --- test/sinit_run.go +++ test/sinit_run.go -@@ -1,5 +1,5 @@ +@@ -1,28 +1,39 @@ // +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 + // license that can be found in the LICENSE file. + + // Run the sinit test. + + package main import ( "bytes" @@ -709,3 +973,8 @@ test: add runtarget action. out, err := cmd.CombinedOutput() if err != nil { fmt.Println(string(out)) + fmt.Println(err) + os.Exit(1) + } + os.Remove("sinit.o") + |