1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:54:40 -07:00

cmd/toolstash: don't pass -N when compiling runtime

The runtime cannot be compiled with optimizations disabled.
This lead to very confusing error messages
when toolstash -cmp failed.

Change-Id: Ie341d633ff9b26693b475957309591ff0757f1ab
Reviewed-on: https://go-review.googlesource.com/38378
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Josh Bleecher Snyder 2017-03-20 13:03:44 -07:00
parent 2946dd1f77
commit a5c9681e31

View File

@ -275,14 +275,26 @@ func compareTool() {
log.Fatalf("unknown tool %s", tool)
case tool == "compile" || strings.HasSuffix(tool, "g"): // compiler
cmdN := append([]string{cmd[0], "-N"}, cmd[1:]...)
_, ok := cmpRun(false, cmdN)
if !ok {
log.Printf("compiler output differs, even with optimizers disabled (-N)")
cmd = append([]string{cmd[0], "-v", "-N", "-m=2"}, cmd[1:]...)
useDashN := true
for _, s := range cmd {
if s == "-+" {
// Compiling runtime. Don't use -N.
useDashN = false
break
}
cmd = append([]string{cmd[0], "-v", "-m=2"}, cmd[1:]...)
}
cmdN := injectflags(cmd, nil, useDashN)
_, ok := cmpRun(false, cmdN)
if !ok {
if useDashN {
log.Printf("compiler output differs, with optimizers disabled (-N)")
} else {
log.Printf("compiler output differs")
}
cmd = injectflags(cmd, []string{"-v", "-m=2"}, useDashN)
break
}
cmd = injectflags(cmd, []string{"-v", "-m=2"}, false)
log.Printf("compiler output differs, only with optimizers enabled")
case tool == "asm" || strings.HasSuffix(tool, "a"): // assembler
@ -293,13 +305,23 @@ func compareTool() {
extra = "-v=2"
}
cmdS := append([]string{cmd[0], extra}, cmd[1:]...)
cmdS := injectflags(cmd, []string{extra}, false)
outfile, _ = cmpRun(true, cmdS)
fmt.Fprintf(os.Stderr, "\n%s\n", compareLogs(outfile))
os.Exit(2)
}
func injectflags(cmd []string, extra []string, addDashN bool) []string {
x := []string{cmd[0]}
if addDashN {
x = append(x, "-N")
}
x = append(x, extra...)
x = append(x, cmd[1:]...)
return x
}
func cmpRun(keepLog bool, cmd []string) (outfile string, match bool) {
cmdStash := make([]string, len(cmd))
copy(cmdStash, cmd)