diff --git a/fuzz/meson.build b/fuzz/meson.build index 09eef853ad..43e1251bd7 100644 --- a/fuzz/meson.build +++ b/fuzz/meson.build @@ -9,7 +9,7 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -if fuzz_opt == 'none' +if fuzz_opt.enabled() subdir_done() endif diff --git a/meson.build b/meson.build index ee12ed857f..972f41fed9 100644 --- a/meson.build +++ b/meson.build @@ -57,6 +57,7 @@ doc_opt = get_option('doc') doh_opt = get_option('doh') fips_opt = get_option('fips') fuzz_opt = get_option('fuzzing') +fuzz_backend_opt = get_option('fuzzing-backend') geoip_opt = get_option('geoip') gssapi_opt = get_option('gssapi') idn_opt = get_option('idn') @@ -406,17 +407,19 @@ endif config.set_quoted('FUZZDIR', meson.project_source_root() / 'fuzz') fuzz_link_args = [] -if fuzz_opt != 'none' - if get_option('b_lundef') != false - warning('fuzzing will fail to build properly without -Db_lundef=false') - endif +if fuzz_opt.enabled() + if fuzz_backed_opt != 'none' + if get_option('b_lundef') != false + warning('fuzzing will fail to build properly without -Db_lundef=false') + endif - if fuzz_opt == 'afl' - elif fuzz_opt == 'libfuzzer' - config.set('FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION', 1) - fuzz_link_args += '-fsanitize=fuzzer,address,undefined' - add_project_link_arguments('-fsanitize=address,undefined', language: 'c') - add_project_arguments('-fsanitize=fuzzer-no-link,address,undefined', language: 'c') + if fuzz_opt == 'afl' + elif fuzz_opt == 'libfuzzer' + config.set('FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION', 1) + fuzz_link_args += '-fsanitize=fuzzer,address,undefined' + add_project_link_arguments('-fsanitize=address,undefined', language: 'c') + add_project_arguments('-fsanitize=fuzzer-no-link,address,undefined', language: 'c') + endif endif endif diff --git a/meson_options.txt b/meson_options.txt index 5783d45f3d..2f1ae16a1c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -169,9 +169,17 @@ option( option( 'fuzzing', + type: 'feature', + value: 'auto', + description: 'Build fuzzing binaries', +) + +option( + 'fuzzing-backend', type: 'combo', choices: ['none', 'afl', 'libfuzzer', 'oss-fuzz'], - description: 'Enable fuzzing', + value: 'none', + description: 'Fuzzing backend (backend none with -Dfuzzing=enabled only compiles the binary)', ) option(