2017-04-22 01:39:50 +08:00
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
|
|
|
static thread_local int blah;
|
|
|
|
int main() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAS_THREAD_LOCAL)
|
|
|
|
|
|
|
|
if( NOT HAS_THREAD_LOCAL )
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dthread_local=__thread")
|
|
|
|
endif()
|
|
|
|
|
2017-04-22 02:02:22 +08:00
|
|
|
set(LIBFUZZER_FLAGS_BASE "${CMAKE_CXX_FLAGS}")
|
|
|
|
# Disable the coverage and sanitizer instrumentation for the fuzzer itself.
|
|
|
|
set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fno-sanitize-coverage=trace-pc-guard,edge,trace-cmp,indirect-calls,8bit-counters -Werror")
|
2015-04-07 00:09:13 +08:00
|
|
|
if( LLVM_USE_SANITIZE_COVERAGE )
|
2017-04-22 02:02:22 +08:00
|
|
|
if(NOT "${LLVM_USE_SANITIZER}" STREQUAL "Address")
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"LibFuzzer and its tests require LLVM_USE_SANITIZER=Address and "
|
|
|
|
"LLVM_USE_SANITIZE_COVERAGE=YES to be set."
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
add_library(LLVMFuzzerNoMainObjects OBJECT
|
2015-01-30 00:58:29 +08:00
|
|
|
FuzzerCrossOver.cpp
|
2015-02-20 02:45:37 +08:00
|
|
|
FuzzerDriver.cpp
|
2016-06-02 13:48:02 +08:00
|
|
|
FuzzerExtFunctionsDlsym.cpp
|
2017-02-10 09:35:46 +08:00
|
|
|
FuzzerExtFunctionsDlsymWin.cpp
|
2016-06-02 13:48:02 +08:00
|
|
|
FuzzerExtFunctionsWeak.cpp
|
2017-03-24 06:43:12 +08:00
|
|
|
FuzzerExtraCounters.cpp
|
2015-01-30 00:58:29 +08:00
|
|
|
FuzzerIO.cpp
|
2016-12-01 05:44:26 +08:00
|
|
|
FuzzerIOPosix.cpp
|
|
|
|
FuzzerIOWindows.cpp
|
2015-01-30 00:58:29 +08:00
|
|
|
FuzzerLoop.cpp
|
2016-12-09 09:17:24 +08:00
|
|
|
FuzzerMerge.cpp
|
2015-01-30 00:58:29 +08:00
|
|
|
FuzzerMutate.cpp
|
2015-05-15 06:41:49 +08:00
|
|
|
FuzzerSHA1.cpp
|
2017-01-21 04:57:07 +08:00
|
|
|
FuzzerShmemPosix.cpp
|
2017-02-08 08:02:12 +08:00
|
|
|
FuzzerShmemWindows.cpp
|
2016-02-27 05:33:56 +08:00
|
|
|
FuzzerTracePC.cpp
|
2016-12-01 05:44:26 +08:00
|
|
|
FuzzerTraceState.cpp
|
2015-01-30 00:58:29 +08:00
|
|
|
FuzzerUtil.cpp
|
2016-08-13 02:29:36 +08:00
|
|
|
FuzzerUtilDarwin.cpp
|
|
|
|
FuzzerUtilLinux.cpp
|
2016-12-03 07:02:01 +08:00
|
|
|
FuzzerUtilPosix.cpp
|
|
|
|
FuzzerUtilWindows.cpp
|
2015-01-30 00:58:29 +08:00
|
|
|
)
|
2017-04-22 02:02:22 +08:00
|
|
|
add_library(LLVMFuzzerNoMain STATIC
|
2015-05-23 06:35:31 +08:00
|
|
|
$<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
|
|
|
|
)
|
2017-04-22 02:02:22 +08:00
|
|
|
target_link_libraries(LLVMFuzzerNoMain ${LLVM_PTHREAD_LIB})
|
|
|
|
add_library(LLVMFuzzer STATIC
|
2015-01-31 07:26:57 +08:00
|
|
|
FuzzerMain.cpp
|
2015-05-23 06:35:31 +08:00
|
|
|
$<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
|
2015-01-31 07:26:57 +08:00
|
|
|
)
|
2017-04-22 02:02:22 +08:00
|
|
|
target_link_libraries(LLVMFuzzer ${LLVM_PTHREAD_LIB})
|
2015-01-30 00:58:29 +08:00
|
|
|
|
|
|
|
if( LLVM_INCLUDE_TESTS )
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
|
|
|
endif()
|