mirror of
https://github.com/golang/go
synced 2024-11-18 13:14:47 -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:
parent
2946dd1f77
commit
a5c9681e31
@ -275,14 +275,26 @@ func compareTool() {
|
|||||||
log.Fatalf("unknown tool %s", tool)
|
log.Fatalf("unknown tool %s", tool)
|
||||||
|
|
||||||
case tool == "compile" || strings.HasSuffix(tool, "g"): // compiler
|
case tool == "compile" || strings.HasSuffix(tool, "g"): // compiler
|
||||||
cmdN := append([]string{cmd[0], "-N"}, cmd[1:]...)
|
useDashN := true
|
||||||
|
for _, s := range cmd {
|
||||||
|
if s == "-+" {
|
||||||
|
// Compiling runtime. Don't use -N.
|
||||||
|
useDashN = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmdN := injectflags(cmd, nil, useDashN)
|
||||||
_, ok := cmpRun(false, cmdN)
|
_, ok := cmpRun(false, cmdN)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("compiler output differs, even with optimizers disabled (-N)")
|
if useDashN {
|
||||||
cmd = append([]string{cmd[0], "-v", "-N", "-m=2"}, cmd[1:]...)
|
log.Printf("compiler output differs, with optimizers disabled (-N)")
|
||||||
|
} else {
|
||||||
|
log.Printf("compiler output differs")
|
||||||
|
}
|
||||||
|
cmd = injectflags(cmd, []string{"-v", "-m=2"}, useDashN)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
cmd = append([]string{cmd[0], "-v", "-m=2"}, cmd[1:]...)
|
cmd = injectflags(cmd, []string{"-v", "-m=2"}, false)
|
||||||
log.Printf("compiler output differs, only with optimizers enabled")
|
log.Printf("compiler output differs, only with optimizers enabled")
|
||||||
|
|
||||||
case tool == "asm" || strings.HasSuffix(tool, "a"): // assembler
|
case tool == "asm" || strings.HasSuffix(tool, "a"): // assembler
|
||||||
@ -293,13 +305,23 @@ func compareTool() {
|
|||||||
extra = "-v=2"
|
extra = "-v=2"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdS := append([]string{cmd[0], extra}, cmd[1:]...)
|
cmdS := injectflags(cmd, []string{extra}, false)
|
||||||
outfile, _ = cmpRun(true, cmdS)
|
outfile, _ = cmpRun(true, cmdS)
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "\n%s\n", compareLogs(outfile))
|
fmt.Fprintf(os.Stderr, "\n%s\n", compareLogs(outfile))
|
||||||
os.Exit(2)
|
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) {
|
func cmpRun(keepLog bool, cmd []string) (outfile string, match bool) {
|
||||||
cmdStash := make([]string, len(cmd))
|
cmdStash := make([]string, len(cmd))
|
||||||
copy(cmdStash, cmd)
|
copy(cmdStash, cmd)
|
||||||
|
Loading…
Reference in New Issue
Block a user