diff options
author | Andrew Morrow <acm@10gen.com> | 2013-04-25 11:33:22 -0400 |
---|---|---|
committer | Andrew Morrow <acm@10gen.com> | 2013-04-26 11:08:34 -0400 |
commit | 128b0cb3b421ec91e93402a5b275b4b97a158eaf (patch) | |
tree | 4c4cd714a9d9964e5271dcfda0034e427a331eb2 /SConstruct | |
parent | bc532c817a433d33a9d25d9e48cc1567f303097c (diff) | |
download | mongo-128b0cb3b421ec91e93402a5b275b4b97a158eaf.tar.gz |
Handle gcc options parsing peculiarity for -Wno- flags
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/SConstruct b/SConstruct index 7c8fbbcc93e..c72ec372a05 100644 --- a/SConstruct +++ b/SConstruct @@ -14,6 +14,7 @@ # several, subordinate SConscript files, which describe specific build rules. import buildscripts +import copy import datetime import imp import os @@ -960,13 +961,28 @@ def doConfigure(myenv): context.Result(ret) return ret - cloned = env.Clone() - cloned.Append(**mutation) - if using_msvc(): print("AddFlagIfSupported is not currently supported with MSVC") Exit(1) + test_mutation = mutation + if using_gcc(): + test_mutation = copy.deepcopy(mutation) + # GCC helpfully doesn't issue a diagnostic on unkown flags of the form -Wno-xxx + # unless other diagnostics are triggered. That makes it tough to check for support + # for -Wno-xxx. To work around, if we see that we are testing for a flag of the + # form -Wno-xxx (but not -Wno-error=xxx), we also add -Wxxx to the flags. GCC does + # warn on unknown -Wxxx style flags, so this lets us probe for availablity of + # -Wno-xxx. + for kw in test_mutation.keys(): + test_flags = test_mutation[kw] + for test_flag in test_flags: + if test_flag.startswith("-Wno-") and not test_flag.startswith("-Wno-error="): + test_flags.append(re.sub("^-Wno-", "-W", test_flag)) + + cloned = env.Clone() + cloned.Append(**test_mutation) + # For GCC, we don't need anything since bad flags are already errors, but # adding -Werror won't hurt. For clang, bad flags are only warnings, so we need -Werror # to make them real errors. |