Adapt fuzzer CMake rules for OSS-Fuzz

Refactors the CMake rules for the tint fuzzers so that when OSS-Fuzz is
controlling the build process no specific fuzzer options are used. This
allows OSS-Fuzz to fully control the fuzzing engine.

Change-Id: Ic4423b981df12e66a14ca8f53c97168ac28bfa39
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/63342
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Alastair Donaldson <afdx@google.com>
Auto-Submit: Alastair Donaldson <afdx@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Alastair Donaldson
2021-09-02 23:49:25 +00:00
committed by Tint LUCI CQ
parent 5093b9fe4d
commit 6a1eb45961
2 changed files with 18 additions and 2 deletions

View File

@@ -540,8 +540,18 @@ if (${TINT_BUILD_FUZZERS})
if (${COMPILER_IS_LIKE_GNU})
target_compile_options(libtint-fuzz PRIVATE -fvisibility=hidden)
endif()
target_compile_options(libtint-fuzz PUBLIC -fsanitize=fuzzer -fsanitize-coverage=trace-cmp)
target_link_options(libtint-fuzz PUBLIC -fsanitize=fuzzer -fsanitize-coverage=trace-cmp)
if (NOT ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS} STREQUAL "")
# This is set when the fuzzers are being built by OSS-Fuzz. In this case the
# variable provides the necessary linker flags, and OSS-Fuzz will take care
# of passing suitable compiler flags.
target_link_options(libtint-fuzz PUBLIC ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS})
else()
# When the fuzzers are being built outside of OSS-Fuzz, specific libFuzzer
# arguments to enable fuzzing are used.
target_compile_options(libtint-fuzz PUBLIC -fsanitize=fuzzer -fsanitize-coverage=trace-cmp)
target_link_options(libtint-fuzz PUBLIC -fsanitize=fuzzer -fsanitize-coverage=trace-cmp)
endif()
endif()
if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})