scons: Use conf to determine if some flags are supported.
authorGabe Black <gabe.black@gmail.com>
Sun, 7 Feb 2021 09:48:20 +0000 (01:48 -0800)
committerGabe Black <gabe.black@gmail.com>
Thu, 11 Feb 2021 19:33:24 +0000 (19:33 +0000)
Use conf rather than checking for particular combinations of OS and/or
compiler versions. This *should* be just as correct, and not require
keeping track of what versions of the tools particular flags were added.

Change-Id: Icaa4c273fe89801e2808e6a814ce476700fd6956
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40861
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
SConstruct

index d64842425b26dd83ff586e655d8673ca05e87e4b..214aa4834f7b288973cbba8cf65b4c7cfaac6149 100755 (executable)
@@ -323,10 +323,7 @@ if main['GCC'] or main['CLANG']:
         main.Append(CCFLAGS=['-I/usr/local/include'])
         main.Append(CXXFLAGS=['-I/usr/local/include'])
 
-    # On Mac OS X/Darwin the default linker doesn't support the
-    # option --as-needed
-    if sys.platform != "darwin":
-        main.Append(LINKFLAGS='-Wl,--as-needed')
+    conf.CheckLinkFlag('-Wl,--as-needed')
     if GetOption('gold_linker'):
         main.Append(LINKFLAGS='-fuse-ld=gold')
 
@@ -397,12 +394,8 @@ elif main['CLANG']:
                          # interchangeably.
                          '-Wno-mismatched-tags',
                          ])
-    if sys.platform != "darwin" and \
-       compareVersions(clang_version, "10.0") >= 0:
-        main.Append(CCFLAGS=['-Wno-c99-designator'])
-
-    if compareVersions(clang_version, "8.0") >= 0:
-        main.Append(CCFLAGS=['-Wno-defaulted-function-deleted'])
+    conf.CheckCxxFlag('-Wno-c99-designator')
+    conf.CheckCxxFlag('-Wno-defaulted-function-deleted')
 
     main.Append(TCMALLOC_CCFLAGS=['-fno-builtin'])