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

Chris Apple via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 13:20:01 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);
----------------
cjappl wrote:

Good question, maybe @yln can help me answer it. This was following the pattern I found for libdispatch, I don't know if it is necessary or not.

https://github.com/llvm/llvm-project/blob/f7669ba3d9443bc95dd63fa25beea13e6265fdc5/compiler-rt/lib/tsan/rtl/tsan_interceptors_libdispatch.cpp#L226-L247

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


More information about the llvm-commits mailing list