Nikos Nikoleris has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/23883 )

Change subject: scons: Cleanup code that enables asan and ubsan
......................................................................

scons: Cleanup code that enables asan and ubsan

Change-Id: Ie29efc99067dac051536bb099a89f29c940192ec
Signed-off-by: Nikos Nikoleris <nikos.nikole...@arm.com>
---
M SConstruct
1 file changed, 15 insertions(+), 34 deletions(-)



diff --git a/SConstruct b/SConstruct
index 5a90808..d8ab70d 100755
--- a/SConstruct
+++ b/SConstruct
@@ -466,25 +466,6 @@
main.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc',
                                   '-fno-builtin-realloc', '-fno-builtin-free'])

-    # The address sanitizer is available for gcc >= 4.8
-    if GetOption('with_asan'):
-        if GetOption('with_ubsan') and \
-                compareVersions(main['GCC_VERSION'], '4.9') >= 0:
-            main.Append(CCFLAGS=['-fsanitize=address,undefined',
-                                 '-fno-omit-frame-pointer'],
-                        LINKFLAGS='-fsanitize=address,undefined')
-        else:
-            main.Append(CCFLAGS=['-fsanitize=address',
-                                 '-fno-omit-frame-pointer'],
-                        LINKFLAGS='-fsanitize=address')
-    # Only gcc >= 4.9 supports UBSan, so check both the version
-    # and the command-line option before adding the compiler and
-    # linker flags.
-    elif GetOption('with_ubsan') and \
-            compareVersions(main['GCC_VERSION'], '4.9') >= 0:
-        main.Append(CCFLAGS='-fsanitize=undefined')
-        main.Append(LINKFLAGS='-fsanitize=undefined')
-
 elif main['CLANG']:
     # Check for a supported version of clang, >= 3.1 is needed to
     # support similar features as gcc 4.8. See
@@ -523,21 +504,21 @@
     if sys.platform.startswith('freebsd'):
         main.Append(LIBS=['thr'])

-    # We require clang >= 3.1, so there is no need to check any
-    # versions here.
-    if GetOption('with_ubsan'):
-        if GetOption('with_asan'):
-            main.Append(CCFLAGS=['-fsanitize=address,undefined',
-                                 '-fno-omit-frame-pointer'],
-                       LINKFLAGS='-fsanitize=address,undefined')
-        else:
-            main.Append(CCFLAGS='-fsanitize=undefined',
-                        LINKFLAGS='-fsanitize=undefined')
-
-    elif GetOption('with_asan'):
-        main.Append(CCFLAGS=['-fsanitize=address',
-                             '-fno-omit-frame-pointer'],
-                   LINKFLAGS='-fsanitize=address')
+# Add sanitizers' flags
+sanitizers=[]
+if GetOption('with_ubsan'):
+    sanitizers.append('undefined')
+if GetOption('with_asan'):
+    # Only gcc >= 4.9 supports UBSan, so check both the version
+    # and the command-line option before adding the compiler and
+    # linker flags.
+    if not main['GCC'] or compareVersions(main['GCC_VERSION'], '4.9') >= 0:
+        sanitizers.append('address')
+if sanitizers:
+    sanitizers = ','.join(sanitizers)
+    main.Append(CCFLAGS=['-fsanitize=%s' % sanitizers,
+                         '-fno-omit-frame-pointer'],
+                LINKFLAGS='-fsanitize=%s' % sanitizers)

 # Set up common yacc/bison flags (needed for Ruby)
 main['YACCFLAGS'] = '-d'

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

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ie29efc99067dac051536bb099a89f29c940192ec
Gerrit-Change-Number: 23883
Gerrit-PatchSet: 1
Gerrit-Owner: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to