forked from OSchip/llvm-project
Add GWP-ASan fuzz target to compiler-rt/tools.
Summary: @eugenis to approve addition of //compiler-rt/tools. @pree-jackie please confirm that this WFY. D66494 introduced the GWP-ASan stack_trace_compressor_fuzzer. Building fuzz targets in compiler-rt is a new affair, and has some challenges: - If the host compiler doesn't have compiler-rt, the -fsanitize=fuzzer may not be able to link against `libclang_rt.fuzzer*`. - Things in compiler-rt generally aren't built when you want to build with sanitizers using `-DLLVM_USE_SANITIZER`. This tricky to work around, so we create the new tools directory so that we can build fuzz targets with sanitizers. This has the added bonus of fixing the problem above as well, as we can now just guard the fuzz target build to only be done with `-DLLVM_USE_SANITIZE_COVERAGE=On`. Reviewers: eugenis, pree-jackie Reviewed By: eugenis, pree-jackie Subscribers: dberris, mgorny, #sanitizers, llvm-commits, eugenis, pree-jackie, lebedev.ri, vitalybuka, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66776 llvm-svn: 370094
This commit is contained in:
parent
3737c0239a
commit
ae56e593b9
|
@ -513,3 +513,5 @@ if(COMPILER_RT_INCLUDE_TESTS)
|
|||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(tools)
|
||||
|
|
|
@ -98,29 +98,6 @@ if (COMPILER_RT_HAS_GWP_ASAN)
|
|||
SOURCES optional/backtrace_sanitizer_common.cpp
|
||||
ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS}
|
||||
CFLAGS ${GWP_ASAN_CFLAGS} ${SANITIZER_COMMON_CFLAGS})
|
||||
|
||||
# Build the stack trace compressor fuzzer. Note that clang versions 4.* did
|
||||
# not have -fsanitize=fuzzer, and Clang versions 5.* didn't have
|
||||
# -fsanitize=fuzzer-no-link. In general, the way we build fuzz targets in LLVM
|
||||
# core is to link it against a dummy main when DLLVM_USE_SANITIZE_COVERAGE
|
||||
# isn't specified. Instead, here we only build fuzz targets if clang version
|
||||
# is >= 6.0.
|
||||
if (COMPILER_RT_BUILD_LIBFUZZER AND
|
||||
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND
|
||||
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
|
||||
add_executable(stack_trace_compressor_fuzzer
|
||||
stack_trace_compressor_fuzzer.cpp
|
||||
${GWP_ASAN_SOURCES}
|
||||
${GWP_ASAN_HEADERS})
|
||||
set_target_properties(
|
||||
stack_trace_compressor_fuzzer PROPERTIES FOLDER "Fuzzers")
|
||||
target_compile_options(
|
||||
stack_trace_compressor_fuzzer PRIVATE -fsanitize=fuzzer-no-link)
|
||||
set_target_properties(
|
||||
stack_trace_compressor_fuzzer PROPERTIES LINK_FLAGS -fsanitize=fuzzer)
|
||||
add_dependencies(stack_trace_compressor_fuzzer fuzzer)
|
||||
add_dependencies(gwp_asan stack_trace_compressor_fuzzer)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(COMPILER_RT_INCLUDE_TESTS)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
add_subdirectory(gwp_asan)
|
|
@ -0,0 +1,20 @@
|
|||
# Build the stack trace compressor fuzzer. This will require Clang >= 6.0.0, as
|
||||
# -fsanitize=fuzzer-no-link was not a valid command line flag prior to this.
|
||||
if (LLVM_USE_SANITIZE_COVERAGE)
|
||||
add_executable(stack_trace_compressor_fuzzer
|
||||
../../lib/gwp_asan/stack_trace_compressor.cpp
|
||||
../../lib/gwp_asan/stack_trace_compressor.h
|
||||
stack_trace_compressor_fuzzer.cpp)
|
||||
set_target_properties(
|
||||
stack_trace_compressor_fuzzer PROPERTIES FOLDER "Fuzzers")
|
||||
target_compile_options(
|
||||
stack_trace_compressor_fuzzer PRIVATE -fsanitize=fuzzer-no-link)
|
||||
set_target_properties(
|
||||
stack_trace_compressor_fuzzer PROPERTIES LINK_FLAGS -fsanitize=fuzzer)
|
||||
target_include_directories(
|
||||
stack_trace_compressor_fuzzer PRIVATE ../../lib/)
|
||||
|
||||
if (TARGET gwp_asan)
|
||||
add_dependencies(gwp_asan stack_trace_compressor_fuzzer)
|
||||
endif()
|
||||
endif()
|
Loading…
Reference in New Issue