Skip to content

Commit 2f6ac22

Browse files
committed
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
1 parent 1fa4c18 commit 2f6ac22

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

compiler-rt/CMakeLists.txt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 SANITIZER_COMMON_CFLAGS)
363363

364364
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
365365
list(APPEND THREAD_SAFETY_FLAGS
366-
"-Werror=thread-safety"
367-
"-Werror=thread-safety-reference"
368-
"-Werror=thread-safety-beta"
366+
"-Wthread-safety"
367+
"-Wthread-safety-reference"
368+
"-Wthread-safety-beta"
369369
)
370370
list(APPEND SANITIZER_COMMON_CFLAGS ${THREAD_SAFETY_FLAGS})
371371
string(REPLACE ";" " " thread_safety_flags_space_sep "${THREAD_SAFETY_FLAGS}")
@@ -546,14 +546,6 @@ set(COMPILER_RT_GTEST_CFLAGS
546546
-I${COMPILER_RT_GTEST_PATH}/include
547547
-I${COMPILER_RT_GTEST_PATH}
548548
)
549-
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
550-
# FreeBSD has its pthread functions marked with thread safety annotations, but
551-
# googletest is not compatible with such annotations. Disable the thread
552-
# safety warnings-as-errors until googletest has been fixed.
553-
list(APPEND NO_THREAD_SAFETY_FLAGS ${THREAD_SAFETY_FLAGS})
554-
list(TRANSFORM NO_THREAD_SAFETY_FLAGS REPLACE "error=" "no-")
555-
list(APPEND COMPILER_RT_GTEST_CFLAGS ${NO_THREAD_SAFETY_FLAGS})
556-
endif()
557549

558550
# Mocking support.
559551
set(COMPILER_RT_GMOCK_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock)

0 commit comments

Comments
 (0)