From 0d46e0e88bdeb8bfff3b30c65002cc34d3b7ba4e Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 9 Apr 2024 10:47:43 +0200 Subject: [PATCH] meson: Add blacklist when compiling with tsan Check whether the compiler actually supports it and if not than warn about it. Note that meson will also suggest that one should use the build-in flag, but this is just sloppy testing for -fsanitize, -fsanitize-blacklist is actually not available as build-in option. v2: define THREAD_SANITIZER to 1 or 0 (suggested by Yonggang Luo) v3: Update comment about meson warning (Dylan Baker) Signed-off-by: Gert Wollny Part-of: --- meson.build | 17 +++++++++++++++++ tsan-blacklist.txt | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 tsan-blacklist.txt diff --git a/meson.build b/meson.build index 7d70033d835..c99b98f542e 100644 --- a/meson.build +++ b/meson.build @@ -1909,6 +1909,23 @@ else asan_c_args = ['-DBUILT_WITH_ASAN=0'] endif +# ThreadSanitizer can't deal with futexes, and reports races for cases we don't care about +# so add a define to work silence these issues. +if get_option('b_sanitize') == 'thread' + pre_args += '-DTHREAD_SANITIZER=1' + # meson versions prior to 1.4 will warn "Consider using the built-in option for sanitizers ..." + # later on because it only checks whether the option starts with "-fsanitize", + # but there is no built-in option for adding a blacklist + tsan_blacklist = '-fsanitize-blacklist=@0@'.format(join_paths(meson.project_source_root(), 'tsan-blacklist.txt')) + if cc.has_argument(tsan_blacklist) + pre_args += tsan_blacklist + else + warning('Compiler does not support "-fsanitize-blacklist", expected race conditions will not be surpressed') + endif +else + pre_args += '-DTHREAD_SANITIZER=0' +endif + yacc_is_bison = true needs_flex_bison = with_any_opengl or with_freedreno_vk or with_intel_tools or with_gallium diff --git a/tsan-blacklist.txt b/tsan-blacklist.txt new file mode 100644 index 00000000000..46f383c4112 --- /dev/null +++ b/tsan-blacklist.txt @@ -0,0 +1,2 @@ +# Placeholder file, will be filled with surpressions for TSAN +