[compiler-rt] 10158b5 - sanitizer_common: fix 32-bit build

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 12 05:03:18 PDT 2021


Author: Dmitry Vyukov
Date: 2021-07-12T14:03:13+02:00
New Revision: 10158b52dcb3b9f1db44d9bd56993ad8cd68912a

URL: https://github.com/llvm/llvm-project/commit/10158b52dcb3b9f1db44d9bd56993ad8cd68912a
DIFF: https://github.com/llvm/llvm-project/commit/10158b52dcb3b9f1db44d9bd56993ad8cd68912a.diff

LOG: 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

Added: 
    

Modified: 
    compiler-rt/CMakeLists.txt
    compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h

Removed: 
    


################################################################################
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();
     }


        


More information about the llvm-commits mailing list