From a607b3b437291db4699c48f5b86ac04b38ff5e8a Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 20 Oct 2017 09:51:45 -0700 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Damien Neil --- src/cmd/go/internal/work/build.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index 11e4632815c..c7127f6ec89 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -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 }