[compiler-rt] Change linkage for friendship with modules (PR #166399)

Sergey Chebotarev via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 23 21:12:25 PST 2025


https://github.com/d7d1cd updated https://github.com/llvm/llvm-project/pull/166399

>From 175189063a4c46397ca8ed7f2468950e7784f778 Mon Sep 17 00:00:00 2001
From: Sergey Chebotarev <50007587+d7d1cd at users.noreply.github.com>
Date: Tue, 4 Nov 2025 16:46:52 +0000
Subject: [PATCH 1/6] Change linkage

---
 .../include/sanitizer/tsan_interface.h        | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/compiler-rt/include/sanitizer/tsan_interface.h b/compiler-rt/include/sanitizer/tsan_interface.h
index e11a4175cd8ed..dae075106426f 100644
--- a/compiler-rt/include/sanitizer/tsan_interface.h
+++ b/compiler-rt/include/sanitizer/tsan_interface.h
@@ -38,39 +38,39 @@ void SANITIZER_CDECL __tsan_release(void *addr);
 
 // Mutex has static storage duration and no-op constructor and destructor.
 // This effectively makes tsan ignore destroy annotation.
-static const unsigned __tsan_mutex_linker_init      = 1 << 0;
+inline constexpr unsigned __tsan_mutex_linker_init      = 1 << 0;
 // Mutex is write reentrant.
-static const unsigned __tsan_mutex_write_reentrant  = 1 << 1;
+inline constexpr unsigned __tsan_mutex_write_reentrant  = 1 << 1;
 // Mutex is read reentrant.
-static const unsigned __tsan_mutex_read_reentrant   = 1 << 2;
+inline constexpr unsigned __tsan_mutex_read_reentrant   = 1 << 2;
 // Mutex does not have static storage duration, and must not be used after
 // its destructor runs.  The opposite of __tsan_mutex_linker_init.
 // If this flag is passed to __tsan_mutex_destroy, then the destruction
 // is ignored unless this flag was previously set on the mutex.
-static const unsigned __tsan_mutex_not_static       = 1 << 8;
+inline constexpr unsigned __tsan_mutex_not_static       = 1 << 8;
 
 // Mutex operation flags:
 
 // Denotes read lock operation.
-static const unsigned __tsan_mutex_read_lock = 1 << 3;
+inline constexpr unsigned __tsan_mutex_read_lock = 1 << 3;
 // Denotes try lock operation.
-static const unsigned __tsan_mutex_try_lock = 1 << 4;
+inline constexpr unsigned __tsan_mutex_try_lock = 1 << 4;
 // Denotes that a try lock operation has failed to acquire the mutex.
-static const unsigned __tsan_mutex_try_lock_failed = 1 << 5;
+inline constexpr unsigned __tsan_mutex_try_lock_failed = 1 << 5;
 // Denotes that the lock operation acquires multiple recursion levels.
 // Number of levels is passed in recursion parameter.
 // This is useful for annotation of e.g. Java builtin monitors,
 // for which wait operation releases all recursive acquisitions of the mutex.
-static const unsigned __tsan_mutex_recursive_lock = 1 << 6;
+inline constexpr unsigned __tsan_mutex_recursive_lock = 1 << 6;
 // Denotes that the unlock operation releases all recursion levels.
 // Number of released levels is returned and later must be passed to
 // the corresponding __tsan_mutex_post_lock annotation.
-static const unsigned __tsan_mutex_recursive_unlock = 1 << 7;
+inline constexpr unsigned __tsan_mutex_recursive_unlock = 1 << 7;
 
 // Convenient composed constants.
-static const unsigned __tsan_mutex_try_read_lock =
+inline constexpr unsigned __tsan_mutex_try_read_lock =
     __tsan_mutex_read_lock | __tsan_mutex_try_lock;
-static const unsigned __tsan_mutex_try_read_lock_failed =
+inline constexpr unsigned __tsan_mutex_try_read_lock_failed =
     __tsan_mutex_try_read_lock | __tsan_mutex_try_lock_failed;
 
 // Annotate creation of a mutex.

>From c7a0caf01a1490a6fd4c49c2cf5df08ea2d66c2d Mon Sep 17 00:00:00 2001
From: Sergey Chebotarev <50007587+d7d1cd at users.noreply.github.com>
Date: Wed, 5 Nov 2025 13:07:45 +0000
Subject: [PATCH 2/6] Review fix

---
 .../include/sanitizer/tsan_interface.h        | 75 ++++++++++---------
 1 file changed, 39 insertions(+), 36 deletions(-)

diff --git a/compiler-rt/include/sanitizer/tsan_interface.h b/compiler-rt/include/sanitizer/tsan_interface.h
index dae075106426f..6127ec8de04ef 100644
--- a/compiler-rt/include/sanitizer/tsan_interface.h
+++ b/compiler-rt/include/sanitizer/tsan_interface.h
@@ -36,42 +36,45 @@ void SANITIZER_CDECL __tsan_release(void *addr);
 // the flags may be passed to __tsan_mutex_pre_lock/__tsan_mutex_post_lock
 // annotations.
 
-// Mutex has static storage duration and no-op constructor and destructor.
-// This effectively makes tsan ignore destroy annotation.
-inline constexpr unsigned __tsan_mutex_linker_init      = 1 << 0;
-// Mutex is write reentrant.
-inline constexpr unsigned __tsan_mutex_write_reentrant  = 1 << 1;
-// Mutex is read reentrant.
-inline constexpr unsigned __tsan_mutex_read_reentrant   = 1 << 2;
-// Mutex does not have static storage duration, and must not be used after
-// its destructor runs.  The opposite of __tsan_mutex_linker_init.
-// If this flag is passed to __tsan_mutex_destroy, then the destruction
-// is ignored unless this flag was previously set on the mutex.
-inline constexpr unsigned __tsan_mutex_not_static       = 1 << 8;
-
-// Mutex operation flags:
-
-// Denotes read lock operation.
-inline constexpr unsigned __tsan_mutex_read_lock = 1 << 3;
-// Denotes try lock operation.
-inline constexpr unsigned __tsan_mutex_try_lock = 1 << 4;
-// Denotes that a try lock operation has failed to acquire the mutex.
-inline constexpr unsigned __tsan_mutex_try_lock_failed = 1 << 5;
-// Denotes that the lock operation acquires multiple recursion levels.
-// Number of levels is passed in recursion parameter.
-// This is useful for annotation of e.g. Java builtin monitors,
-// for which wait operation releases all recursive acquisitions of the mutex.
-inline constexpr unsigned __tsan_mutex_recursive_lock = 1 << 6;
-// Denotes that the unlock operation releases all recursion levels.
-// Number of released levels is returned and later must be passed to
-// the corresponding __tsan_mutex_post_lock annotation.
-inline constexpr unsigned __tsan_mutex_recursive_unlock = 1 << 7;
-
-// Convenient composed constants.
-inline constexpr unsigned __tsan_mutex_try_read_lock =
-    __tsan_mutex_read_lock | __tsan_mutex_try_lock;
-inline constexpr unsigned __tsan_mutex_try_read_lock_failed =
-    __tsan_mutex_try_read_lock | __tsan_mutex_try_lock_failed;
+enum : unsigned
+{
+    // Mutex has static storage duration and no-op constructor and destructor.
+    // This effectively makes tsan ignore destroy annotation.
+    __tsan_mutex_linker_init      = 1 << 0,
+    // Mutex is write reentrant.
+    __tsan_mutex_write_reentrant  = 1 << 1,
+    // Mutex is read reentrant.
+    __tsan_mutex_read_reentrant   = 1 << 2,
+    // Mutex does not have static storage duration, and must not be used after
+    // its destructor runs.  The opposite of __tsan_mutex_linker_init.
+    // If this flag is passed to __tsan_mutex_destroy, then the destruction
+    // is ignored unless this flag was previously set on the mutex.
+    __tsan_mutex_not_static       = 1 << 8,
+
+    // Mutex operation flags:
+
+    // Denotes read lock operation.
+    __tsan_mutex_read_lock = 1 << 3,
+    // Denotes try lock operation.
+    __tsan_mutex_try_lock = 1 << 4,
+    // Denotes that a try lock operation has failed to acquire the mutex.
+    __tsan_mutex_try_lock_failed = 1 << 5,
+    // Denotes that the lock operation acquires multiple recursion levels.
+    // Number of levels is passed in recursion parameter.
+    // This is useful for annotation of e.g. Java builtin monitors,
+    // for which wait operation releases all recursive acquisitions of the mutex.
+    __tsan_mutex_recursive_lock = 1 << 6,
+    // Denotes that the unlock operation releases all recursion levels.
+    // Number of released levels is returned and later must be passed to
+    // the corresponding __tsan_mutex_post_lock annotation.
+    __tsan_mutex_recursive_unlock = 1 << 7,
+
+    // Convenient composed constants.
+    __tsan_mutex_try_read_lock = 
+        __tsan_mutex_read_lock | __tsan_mutex_try_lock,
+    __tsan_mutex_try_read_lock_failed =
+        __tsan_mutex_try_read_lock | __tsan_mutex_try_lock_failed
+};
 
 // Annotate creation of a mutex.
 // Supported flags: mutex creation flags.

>From a4391a712607bba5fb4a42df312c99697895dbe9 Mon Sep 17 00:00:00 2001
From: Sergey Chebotarev <50007587+d7d1cd at users.noreply.github.com>
Date: Sun, 23 Nov 2025 17:39:10 +0000
Subject: [PATCH 3/6] wip

---
 .../include/sanitizer/tsan_interface.h        | 75 +++++++++----------
 1 file changed, 37 insertions(+), 38 deletions(-)

diff --git a/compiler-rt/include/sanitizer/tsan_interface.h b/compiler-rt/include/sanitizer/tsan_interface.h
index 6127ec8de04ef..53b97ff939546 100644
--- a/compiler-rt/include/sanitizer/tsan_interface.h
+++ b/compiler-rt/include/sanitizer/tsan_interface.h
@@ -36,44 +36,43 @@ void SANITIZER_CDECL __tsan_release(void *addr);
 // the flags may be passed to __tsan_mutex_pre_lock/__tsan_mutex_post_lock
 // annotations.
 
-enum : unsigned
-{
-    // Mutex has static storage duration and no-op constructor and destructor.
-    // This effectively makes tsan ignore destroy annotation.
-    __tsan_mutex_linker_init      = 1 << 0,
-    // Mutex is write reentrant.
-    __tsan_mutex_write_reentrant  = 1 << 1,
-    // Mutex is read reentrant.
-    __tsan_mutex_read_reentrant   = 1 << 2,
-    // Mutex does not have static storage duration, and must not be used after
-    // its destructor runs.  The opposite of __tsan_mutex_linker_init.
-    // If this flag is passed to __tsan_mutex_destroy, then the destruction
-    // is ignored unless this flag was previously set on the mutex.
-    __tsan_mutex_not_static       = 1 << 8,
-
-    // Mutex operation flags:
-
-    // Denotes read lock operation.
-    __tsan_mutex_read_lock = 1 << 3,
-    // Denotes try lock operation.
-    __tsan_mutex_try_lock = 1 << 4,
-    // Denotes that a try lock operation has failed to acquire the mutex.
-    __tsan_mutex_try_lock_failed = 1 << 5,
-    // Denotes that the lock operation acquires multiple recursion levels.
-    // Number of levels is passed in recursion parameter.
-    // This is useful for annotation of e.g. Java builtin monitors,
-    // for which wait operation releases all recursive acquisitions of the mutex.
-    __tsan_mutex_recursive_lock = 1 << 6,
-    // Denotes that the unlock operation releases all recursion levels.
-    // Number of released levels is returned and later must be passed to
-    // the corresponding __tsan_mutex_post_lock annotation.
-    __tsan_mutex_recursive_unlock = 1 << 7,
-
-    // Convenient composed constants.
-    __tsan_mutex_try_read_lock = 
-        __tsan_mutex_read_lock | __tsan_mutex_try_lock,
-    __tsan_mutex_try_read_lock_failed =
-        __tsan_mutex_try_read_lock | __tsan_mutex_try_lock_failed
+enum : unsigned {
+  // Mutex has static storage duration and no-op constructor and destructor.
+  // This effectively makes tsan ignore destroy annotation.
+  __tsan_mutex_linker_init      = 1 << 0,
+  // Mutex is write reentrant.
+  __tsan_mutex_write_reentrant  = 1 << 1,
+  // Mutex is read reentrant.
+  __tsan_mutex_read_reentrant   = 1 << 2,
+  // Mutex does not have static storage duration, and must not be used after
+  // its destructor runs.  The opposite of __tsan_mutex_linker_init.
+  // If this flag is passed to __tsan_mutex_destroy, then the destruction
+  // is ignored unless this flag was previously set on the mutex.
+  __tsan_mutex_not_static       = 1 << 8,
+
+  // Mutex operation flags:
+
+  // Denotes read lock operation.
+  __tsan_mutex_read_lock = 1 << 3,
+  // Denotes try lock operation.
+  __tsan_mutex_try_lock = 1 << 4,
+  // Denotes that a try lock operation has failed to acquire the mutex.
+  __tsan_mutex_try_lock_failed = 1 << 5,
+  // Denotes that the lock operation acquires multiple recursion levels.
+  // Number of levels is passed in recursion parameter.
+  // This is useful for annotation of e.g. Java builtin monitors,
+  // for which wait operation releases all recursive acquisitions of the mutex.
+  __tsan_mutex_recursive_lock = 1 << 6,
+  // Denotes that the unlock operation releases all recursion levels.
+  // Number of released levels is returned and later must be passed to
+  // the corresponding __tsan_mutex_post_lock annotation.
+  __tsan_mutex_recursive_unlock = 1 << 7,
+
+  // Convenient composed constants.
+  __tsan_mutex_try_read_lock = 
+      __tsan_mutex_read_lock | __tsan_mutex_try_lock,
+  __tsan_mutex_try_read_lock_failed =
+      __tsan_mutex_try_read_lock | __tsan_mutex_try_lock_failed
 };
 
 // Annotate creation of a mutex.

>From 2423d9a3bffd1053daba109907174fc4542be75b Mon Sep 17 00:00:00 2001
From: Sergey Chebotarev <50007587+d7d1cd at users.noreply.github.com>
Date: Sun, 23 Nov 2025 17:49:11 +0000
Subject: [PATCH 4/6] wip

---
 compiler-rt/include/sanitizer/tsan_interface.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/compiler-rt/include/sanitizer/tsan_interface.h b/compiler-rt/include/sanitizer/tsan_interface.h
index 53b97ff939546..e9718fe8827a6 100644
--- a/compiler-rt/include/sanitizer/tsan_interface.h
+++ b/compiler-rt/include/sanitizer/tsan_interface.h
@@ -39,16 +39,16 @@ void SANITIZER_CDECL __tsan_release(void *addr);
 enum : unsigned {
   // Mutex has static storage duration and no-op constructor and destructor.
   // This effectively makes tsan ignore destroy annotation.
-  __tsan_mutex_linker_init      = 1 << 0,
+  __tsan_mutex_linker_init = 1 << 0,
   // Mutex is write reentrant.
-  __tsan_mutex_write_reentrant  = 1 << 1,
+  __tsan_mutex_write_reentrant = 1 << 1,
   // Mutex is read reentrant.
-  __tsan_mutex_read_reentrant   = 1 << 2,
+  __tsan_mutex_read_reentrant = 1 << 2,
   // Mutex does not have static storage duration, and must not be used after
   // its destructor runs.  The opposite of __tsan_mutex_linker_init.
   // If this flag is passed to __tsan_mutex_destroy, then the destruction
   // is ignored unless this flag was previously set on the mutex.
-  __tsan_mutex_not_static       = 1 << 8,
+  __tsan_mutex_not_static = 1 << 8,
 
   // Mutex operation flags:
 
@@ -69,10 +69,8 @@ enum : unsigned {
   __tsan_mutex_recursive_unlock = 1 << 7,
 
   // Convenient composed constants.
-  __tsan_mutex_try_read_lock = 
-      __tsan_mutex_read_lock | __tsan_mutex_try_lock,
-  __tsan_mutex_try_read_lock_failed =
-      __tsan_mutex_try_read_lock | __tsan_mutex_try_lock_failed
+  __tsan_mutex_try_read_lock = __tsan_mutex_read_lock | __tsan_mutex_try_lock,
+  __tsan_mutex_try_read_lock_failed = __tsan_mutex_try_read_lock | __tsan_mutex_try_lock_failed
 };
 
 // Annotate creation of a mutex.

>From efad578c8805a151ff6d350d3b1d81d9633940a3 Mon Sep 17 00:00:00 2001
From: Sergey Chebotarev <50007587+d7d1cd at users.noreply.github.com>
Date: Sun, 23 Nov 2025 17:51:30 +0000
Subject: [PATCH 5/6] Merge branch 'friendship_with_modules' of
 https://github.com/d7d1cd/llvm-project into friendship_with_modules


>From 04e2d0435808f88181be546802ca3a8a7fbca1bc Mon Sep 17 00:00:00 2001
From: Sergey Chebotarev <50007587+d7d1cd at users.noreply.github.com>
Date: Sun, 23 Nov 2025 18:01:09 +0000
Subject: [PATCH 6/6] wip

---
 compiler-rt/include/sanitizer/tsan_interface.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/include/sanitizer/tsan_interface.h b/compiler-rt/include/sanitizer/tsan_interface.h
index e9718fe8827a6..6a8f9cf502ef5 100644
--- a/compiler-rt/include/sanitizer/tsan_interface.h
+++ b/compiler-rt/include/sanitizer/tsan_interface.h
@@ -70,7 +70,8 @@ enum : unsigned {
 
   // Convenient composed constants.
   __tsan_mutex_try_read_lock = __tsan_mutex_read_lock | __tsan_mutex_try_lock,
-  __tsan_mutex_try_read_lock_failed = __tsan_mutex_try_read_lock | __tsan_mutex_try_lock_failed
+  __tsan_mutex_try_read_lock_failed =
+      __tsan_mutex_try_read_lock | __tsan_mutex_try_lock_failed
 };
 
 // Annotate creation of a mutex.



More information about the llvm-commits mailing list