[compiler-rt] 2f6ac22 - sanitizers: turn thread-safety errors into warnings

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 10 11:03:34 PDT 2021


Author: Dmitry Vyukov
Date: 2021-08-10T20:03:30+02:00
New Revision: 2f6ac22b083eb9eedf8a27c0e41cc9550a15739a

URL: https://github.com/llvm/llvm-project/commit/2f6ac22b083eb9eedf8a27c0e41cc9550a15739a
DIFF: https://github.com/llvm/llvm-project/commit/2f6ac22b083eb9eedf8a27c0e41cc9550a15739a.diff

LOG: sanitizers: turn thread-safety errors into warnings

There were 2 issues reported on https://reviews.llvm.org/D105716:
1. FreeBSD phtread.h is annotated with thread-safety attributes
and this causes errors in gtest headers.
2. If sanitizers are compiled with an older versions of clang
(which supports the annotations, but has some false positives
in analysis not present in later versions of clang), compilation
fails with errors.

Switch the errors to warnings by default.
Some CI bots enable COMPILER_RT_ENABLE_WERROR, which should
turn these warnings back into errors.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D107826

Added: 
    

Modified: 
    compiler-rt/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 5229616be4a2..1e242415ffdc 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -363,9 +363,9 @@ append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 SANITIZER_COMMON_CFLAGS)
 
 if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
   list(APPEND THREAD_SAFETY_FLAGS
-      "-Werror=thread-safety"
-      "-Werror=thread-safety-reference"
-      "-Werror=thread-safety-beta"
+      "-Wthread-safety"
+      "-Wthread-safety-reference"
+      "-Wthread-safety-beta"
   )
   list(APPEND SANITIZER_COMMON_CFLAGS ${THREAD_SAFETY_FLAGS})
   string(REPLACE ";" " " thread_safety_flags_space_sep "${THREAD_SAFETY_FLAGS}")
@@ -546,14 +546,6 @@ set(COMPILER_RT_GTEST_CFLAGS
   -I${COMPILER_RT_GTEST_PATH}/include
   -I${COMPILER_RT_GTEST_PATH}
 )
-if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
-  # FreeBSD has its pthread functions marked with thread safety annotations, but
-  # googletest is not compatible with such annotations. Disable the thread
-  # safety warnings-as-errors until googletest has been fixed.
-  list(APPEND NO_THREAD_SAFETY_FLAGS ${THREAD_SAFETY_FLAGS})
-  list(TRANSFORM NO_THREAD_SAFETY_FLAGS REPLACE "error=" "no-")
-  list(APPEND COMPILER_RT_GTEST_CFLAGS ${NO_THREAD_SAFETY_FLAGS})
-endif()
 
 # Mocking support.
 set(COMPILER_RT_GMOCK_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock)


        


More information about the llvm-commits mailing list