Merge pull request #31174 from qarmin/thread_sanitizer

Added Thread Sanitizer
This commit is contained in:
Rémi Verschelde 2019-08-07 13:21:33 +02:00 committed by GitHub
commit 1f2bcb8f02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -35,6 +35,7 @@ def get_opts():
BoolVariable('use_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False), BoolVariable('use_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False),
BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False), BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False),
BoolVariable('use_lsan', 'Use LLVM/GCC compiler leak sanitizer (LSAN))', False), BoolVariable('use_lsan', 'Use LLVM/GCC compiler leak sanitizer (LSAN))', False),
BoolVariable('use_tsan', 'Use LLVM/GCC compiler thread sanitizer (TSAN))', False),
EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')), EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')),
BoolVariable('separate_debug_symbols', 'Create a separate file containing debugging symbols', False), BoolVariable('separate_debug_symbols', 'Create a separate file containing debugging symbols', False),
BoolVariable('execinfo', 'Use libexecinfo on systems where glibc is not available', False), BoolVariable('execinfo', 'Use libexecinfo on systems where glibc is not available', False),
@ -99,7 +100,7 @@ def configure(env):
env.extra_suffix = ".llvm" + env.extra_suffix env.extra_suffix = ".llvm" + env.extra_suffix
if env['use_ubsan'] or env['use_asan'] or env['use_lsan']: if env['use_ubsan'] or env['use_asan'] or env['use_lsan'] or env['use_tsan']:
env.extra_suffix += "s" env.extra_suffix += "s"
if env['use_ubsan']: if env['use_ubsan']:
@ -114,6 +115,10 @@ def configure(env):
env.Append(CCFLAGS=['-fsanitize=leak']) env.Append(CCFLAGS=['-fsanitize=leak'])
env.Append(LINKFLAGS=['-fsanitize=leak']) env.Append(LINKFLAGS=['-fsanitize=leak'])
if env['use_tsan']:
env.Append(CCFLAGS=['-fsanitize=thread'])
env.Append(LINKFLAGS=['-fsanitize=thread'])
if env['use_lto']: if env['use_lto']:
env.Append(CCFLAGS=['-flto']) env.Append(CCFLAGS=['-flto'])
if not env['use_llvm'] and env.GetOption("num_jobs") > 1: if not env['use_llvm'] and env.GetOption("num_jobs") > 1:

View file

@ -64,6 +64,7 @@ def get_opts():
BoolVariable('use_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False), BoolVariable('use_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False),
BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False), BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False),
BoolVariable('use_lsan', 'Use LLVM/GCC compiler leak sanitizer (LSAN))', False), BoolVariable('use_lsan', 'Use LLVM/GCC compiler leak sanitizer (LSAN))', False),
BoolVariable('use_tsan', 'Use LLVM/GCC compiler thread sanitizer (TSAN))', False),
BoolVariable('pulseaudio', 'Detect and use PulseAudio', True), BoolVariable('pulseaudio', 'Detect and use PulseAudio', True),
BoolVariable('udev', 'Use udev for gamepad connection callbacks', False), BoolVariable('udev', 'Use udev for gamepad connection callbacks', False),
EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')), EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')),
@ -140,7 +141,7 @@ def configure(env):
print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.") print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.")
sys.exit(255) sys.exit(255)
if env['use_ubsan'] or env['use_asan'] or env['use_lsan']: if env['use_ubsan'] or env['use_asan'] or env['use_lsan'] or env['use_tsan']:
env.extra_suffix += "s" env.extra_suffix += "s"
if env['use_ubsan']: if env['use_ubsan']:
@ -155,6 +156,10 @@ def configure(env):
env.Append(CCFLAGS=['-fsanitize=leak']) env.Append(CCFLAGS=['-fsanitize=leak'])
env.Append(LINKFLAGS=['-fsanitize=leak']) env.Append(LINKFLAGS=['-fsanitize=leak'])
if env['use_tsan']:
env.Append(CCFLAGS=['-fsanitize=thread'])
env.Append(LINKFLAGS=['-fsanitize=thread'])
if env['use_lto']: if env['use_lto']:
if not env['use_llvm'] and env.GetOption("num_jobs") > 1: if not env['use_llvm'] and env.GetOption("num_jobs") > 1:
env.Append(CCFLAGS=['-flto']) env.Append(CCFLAGS=['-flto'])