brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 1850e8e Raw
61 lines · plain
1if(CLANG_ENABLE_PROTO_FUZZER)2  set(LLVM_LINK_COMPONENTS3    Support4    )5 6  add_llvm_fuzzer(lldb-expression-fuzzer7    EXCLUDE_FROM_ALL8    lldb-expression-fuzzer.cpp9    )10 11  if(TARGET lldb-expression-fuzzer)12    target_include_directories(lldb-expression-fuzzer PRIVATE ..)13    find_package(Protobuf REQUIRED)14    add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)15    include_directories(${PROTOBUF_INCLUDE_DIRS})16    include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../../clang/tools/clang-fuzzer PRIVATE ..)17    include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/tools/clang-fuzzer)18 19    set(CLANG_CMAKE_MODULE_PATH20      ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/cmake/modules)21 22    set(CMAKE_MODULE_PATH23      ${CMAKE_MODULE_PATH}24      ${CLANG_CMAKE_MODULE_PATH})25 26 27    set (PBM_PREFIX lldb_protobuf_mutator)28    include(ProtobufMutator)29    include_directories(${ProtobufMutator_INCLUDE_DIRS})30 31    target_link_libraries(lldb-expression-fuzzer32      PRIVATE33      ${ProtobufMutator_LIBRARIES}34      ${LLVM_LIB_FUZZING_ENGINE}35      clangHandleCXX36      clangCXXProto37      clangProtoToCXX38      liblldb39      )40 41    add_custom_command(TARGET lldb-expression-fuzzer PRE_BUILD42      COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/fuzzer-artifacts/expression-artifacts43      # Create and compile a simple C program using the command line. This is44      # needed because LLDB's expression evaluator needs a legitmate target45      # instead of a dummy target46      COMMAND echo 'int main (int argc, char** argv) { return 0\; }' | clang -o main.out -xc -47      )48 49    # Create a directory for storing the fuzzer's artifacts and run the fuzzer with arguments that will50    # not attempt to reduce the size of the inputs being generated51    # Also set the executable that's created above as an environment variable for the52    # source code to use53    add_custom_target(fuzz-lldb-expression54      COMMENT "Running the LLDB expression evaluator fuzzer..."55      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/fuzzer-artifacts/expression-artifacts56      COMMAND ${CMAKE_COMMAND} -E env LLDB_FUZZER_TARGET=${CMAKE_CURRENT_BINARY_DIR}/main.out $<TARGET_FILE:lldb-expression-fuzzer> -artifact_prefix=expression- -reduce_inputs=057      USES_TERMINAL58      )59  endif()60endif()61