[tsan] Always initialize tsan when building shared lib

Differential Revision: https://reviews.llvm.org/D142039
This commit is contained in:
Han Zhu 2023-01-13 12:18:32 -08:00
parent 0b92f85270
commit 84bec0a219
2 changed files with 2 additions and 1 deletions

View File

@ -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)

View File

@ -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