mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: remove -O options when generating compiler errors
The cgo tool generates compiler errors to find out what kind of name it is using. Turning on optimization can confuse that process by producing new unexpected messages. Fixes #14669. Change-Id: Idc8e35fd259711ecc9638566b691c11d17140325 Reviewed-on: https://go-review.googlesource.com/23231 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
9369f22b84
commit
b5d18b50ac
3 changed files with 40 additions and 2 deletions
|
|
@ -1243,12 +1243,20 @@ func (p *Package) gccErrors(stdin []byte) string {
|
|||
// TODO(rsc): require failure
|
||||
args := p.gccCmd()
|
||||
|
||||
// Optimization options can confuse the error messages; remove them.
|
||||
nargs := make([]string, 0, len(args))
|
||||
for _, arg := range args {
|
||||
if !strings.HasPrefix(arg, "-O") {
|
||||
nargs = append(nargs, arg)
|
||||
}
|
||||
}
|
||||
|
||||
if *debugGcc {
|
||||
fmt.Fprintf(os.Stderr, "$ %s <<EOF\n", strings.Join(args, " "))
|
||||
fmt.Fprintf(os.Stderr, "$ %s <<EOF\n", strings.Join(nargs, " "))
|
||||
os.Stderr.Write(stdin)
|
||||
fmt.Fprint(os.Stderr, "EOF\n")
|
||||
}
|
||||
stdout, stderr, _ := run(stdin, args)
|
||||
stdout, stderr, _ := run(stdin, nargs)
|
||||
if *debugGcc {
|
||||
os.Stderr.Write(stdout)
|
||||
os.Stderr.Write(stderr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue