1c5f01b2fSopenharmony_ciset(LIBFUZZER_FLAGS_BASE "${CMAKE_CXX_FLAGS}") 2c5f01b2fSopenharmony_ci# Disable the coverage and sanitizer instrumentation for the fuzzer itself. 3c5f01b2fSopenharmony_ciset(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fno-sanitize-coverage=trace-pc-guard,edge,trace-cmp,indirect-calls,8bit-counters -Werror") 4c5f01b2fSopenharmony_ciif( LLVM_USE_SANITIZE_COVERAGE ) 5c5f01b2fSopenharmony_ci if(NOT "${LLVM_USE_SANITIZER}" STREQUAL "Address") 6c5f01b2fSopenharmony_ci message(FATAL_ERROR 7c5f01b2fSopenharmony_ci "LibFuzzer and its tests require LLVM_USE_SANITIZER=Address and " 8c5f01b2fSopenharmony_ci "LLVM_USE_SANITIZE_COVERAGE=YES to be set." 9c5f01b2fSopenharmony_ci ) 10c5f01b2fSopenharmony_ci endif() 11c5f01b2fSopenharmony_ci add_library(LLVMFuzzerNoMainObjects OBJECT 12c5f01b2fSopenharmony_ci FuzzerCrossOver.cpp 13c5f01b2fSopenharmony_ci FuzzerDriver.cpp 14c5f01b2fSopenharmony_ci FuzzerExtFunctionsDlsym.cpp 15c5f01b2fSopenharmony_ci FuzzerExtFunctionsWeak.cpp 16c5f01b2fSopenharmony_ci FuzzerExtFunctionsWeakAlias.cpp 17c5f01b2fSopenharmony_ci FuzzerIO.cpp 18c5f01b2fSopenharmony_ci FuzzerIOPosix.cpp 19c5f01b2fSopenharmony_ci FuzzerIOWindows.cpp 20c5f01b2fSopenharmony_ci FuzzerLoop.cpp 21c5f01b2fSopenharmony_ci FuzzerMerge.cpp 22c5f01b2fSopenharmony_ci FuzzerMutate.cpp 23c5f01b2fSopenharmony_ci FuzzerSHA1.cpp 24c5f01b2fSopenharmony_ci FuzzerTracePC.cpp 25c5f01b2fSopenharmony_ci FuzzerTraceState.cpp 26c5f01b2fSopenharmony_ci FuzzerUtil.cpp 27c5f01b2fSopenharmony_ci FuzzerUtilDarwin.cpp 28c5f01b2fSopenharmony_ci FuzzerUtilLinux.cpp 29c5f01b2fSopenharmony_ci FuzzerUtilPosix.cpp 30c5f01b2fSopenharmony_ci FuzzerUtilWindows.cpp 31c5f01b2fSopenharmony_ci ) 32c5f01b2fSopenharmony_ci add_library(LLVMFuzzerNoMain STATIC 33c5f01b2fSopenharmony_ci $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects> 34c5f01b2fSopenharmony_ci ) 35c5f01b2fSopenharmony_ci target_link_libraries(LLVMFuzzerNoMain ${PTHREAD_LIB}) 36c5f01b2fSopenharmony_ci add_library(LLVMFuzzer STATIC 37c5f01b2fSopenharmony_ci FuzzerMain.cpp 38c5f01b2fSopenharmony_ci $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects> 39c5f01b2fSopenharmony_ci ) 40c5f01b2fSopenharmony_ci target_link_libraries(LLVMFuzzer ${PTHREAD_LIB}) 41c5f01b2fSopenharmony_ci 42c5f01b2fSopenharmony_ci if( LLVM_INCLUDE_TESTS ) 43c5f01b2fSopenharmony_ci add_subdirectory(test) 44c5f01b2fSopenharmony_ci endif() 45c5f01b2fSopenharmony_ciendif() 46