scons: fix sanitizer flags with multiple sanitizers
There has been some problem when using address and undefined-behavior sanitizers at the same time. This patch will look for the special case where both are enabled at once and change the flags passed to the compiler to reflect this.
This commit is contained in:
parent
faaf2d396f
commit
4b7bc5b1e1
1 changed files with 21 additions and 9 deletions
|
@ -1085,19 +1085,26 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs):
|
||||||
'-Wno-maybe-uninitialized',
|
'-Wno-maybe-uninitialized',
|
||||||
'-Wno-type-limits'])
|
'-Wno-type-limits'])
|
||||||
|
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
new_env.Append(CCFLAGS=['-fsanitize=address,undefined',
|
||||||
|
'-fno-omit-frame-pointer'])
|
||||||
|
new_env.Append(LINKFLAGS='-fsanitize=address,undefined')
|
||||||
|
else:
|
||||||
|
new_env.Append(CCFLAGS=['-fsanitize=address',
|
||||||
|
'-fno-omit-frame-pointer'])
|
||||||
|
new_env.Append(LINKFLAGS='-fsanitize=address')
|
||||||
# Only gcc >= 4.9 supports UBSan, so check both the version
|
# Only gcc >= 4.9 supports UBSan, so check both the version
|
||||||
# and the command-line option before adding the compiler and
|
# and the command-line option before adding the compiler and
|
||||||
# linker flags.
|
# linker flags.
|
||||||
if GetOption('with_ubsan') and \
|
elif GetOption('with_ubsan') and \
|
||||||
compareVersions(env['GCC_VERSION'], '4.9') >= 0:
|
compareVersions(env['GCC_VERSION'], '4.9') >= 0:
|
||||||
new_env.Append(CCFLAGS='-fsanitize=undefined')
|
new_env.Append(CCFLAGS='-fsanitize=undefined')
|
||||||
new_env.Append(LINKFLAGS='-fsanitize=undefined')
|
new_env.Append(LINKFLAGS='-fsanitize=undefined')
|
||||||
|
|
||||||
# The address sanitizer is available for gcc >= 4.8
|
|
||||||
if GetOption('with_asan'):
|
|
||||||
new_env.Append(CCFLAGS=['-fsanitize=address',
|
|
||||||
'-fno-omit-frame-pointer'])
|
|
||||||
new_env.Append(LINKFLAGS='-fsanitize=address')
|
|
||||||
|
|
||||||
if env['CLANG']:
|
if env['CLANG']:
|
||||||
swig_env.Append(CCFLAGS=['-Wno-sometimes-uninitialized',
|
swig_env.Append(CCFLAGS=['-Wno-sometimes-uninitialized',
|
||||||
|
@ -1107,10 +1114,15 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs):
|
||||||
# We require clang >= 3.1, so there is no need to check any
|
# We require clang >= 3.1, so there is no need to check any
|
||||||
# versions here.
|
# versions here.
|
||||||
if GetOption('with_ubsan'):
|
if GetOption('with_ubsan'):
|
||||||
new_env.Append(CCFLAGS='-fsanitize=undefined')
|
if GetOption('with_asan'):
|
||||||
new_env.Append(LINKFLAGS='-fsanitize=undefined')
|
new_env.Append(CCFLAGS=['-fsanitize=address,undefined',
|
||||||
|
'-fno-omit-frame-pointer'])
|
||||||
|
new_env.Append(LINKFLAGS='-fsanitize=address,undefined')
|
||||||
|
else:
|
||||||
|
new_env.Append(CCFLAGS='-fsanitize=undefined')
|
||||||
|
new_env.Append(LINKFLAGS='-fsanitize=undefined')
|
||||||
|
|
||||||
if GetOption('with_asan'):
|
elif GetOption('with_asan'):
|
||||||
new_env.Append(CCFLAGS=['-fsanitize=address',
|
new_env.Append(CCFLAGS=['-fsanitize=address',
|
||||||
'-fno-omit-frame-pointer'])
|
'-fno-omit-frame-pointer'])
|
||||||
new_env.Append(LINKFLAGS='-fsanitize=address')
|
new_env.Append(LINKFLAGS='-fsanitize=address')
|
||||||
|
|
Loading…
Reference in a new issue