summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2014-10-16 05:49:36 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2014-10-16 05:49:36 -0400
commitb14f521e5f16f942a1f13a431dad2a72e8966f21 (patch)
tree99bb5d51faa8fd4a49eaf19978cd5c3e2373780a /SConstruct
parentded540a661d9ff572ca58cd2e990460b2518dc28 (diff)
downloadgem5-b14f521e5f16f942a1f13a431dad2a72e8966f21.tar.xz
scons: Add Undefined Behavior Sanitizer (UBSan) option
This patch adds the Undefined Behavior Sanitizer (UBSan) for clang and gcc >= 4.9. Due to the performance impact, the usage is guarded by a command-line option.
Diffstat (limited to 'SConstruct')
-rwxr-xr-xSConstruct11
1 files changed, 11 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
index 1d1b95711..1078a3e96 100755
--- a/SConstruct
+++ b/SConstruct
@@ -189,6 +189,8 @@ AddLocalOption('--without-python', dest='without_python',
AddLocalOption('--without-tcmalloc', dest='without_tcmalloc',
action='store_true',
help='Disable linking against tcmalloc')
+AddLocalOption('--with-ubsan', dest='with_ubsan', action='store_true',
+ help='Build with Undefined Behavior Sanitizer if available')
termcap = get_termcap(GetOption('use_colors'))
@@ -602,6 +604,15 @@ if main['GCC']:
'binutils to 2.23.' + \
termcap.Normal
+ # Make sure we warn if the user has requested to compile with the
+ # Undefined Benahvior Sanitizer and this version of gcc does not
+ # support it.
+ if GetOption('with_ubsan') and \
+ compareVersions(gcc_version, '4.9') < 0:
+ print termcap.Yellow + termcap.Bold + \
+ 'Warning: UBSan is only supported using gcc 4.9 and later.' + \
+ termcap.Normal
+
# Add the appropriate Link-Time Optimization (LTO) flags
# unless LTO is explicitly turned off. Note that these flags
# are only used by the fast target.