summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorMichael Hanselmann <public@hansmi.ch>2021-03-31 23:39:49 +0200
committerVictor Toso <me@victortoso.com>2021-04-27 17:17:40 +0000
commit5eac609af24b7459f18df5df2607d9bf8e022fc7 (patch)
treeb852569b11918d3968f9126f4d4293e2b0c4e661 /meson.build
parentc55b77549f8ca8d8797a7379a9e9bb2aa47dfeb9 (diff)
Make fuzzing with meson build work
TL;DR: Update build system and utility script such invoking `build-aux/oss-fuzz.sh` is all that's needed to build fuzzers in an OSS-Fuzz compatible environment. `.gitlab-ci.yml`: Build three variants of fuzzers: using autoconf as before, libFuzzer via Clang and using the standalone driver. `build-aux/oss-fuzz.sh`: Remove compiler-specific code. The fuzzing environment should control the compiler via `$CC`/`$CXX` along with flags in `$CFLAGS`/`$CXXFLAGS`. Make code actually build by overriding `b_lundef` default value, otherwise fuzzing-related symbols would cause linker errors during compilation. Pass fuzzing engine via option; the default would be to use the built-in standalone engine. `meson.build`: Remove all fuzzing-related logic except to detect whether fuzzing should be enabled at all. `fuzzing/meson.build`: If fuzzing engine `standalone` is selected the build behaves as any other C program build. When another fuzzing engine is to be used, e.g. from `$LIB_FUZZING_ENGINE` in `build-aux/oss-fuzz.sh`, a test program is compiled and linked to ensure that linking suceeds (in particular whether a `main` function is provided). Prepare for the addition of more fuzzing binaries by using a loop. Add OSS-Fuzz configuration file for binaries. Signed-off-by: Michael Hanselmann <public@hansmi.ch>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build18
1 files changed, 2 insertions, 16 deletions
diff --git a/meson.build b/meson.build
index 8b2ccca..fd72c5b 100644
--- a/meson.build
+++ b/meson.build
@@ -31,21 +31,6 @@ if host_machine.system() != 'windows'
add_project_arguments('-fstack-protector', language: 'c')
endif
-want_libfuzzer = get_option('llvm-fuzz').enabled()
-if want_libfuzzer
- add_languages('cpp', required : true)
- fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
- if fuzzing_engine.found()
- add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
- elif compiler.has_argument('-fsanitize=fuzzer-no-link')
- add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
- else
- error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
- endif
- # This is preferable to static linking
- add_project_link_arguments('-shared-libsan', language: ['c', 'cpp'])
-endif
-
config = configuration_data()
#
@@ -102,7 +87,8 @@ endif
if host_machine.system() != 'windows'
subdir('usbredirserver')
subdir('usbredirtestclient')
- if want_libfuzzer
+
+ if get_option('fuzzing').enabled()
subdir('fuzzing')
endif
endif