[compiler-rt] 84bec0a - [tsan] Always initialize tsan when building shared lib

Han Zhu via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 23 10:30:28 PST 2023


Author: Han Zhu
Date: 2023-01-23T10:30:18-08:00
New Revision: 84bec0a2192dbde5711d2f66b602bcf7b4f9a72b

URL: https://github.com/llvm/llvm-project/commit/84bec0a2192dbde5711d2f66b602bcf7b4f9a72b
DIFF: https://github.com/llvm/llvm-project/commit/84bec0a2192dbde5711d2f66b602bcf7b4f9a72b.diff

LOG: [tsan] Always initialize tsan when building shared lib

Differential Revision: https://reviews.llvm.org/D142039

Added: 
    

Modified: 
    compiler-rt/lib/tsan/rtl/CMakeLists.txt
    compiler-rt/lib/tsan/rtl/tsan_rtl.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/tsan/rtl/CMakeLists.txt b/compiler-rt/lib/tsan/rtl/CMakeLists.txt
index d6c547bb75ef4..7ad91b3cddd18 100644
--- a/compiler-rt/lib/tsan/rtl/CMakeLists.txt
+++ b/compiler-rt/lib/tsan/rtl/CMakeLists.txt
@@ -271,6 +271,7 @@ else()
               $<TARGET_OBJECTS:RTUbsan.${arch}>
       ADDITIONAL_HEADERS ${TSAN_HEADERS}
       CFLAGS ${TSAN_RTL_DYNAMIC_CFLAGS}
+      DEFS SANITIZER_SHARED
       LINK_LIBS ${TSAN_DYNAMIC_LINK_LIBS}
       LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}
       PARENT_TARGET tsan)

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index 7f5de6bf907f8..e02ce5a52ade1 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -681,7 +681,7 @@ void LazyInitialize(ThreadState *thr) {
   // If we can use .preinit_array, assume that __tsan_init
   // called from .preinit_array initializes runtime before
   // any instrumented code except ANDROID.
-#if (!SANITIZER_CAN_USE_PREINIT_ARRAY || defined(__ANDROID__))
+#if (!SANITIZER_CAN_USE_PREINIT_ARRAY || defined(SANITIZER_SHARED))
   if (UNLIKELY(!is_initialized))
     Initialize(thr);
 #endif


        


More information about the llvm-commits mailing list