[compiler-rt] [tsan] Export __cxa_guard_ interceptors from TSan runtime. (PR #171921)

Alexey Samsonov via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 11 14:52:09 PST 2025


https://github.com/vonosmas created https://github.com/llvm/llvm-project/pull/171921

These functions from C++ ABI are defined in
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp and are supposed to replace implementations from libstdc++/libc++abi.

We need to export them similar to why we need to export other interceptors and TSan runtime functions - e.g. if a dlopen-ed shared library depends on `__cxa_guard_acquire`, it needs to pick up the exported definition from the TSan runtime that was linked into the main executable calling the dlopen()

However, because the `__cxa_guard_` functions don't use traditional interceptor machinery, they are omitted from the auto-generated `libclang_rt.tsan.a.syms` files. Fix this by adding them to tsan.syms.extra file explicitly.

>From 6f062b9096099c44c33bf68f49f9f345b1ac2ae3 Mon Sep 17 00:00:00 2001
From: Alexey Samsonov <vonosmas at gmail.com>
Date: Thu, 11 Dec 2025 22:50:39 +0000
Subject: [PATCH] [tsan] Export __cxa_guard_ interceptors from TSan runtime.

These functions from C++ ABI are defined in
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp and are supposed to replace implementations from libstdc++/libc++abi.

We need to export them similar to why we need to export other
interceptors and TSan runtime functions - e.g. if a dlopen-ed
shared library depends on __cxa_guard_acquire, it needs to pick up the exported definition from the TSan runtime that was
linked into the main executable calling the dlopen()

However, because the __cxa_guard_ functions don't use traditional interceptor machinery, they are omitted from the auto-generated libclang_rt.tsan.a.syms files. Fix this by
adding them to tsan.syms.extra file explicitly.
---
 compiler-rt/lib/tsan/rtl/tsan.syms.extra | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/compiler-rt/lib/tsan/rtl/tsan.syms.extra b/compiler-rt/lib/tsan/rtl/tsan.syms.extra
index 6416e5d47fc41..03d17d21e74e8 100644
--- a/compiler-rt/lib/tsan/rtl/tsan.syms.extra
+++ b/compiler-rt/lib/tsan/rtl/tsan.syms.extra
@@ -1,3 +1,6 @@
+__cxa_guard_acquire
+__cxa_guard_abort
+__cxa_guard_release
 __tsan_init
 __tsan_flush_memory
 __tsan_read*



More information about the llvm-commits mailing list