Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/40855 )

Change subject: scons: Update the Check(Cxx|Link)Flag checks to set their vars.
......................................................................

scons: Update the Check(Cxx|Link)Flag checks to set their vars.

This avoids boilerplate where we check to see if flag X is supported,
and if so then set flag X. Since there are shared and static versions of
the linker flags but we only explicitly check the static ones, this
change also adds a parameter to CheckLinkFlag to set both flavors. This
defaults to true since I assume most of the time linking flags will
apply to both.

Change-Id: I983222169e9835aeb98570362f7004e2ef0240d0
---
M SConstruct
1 file changed, 11 insertions(+), 10 deletions(-)



diff --git a/SConstruct b/SConstruct
index 7aee9ab..b0d7f4f 100755
--- a/SConstruct
+++ b/SConstruct
@@ -512,21 +512,26 @@
 main['TIMEOUT'] =  timeout_version and \
     compareVersions(timeout_version[-1], '8.13') >= 0

-def CheckCxxFlag(context, flag):
+def CheckCxxFlag(context, flag, autoadd=True):
     context.Message("Checking for compiler %s support... " % flag)
     last_cxxflags = context.env['CXXFLAGS']
     context.env.Append(CXXFLAGS=[flag])
     ret = context.TryCompile('', '.cc')
-    context.env['CXXFLAGS'] = last_cxxflags
+    if not autoadd:
+        context.env['CXXFLAGS'] = last_cxxflags
     context.Result(ret)
     return ret

-def CheckLinkFlag(context, flag):
+def CheckLinkFlag(context, flag, autoadd=True, set_for_shared=True):
     context.Message("Checking for linker %s support... " % flag)
     last_linkflags = context.env['LINKFLAGS']
     context.env.Append(LINKFLAGS=[flag])
     ret = context.TryLink('int main(int, char *[]) { return 0; }', '.cc')
-    context.env['LINKFLAGS'] = last_linkflags
+    if not autoadd:
+        context.env['LINKFLAGS'] = last_linkflags
+    if set_for_shared:
+        assert(autoadd)
+        context.env.Append(SHLINKFLAGS=[flag])
     context.Result(ret)
     return ret

@@ -621,13 +626,9 @@
     CacheDir(main['M5_BUILD_CACHE'])

 if GetOption('compress_debug'):
-    if conf.CheckCxxFlag('-gz'):
-        main.Append(CXXFLAGS=['-gz'])
-    else:
+    if not conf.CheckCxxFlag('-gz'):
         warning("Can't enable object file debug section compression")
-    if conf.CheckLinkFlag('-gz'):
-        main.Append(LINKFLAGS=['-gz'], SHLINKFLAGS=['-gz'])
-    else:
+    if not conf.CheckLinkFlag('-gz'):
         warning("Can't enable executable debug section compression")

 main['USE_PYTHON'] = not GetOption('without_python')

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40855
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I983222169e9835aeb98570362f7004e2ef0240d0
Gerrit-Change-Number: 40855
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to