diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 782d34c610b8..1610bbd2312a 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -360,11 +360,13 @@ endif() append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 SANITIZER_COMMON_CFLAGS) if(CMAKE_CXX_COMPILER_ID MATCHES Clang) - list(APPEND SANITIZER_COMMON_CFLAGS + list(APPEND THREAD_SAFETY_FLAGS "-Werror=thread-safety" "-Werror=thread-safety-reference" "-Werror=thread-safety-beta" -) + ) + list(APPEND SANITIZER_COMMON_CFLAGS ${THREAD_SAFETY_FLAGS}) + list(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS ${THREAD_SAFETY_FLAGS}) endif() # If we're using MSVC, diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h index fb5394cd39c4..38d2a7d117fb 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h @@ -237,13 +237,13 @@ class SizeClassAllocator32 { // ForceLock() and ForceUnlock() are needed to implement Darwin malloc zone // introspection API. - void ForceLock() { + void ForceLock() NO_THREAD_SAFETY_ANALYSIS { for (uptr i = 0; i < kNumClasses; i++) { GetSizeClassInfo(i)->mutex.Lock(); } } - void ForceUnlock() { + void ForceUnlock() NO_THREAD_SAFETY_ANALYSIS { for (int i = kNumClasses - 1; i >= 0; i--) { GetSizeClassInfo(i)->mutex.Unlock(); }