[compiler-rt] Add aligned_alloc to macOS tsan interceptors (PR #79198)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 12:32:59 PST 2024


================
@@ -815,14 +816,23 @@ TSAN_INTERCEPTOR(void*, memalign, uptr align, uptr sz) {
 #define TSAN_MAYBE_INTERCEPT_MEMALIGN
 #endif
 
-#if !SANITIZER_APPLE
+// aligned_alloc was introduced in macOS 10.15
+// Linking will fail when using an older SDK
+#if !SANITIZER_APPLE || defined(__MAC_10_15)
+// macOS 10.15 is greater than our minimal deployment target.  To ensure we
+// generate a weak reference so the TSan dylib continues to work on older
+// systems, we need to forward declare the intercepted function as "weak
+// imports".
+SANITIZER_WEAK_IMPORT void *aligned_alloc(SIZE_T __alignment, SIZE_T __size);
----------------
vitalybuka wrote:

why do we need to declare SANITIZER_WEAK_IMPORT for !APPLE ?

https://github.com/llvm/llvm-project/pull/79198


More information about the llvm-commits mailing list