summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
Diffstat (limited to 'SConstruct')
-rwxr-xr-xSConstruct35
1 files changed, 35 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
index 095b58be4..36db2162c 100755
--- a/SConstruct
+++ b/SConstruct
@@ -473,6 +473,25 @@ if main['GCC']:
if compareVersions(gcc_version, "5.0") > 0:
main.Append(CCFLAGS=['-Wno-error=suggest-override'])
+ # The address sanitizer is available for gcc >= 4.8
+ if GetOption('with_asan'):
+ if GetOption('with_ubsan') and \
+ compareVersions(env['GCC_VERSION'], '4.9') >= 0:
+ env.Append(CCFLAGS=['-fsanitize=address,undefined',
+ '-fno-omit-frame-pointer'],
+ LINKFLAGS='-fsanitize=address,undefined')
+ else:
+ env.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(env['GCC_VERSION'], '4.9') >= 0:
+ env.Append(CCFLAGS='-fsanitize=undefined')
+ env.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
@@ -513,6 +532,22 @@ elif main['CLANG']:
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'):
+ env.Append(CCFLAGS=['-fsanitize=address,undefined',
+ '-fno-omit-frame-pointer'],
+ LINKFLAGS='-fsanitize=address,undefined')
+ else:
+ env.Append(CCFLAGS='-fsanitize=undefined',
+ LINKFLAGS='-fsanitize=undefined')
+
+ elif GetOption('with_asan'):
+ env.Append(CCFLAGS=['-fsanitize=address',
+ '-fno-omit-frame-pointer'],
+ LINKFLAGS='-fsanitize=address')
+
else:
print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal,
print "Don't know what compiler options to use for your compiler."