[PATCH] D74059: [TSan] Ensure we can compile the runtime with older SDKs

Julian Lettner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 5 08:31:09 PST 2020


yln created this revision.
yln added reviewers: dmajor, hans.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.
yln added a comment.

I can land this as soon as @dmajor confirms that it fixes their build.


One of my changes [1] included in this release silently bumped the
minimal macOS SDK required for building the TSan runtime to SDK 10.12.
Let's ensure release 10 does not unexpectedly break builders with old
SDKs and add proper minimal SDK checking in CMake for subsequent
releases.

This fix `#ifdef`s out interceptors for newer APIs.  Note that the
resulting TSan runtime is less complete: when these newer APIs are used
TSan will report false positives.

Fixes llvm 10 release blocker: #44682
https://bugs.llvm.org/show_bug.cgi?id=44682

[1] 894abb46f891cba2e0ef581650f27f512a7824b4


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74059

Files:
  compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp


Index: compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp
===================================================================
--- compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp
+++ compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp
@@ -23,9 +23,12 @@
 #include <errno.h>
 #include <libkern/OSAtomic.h>
 #include <objc/objc-sync.h>
-#include <os/lock.h>
 #include <sys/ucontext.h>
 
+#if defined(__has_include) && __has_include(<os/lock.h>)
+#include <os/lock.h>
+#endif
+
 #if defined(__has_include) && __has_include(<xpc/xpc.h>)
 #include <xpc/xpc.h>
 #endif  // #if defined(__has_include) && __has_include(<xpc/xpc.h>)
@@ -247,6 +250,8 @@
   REAL(os_lock_unlock)(lock);
 }
 
+#if defined(__has_include) && __has_include(<os/lock.h>)
+
 TSAN_INTERCEPTOR(void, os_unfair_lock_lock, os_unfair_lock_t lock) {
   if (!cur_thread()->is_inited || cur_thread()->is_dead) {
     return REAL(os_unfair_lock_lock)(lock);
@@ -286,6 +291,8 @@
   REAL(os_unfair_lock_unlock)(lock);
 }
 
+#endif  // #if defined(__has_include) && __has_include(<os/lock.h>)
+
 #if defined(__has_include) && __has_include(<xpc/xpc.h>)
 
 TSAN_INTERCEPTOR(void, xpc_connection_set_event_handler,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74059.242635.patch
Type: text/x-patch
Size: 1168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200205/678465b3/attachment.bin>


More information about the llvm-commits mailing list