From 10158b52dcb3b9f1db44d9bd56993ad8cd68912a Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 12 Jul 2021 13:57:14 +0200 Subject: [PATCH] sanitizer_common: fix 32-bit build https://reviews.llvm.org/D105716 enabled thread safety annotations, and that broke 32-bit build: https://green.lab.llvm.org/green/job/lldb-cmake/33604/consoleFull#-77815080549ba4694-19c4-4d7e-bec5-911270d8a58c 1. Enable thread-safety analysis in unit tests (this catches the breakage even in 64-bit mode). 2. Add NO_THREAD_SAFETY_ANALYSIS to sanitizer_allocator_primary32.h to unbreak the build. Reviewed By: melver Differential Revision: https://reviews.llvm.org/D105808 --- compiler-rt/CMakeLists.txt | 6 ++++-- compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 782d34c..1610bbd 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 fb5394c..38d2a7d 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(); } -- 2.7.4