DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dengdui Huang <huangdengdui@huawei.com>
To: <dev@dpdk.org>
Cc: <lihuisong@huawei.com>, <fengchengwen@huawei.com>,
	<haijie1@huawei.com>, <liuyonglong@huawei.com>
Subject: [RFC 1/1] build: support ThreadSanitizer
Date: Tue, 8 Apr 2025 21:05:56 +0800	[thread overview]
Message-ID: <20250408130556.1054041-2-huangdengdui@huawei.com> (raw)
In-Reply-To: <20250408130556.1054041-1-huangdengdui@huawei.com>

ThreadSanitizer is a tool that detects data races. It consists of a
compiler instrumentation module and a run-time library.
Typical slowdown introduced by ThreadSanitizer is about 5x-15x.
Typical memory overhead introduced by ThreadSanitizer is about 5x-10x.

UBSan is integrated with gcc and clang and can be enabled via a meson
option: -Db_sanitize=thread.

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
---
 config/meson.build | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/config/meson.build b/config/meson.build
index f31fef216c..dca1e2b5a4 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -519,6 +519,20 @@ if get_option('b_sanitize') == 'address' or get_option('b_sanitize') == 'address
     endif
 endif
 
+if get_option('b_sanitize') == 'thread'
+    if is_windows
+        error('TSan is not supported on windows')
+    endif
+
+    if cc.get_id() == 'gcc'
+        tsan_dep = cc.find_library('tsan', required: true)
+        if (not cc.links('int main(int argc, char *argv[]) { return 0; }',
+                dependencies: tsan_dep))
+            error('broken dependency, "libtsan"')
+        endif
+    endif
+endif
+
 if get_option('default_library') == 'both'
     error( '''
  Unsupported value "both" for "default_library" option.
-- 
2.33.0


      reply	other threads:[~2025-04-08 13:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08 13:05 [RFC 0/1] " Dengdui Huang
2025-04-08 13:05 ` Dengdui Huang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250408130556.1054041-2-huangdengdui@huawei.com \
    --to=huangdengdui@huawei.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=haijie1@huawei.com \
    --cc=lihuisong@huawei.com \
    --cc=liuyonglong@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).