mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-29 21:24:04 +00:00
[libc++] Disable coverage with sanitize-coverage=0
When building libcxx, libcxxabi, and libunwind the build environment may specify any number of sanitizers. For some build feature tests these sanitizers must be disabled to prevent spurious linking errors. With -fsanitize= this is straight forward with -fno-sanitize=all. With -fsanitize-coverage= there is no -fno-sanitize-coverage=all, but there is the equivalent undocumented but tested -fsanitize-coverage=0. The current build rules fail to disable 'trace-pc-guard'. By disabling all sanitize-coverage flags, including 'trace-pc-guard', possible spurious linker errors are prevented. In particular, this allows libcxx, libcxxabi, and libunwind to be built with HonggFuzz. CMAKE_REQUIRED_FLAGS is extra compile flags when running CMake build configuration steps (like check_cxx_compiler_flag). It does not affect the compile flags for the actual build of the project (unless of course these flags change whether or not a given source compiles and links or not). So libcxx, libcxxabi, and libunwind will still be built with any specified sanitize-coverage as before. The build configuration steps (which are mostly checking to see if certain compiler flags are available) will not try to compile and link "int main() { return 0;}" (or other specified source) with sanitize-coverage (which can fail to link at this stage in building, since the final compile flags required are yet to be determined). The change to LIBFUZZER_CFLAGS was done to keep it consistent with the obvious intention of disabling all sanitize-coverage. This appears to be intentional, preventing the fuzzer driver itself from showing up in any coverage calculations. Reviewed By: #libunwind, #libc, #libc_abi, ldionne, phosek Differential Revision: https://reviews.llvm.org/D116050
This commit is contained in:
parent
b932bdf59f
commit
fb1582f6c5
@ -72,7 +72,7 @@ endif()
|
||||
append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer LIBFUZZER_CFLAGS)
|
||||
|
||||
if (CMAKE_CXX_FLAGS MATCHES "fsanitize-coverage")
|
||||
list(APPEND LIBFUZZER_CFLAGS -fno-sanitize-coverage=trace-pc-guard,edge,trace-cmp,indirect-calls,8bit-counters)
|
||||
list(APPEND LIBFUZZER_CFLAGS -fsanitize-coverage=0)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
|
@ -87,7 +87,7 @@ if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG OR LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
|
||||
endif ()
|
||||
if (CMAKE_C_FLAGS MATCHES -fsanitize-coverage OR CMAKE_CXX_FLAGS MATCHES -fsanitize-coverage)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters")
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fsanitize-coverage=0")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
@ -67,7 +67,7 @@ if (LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG OR LIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
|
||||
endif ()
|
||||
if (CMAKE_C_FLAGS MATCHES -fsanitize-coverage OR CMAKE_CXX_FLAGS MATCHES -fsanitize-coverage)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters")
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fsanitize-coverage=0")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
@ -78,7 +78,7 @@ if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG OR LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
|
||||
endif ()
|
||||
if (CMAKE_C_FLAGS MATCHES -fsanitize-coverage OR CMAKE_CXX_FLAGS MATCHES -fsanitize-coverage)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters")
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fsanitize-coverage=0")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user