[PATCH] D45487: [tsan] Add interceptors for objc_sync_enter and objc_sync_exit

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 11 10:21:22 PDT 2018


kubamracek added inline comments.


================
Comment at: lib/tsan/CMakeLists.txt:121
     LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
-    LINK_LIBS ${TSAN_LINK_LIBS}
+    LINK_LIBS ${TSAN_LINK_LIBS} objc
     PARENT_TARGET tsan)
----------------
delcypher wrote:
> kubamracek wrote:
> > delcypher wrote:
> > > Does this mean that `clang_rt.tsan` will now **always** link against `libobjc`? Is that really necessary. Won't that mean it gets linked in for sanitized C programs that have absolutely no business doing anything with the ObjectiveC runtime?
> > You're right, this always links libobjc, even into program that are not using Objective-C. I don't know how to avoid this dependency, because the dyld interposition requires us to link against the symbols that we intercept.
> > 
> > On the bright side, libobjc gets loaded into every process on macOS anyway. So I believe this is actually safe and shouldn't break anything.
> Okay. Presumably, TSan will still initialise properly (i.e. the fact that TSan links `libobjc` won't break initialisation order)?
Although libobjc isn't part of libSystem, it's actually loaded by libSystem unconditionally to all processes, and libobjc initializer (`_objc_init`) is called early in process startup. So explicitly linking against libobjc shouldn't really change any initialization order.


https://reviews.llvm.org/D45487





More information about the llvm-commits mailing list