Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 67188fd

Browse files
committed
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@370094 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent f23db13 commit 67188fd

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

Diff for: CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -513,3 +513,5 @@ if(COMPILER_RT_INCLUDE_TESTS)
513513
endif()
514514
endif()
515515
endif()
516+
517+
add_subdirectory(tools)

Diff for: lib/gwp_asan/CMakeLists.txt

-23
Original file line numberDiff line numberDiff line change
@@ -98,29 +98,6 @@ if (COMPILER_RT_HAS_GWP_ASAN)
9898
SOURCES optional/backtrace_sanitizer_common.cpp
9999
ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS}
100100
CFLAGS ${GWP_ASAN_CFLAGS} ${SANITIZER_COMMON_CFLAGS})
101-
102-
# Build the stack trace compressor fuzzer. Note that clang versions 4.* did
103-
# not have -fsanitize=fuzzer, and Clang versions 5.* didn't have
104-
# -fsanitize=fuzzer-no-link. In general, the way we build fuzz targets in LLVM
105-
# core is to link it against a dummy main when DLLVM_USE_SANITIZE_COVERAGE
106-
# isn't specified. Instead, here we only build fuzz targets if clang version
107-
# is >= 6.0.
108-
if (COMPILER_RT_BUILD_LIBFUZZER AND
109-
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND
110-
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
111-
add_executable(stack_trace_compressor_fuzzer
112-
stack_trace_compressor_fuzzer.cpp
113-
${GWP_ASAN_SOURCES}
114-
${GWP_ASAN_HEADERS})
115-
set_target_properties(
116-
stack_trace_compressor_fuzzer PROPERTIES FOLDER "Fuzzers")
117-
target_compile_options(
118-
stack_trace_compressor_fuzzer PRIVATE -fsanitize=fuzzer-no-link)
119-
set_target_properties(
120-
stack_trace_compressor_fuzzer PROPERTIES LINK_FLAGS -fsanitize=fuzzer)
121-
add_dependencies(stack_trace_compressor_fuzzer fuzzer)
122-
add_dependencies(gwp_asan stack_trace_compressor_fuzzer)
123-
endif()
124101
endif()
125102

126103
if(COMPILER_RT_INCLUDE_TESTS)

Diff for: tools/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(gwp_asan)

Diff for: tools/gwp_asan/CMakeLists.txt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Build the stack trace compressor fuzzer. This will require Clang >= 6.0.0, as
2+
# -fsanitize=fuzzer-no-link was not a valid command line flag prior to this.
3+
if (LLVM_USE_SANITIZE_COVERAGE)
4+
add_executable(stack_trace_compressor_fuzzer
5+
../../lib/gwp_asan/stack_trace_compressor.cpp
6+
../../lib/gwp_asan/stack_trace_compressor.h
7+
stack_trace_compressor_fuzzer.cpp)
8+
set_target_properties(
9+
stack_trace_compressor_fuzzer PROPERTIES FOLDER "Fuzzers")
10+
target_compile_options(
11+
stack_trace_compressor_fuzzer PRIVATE -fsanitize=fuzzer-no-link)
12+
set_target_properties(
13+
stack_trace_compressor_fuzzer PROPERTIES LINK_FLAGS -fsanitize=fuzzer)
14+
target_include_directories(
15+
stack_trace_compressor_fuzzer PRIVATE ../../lib/)
16+
17+
if (TARGET gwp_asan)
18+
add_dependencies(gwp_asan stack_trace_compressor_fuzzer)
19+
endif()
20+
endif()

0 commit comments

Comments
 (0)