Lagom: Copy fuzzer dictionary files to Oss-Fuzz $OUT directory

When building fuzzers for Oss-Fuzz using `BuildFuzzers.sh --oss-fuzz`,
fuzzer dictionary files are now copied to the `$OUT` directory. This
allows them to be used automatically by the corresponding fuzzer.
This commit is contained in:
Tim Ledbetter 2023-11-05 16:32:32 +00:00 committed by Andreas Kling
parent 33ad384a7d
commit 7d717986de
Notes: sideshowbarker 2024-07-16 23:08:48 +09:00
2 changed files with 6 additions and 2 deletions

View file

@ -72,6 +72,7 @@ if [ "$#" -gt "0" ] && [ "--oss-fuzz" = "$1" ] ; then
-DBUILD_LAGOM=ON \ -DBUILD_LAGOM=ON \
-DBUILD_SHARED_LIBS=OFF \ -DBUILD_SHARED_LIBS=OFF \
-DENABLE_FUZZERS_OSSFUZZ=ON \ -DENABLE_FUZZERS_OSSFUZZ=ON \
-DFUZZER_DICTIONARY_DIRECTORY="$OUT" \
-DCMAKE_C_COMPILER="$CC" \ -DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \ -DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_CXX_FLAGS="$CXXFLAGS -DOSS_FUZZ=ON" \ -DCMAKE_CXX_FLAGS="$CXXFLAGS -DOSS_FUZZ=ON" \

View file

@ -2,8 +2,11 @@ function(add_simple_fuzzer name)
add_executable(${name} "${name}.cpp") add_executable(${name} "${name}.cpp")
if (ENABLE_FUZZERS_OSSFUZZ) if (ENABLE_FUZZERS_OSSFUZZ)
target_link_libraries(${name} if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.dict")
PUBLIC ${ARGN} LibCore) configure_file("${name}.dict" "${FUZZER_DICTIONARY_DIRECTORY}/${name}.dict" COPYONLY)
endif()
target_link_libraries(${name}
PUBLIC ${ARGN} LibCore)
elseif (ENABLE_FUZZERS_LIBFUZZER) elseif (ENABLE_FUZZERS_LIBFUZZER)
target_compile_options(${name} target_compile_options(${name}
PRIVATE $<$<CXX_COMPILER_ID:Clang>:-g -O1 -fsanitize=fuzzer> PRIVATE $<$<CXX_COMPILER_ID:Clang>:-g -O1 -fsanitize=fuzzer>