diff --git a/compiler-rt/lib/tsan/rtl/CMakeLists.txt b/compiler-rt/lib/tsan/rtl/CMakeLists.txt --- a/compiler-rt/lib/tsan/rtl/CMakeLists.txt +++ b/compiler-rt/lib/tsan/rtl/CMakeLists.txt @@ -271,6 +271,7 @@ $ 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 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h @@ -681,7 +681,7 @@ // 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