summaryrefslogtreecommitdiff
path: root/src/SConscript
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2016-02-17 03:56:20 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2016-02-17 03:56:20 -0500
commita34ff350da1367f5daabfe7cc5b36956bc21898a (patch)
treecb8467f4fd7c186e4c765bf3f4d38c69a4d4d38a /src/SConscript
parent0d50979888c1653e9ceb856c6bffa3f5062adeb9 (diff)
downloadgem5-a34ff350da1367f5daabfe7cc5b36956bc21898a.tar.xz
scons: Enable building with the gcc/clang Address Sanitizer
Allow the user to easily build gem5 with the Address Sanitizer, part of both gcc and clang these days.
Diffstat (limited to 'src/SConscript')
-rwxr-xr-xsrc/SConscript14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/SConscript b/src/SConscript
index 6cef47089..9b6c2170b 100755
--- a/src/SConscript
+++ b/src/SConscript
@@ -1083,17 +1083,27 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs):
new_env.Append(CCFLAGS='-fsanitize=undefined')
new_env.Append(LINKFLAGS='-fsanitize=undefined')
+ # The address sanitizer is available for gcc >= 4.8
+ if GetOption('with_asan') and \
+ compareVersions(env['GCC_VERSION'], '4.8') >= 0:
+ new_env.Append(CCFLAGS='-fsanitize=address')
+ new_env.Append(LINKFLAGS='-fsanitize=address')
+
if env['CLANG']:
swig_env.Append(CCFLAGS=['-Wno-sometimes-uninitialized',
'-Wno-deprecated-register',
'-Wno-tautological-compare'])
- # All supported clang versions have support for UBSan, so if
- # asked to use it, append the compiler and linker flags.
+ # We require clang >= 3.1, so there is no need to check any
+ # versions here.
if GetOption('with_ubsan'):
new_env.Append(CCFLAGS='-fsanitize=undefined')
new_env.Append(LINKFLAGS='-fsanitize=undefined')
+ if GetOption('with_asan'):
+ new_env.Append(CCFLAGS='-fsanitize=address')
+ new_env.Append(LINKFLAGS='-fsanitize=address')
+
werror_env = new_env.Clone()
# Treat warnings as errors but white list some warnings that we
# want to allow (e.g., deprecation warnings).