diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2014-10-16 05:49:36 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2014-10-16 05:49:36 -0400 |
commit | b14f521e5f16f942a1f13a431dad2a72e8966f21 (patch) | |
tree | 99bb5d51faa8fd4a49eaf19978cd5c3e2373780a /src/SConscript | |
parent | ded540a661d9ff572ca58cd2e990460b2518dc28 (diff) | |
download | gem5-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 'src/SConscript')
-rwxr-xr-x | src/SConscript | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/SConscript b/src/SConscript index 3737ef51b..ef729cb33 100755 --- a/src/SConscript +++ b/src/SConscript @@ -953,6 +953,15 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs): if compareVersions(env['GCC_VERSION'], '4.7') >= 0: new_env.Append(CXXFLAGS='-Wdelete-non-virtual-dtor') swig_env.Append(CCFLAGS='-Wno-maybe-uninitialized') + + # Only gcc >= 4.9 supports UBSan, so check both the version + # and the command-line option before adding the compiler and + # linker flags. + if GetOption('with_ubsan') and \ + compareVersions(env['GCC_VERSION'], '4.9') >= 0: + new_env.Append(CCFLAGS='-fsanitize=undefined') + new_env.Append(LINKFLAGS='-fsanitize=undefined') + if env['CLANG']: # Always enable the warning for deletion of derived classes # with non-virtual destructors @@ -966,6 +975,12 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs): '-Wno-deprecated-register', ]) + # All supported clang versions have support for UBSan, so if + # asked to use it, append the compiler and linker flags. + if GetOption('with_ubsan'): + new_env.Append(CCFLAGS='-fsanitize=undefined') + new_env.Append(LINKFLAGS='-fsanitize=undefined') + werror_env = new_env.Clone() werror_env.Append(CCFLAGS='-Werror') |