1
0
mirror of https://github.com/golang/go synced 2024-11-24 02:40:17 -07:00

cmd/go: look for "unknown" when checking supported compiler flags

Where GCC says "unrecognized command line option", clang says "unknown
argument". This distinction usually doesn't matter because the
compiler will also exit with a non-zero status, but clang 3.4
reportedly exits with a zero status after reporting an unknown argument.

Change-Id: Ieb69ea352a8de0cd4171a1c26708dfe523421cfa
Reviewed-on: https://go-review.googlesource.com/72151
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
Ian Lance Taylor 2017-10-20 09:51:45 -07:00
parent 2f40dc79e5
commit a607b3b437

View File

@ -3581,7 +3581,9 @@ func (b *Builder) gccSupportsFlag(compiler []string, flag string) bool {
cmd.Dir = b.WorkDir
cmd.Env = base.MergeEnvLists([]string{"LC_ALL=C"}, base.EnvForDir(cmd.Dir, os.Environ()))
out, err := cmd.CombinedOutput()
supported := err == nil && !bytes.Contains(out, []byte("unrecognized"))
// GCC says "unrecognized command line option".
// clang says "unknown argument".
supported := err == nil && !bytes.Contains(out, []byte("unrecognized")) && !bytes.Contains(out, []byte("unknown"))
b.flagCache[key] = supported
return supported
}