]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add option to always build fuzz binaries
authorAlessio Podda <alessio@isc.org>
Thu, 18 Sep 2025 09:32:13 +0000 (11:32 +0200)
committerAlessio Podda <alessio@isc.org>
Mon, 29 Sep 2025 13:29:38 +0000 (15:29 +0200)
Currently the fuzzer binaries are only built when someone requests a
fuzzer. This might cause us to inadvertently break fuzzing when changing
function signatures. It also deviates with the behaviour we had with
autotools, where the fuzz binaries were built with make test.

This commit splits the -Dfuzzing option into two: fuzzing, and
fuzzing-backend. The fuzzing option controls whether the fuzzing
binaries are built. The fuzzing-backend option controls which backend to
use, and defaults to none. If the value none is used the binaries are
built, but no backend is used or guaranteed, which means that the
binaries might be non-functional.

fuzz/meson.build
meson.build
meson_options.txt

index 09eef853adac5d6fa687d2647c5089f737759c2d..43e1251bd738c2d1c410d64fdb3c8bdeffa2601b 100644 (file)
@@ -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
 
index ee12ed857f6a9546e2d12388d05f6c8a6f128e8f..972f41fed9733f70dd5ddadd24e60954caa66a99 100644 (file)
@@ -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
 
index 5783d45f3d0fc49a91374b73ef53cb8a29930a60..2f1ae16a1ca9e862a10fe47341341b603528786d 100644 (file)
@@ -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(