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
This commit is contained in:
parent
1fa4c188b5
commit
2f6ac22b08
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue