No need to define the PROVIDE_FUZZ_MAIN_FUNCTION macro when the build system has been configured with the --disable-fuzz-binary option.
See #24336#pullrequestreview-881368272.
Do you think that the fuzz task timeout is caused by this PR change?
No
This should be combined with the CHECK_RUNTIME_LIB check rather than another enable_fuzz_binary test.
A third refacotring alternative might be to remove it. Then, call AX_CHECK_LINK_FLAG unconditionally?
Updated 4a1e159978792bf3edbc1c51e4b9ccdd4c164a7d -> 7e7ae428319f4813087cde1a5f4611ea20bebe97 (pr24337.01 -> pr24337.02).
This should be combined with the
CHECK_RUNTIME_LIBcheck rather than anotherenable_fuzz_binarytest.
A third refacotring alternative might be to remove it. Then, call
AX_CHECK_LINK_FLAGunconditionally?
Chosen the former suggestion as it assumes minimal diff.
Updated 7e7ae428319f4813087cde1a5f4611ea20bebe97 -> 8d0683da024e62999d574371e965bc8fc51a6f38 (pr24337.02 -> pr24337.03): reverted back and rebased.
This should be combined with the
CHECK_RUNTIME_LIBcheck rather than anotherenable_fuzz_binarytest.
Doesn't work. Fails with "multiple definition of `main'" error.
A third refacotring alternative might be to remove it. Then, call
AX_CHECK_LINK_FLAGunconditionally?
Doesn't work. The -DPROVIDE_FUZZ_MAIN_FUNCTION macro still defined even configured with --disable-fuzz-binary.
I mean:
if enable_fuzz_binary:
AX_CHECK_LINK_FLAG
CHECK_RUNTIME_LIB
fi
I mean:
if enable_fuzz_binary: AX_CHECK_LINK_FLAG CHECK_RUNTIME_LIB fi
Thanks! Done: 8d0683da024e62999d574371e965bc8fc51a6f38 -> 121c4ba4475285dd335655e410aedcb95076ba85 (pr24337.03 -> pr24337.04).
I mean:
if enable_fuzz_binary: AX_CHECK_LINK_FLAG CHECK_RUNTIME_LIB fiThanks! Done: 8d0683d -> 121c4ba (pr24337.03 -> pr24337.04).
Reverted back due to the CI failures.
failures
That's because it incorrectly uses a previously cached, but unrelated result. You can work around that with:
diff --git a/configure.ac b/configure.ac
index b7852ae3b5..efdeb186c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1300,7 +1300,7 @@ fi
if test "$enable_fuzz_binary" = "yes"; then
AC_MSG_CHECKING([whether main function is needed for fuzz binary])
AX_CHECK_LINK_FLAG(
- [-fsanitize=$use_sanitizers],
+ [-fsanitize= -fsanitize=$use_sanitizers],
[AC_MSG_RESULT([no])],
[AC_MSG_RESULT([yes]); CPPFLAGS="$CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"],
[],
See https://cirrus-ci.com/task/6160465456791552?logs=ci#L2772
checking whether main function is needed for fuzz binary... checking whether the linker accepts -fsanitize=address,integer,undefined... (cached) yes no
fsanitize=address,integer,undefined... (cached) yes
Yeap, AX_CHECK_LINK_FLAG creates and uses a cached variable ax_cv_check_ldflags_$4_$1.
Updated 8d0683da024e62999d574371e965bc8fc51a6f38 -> c0a089b242150979aefe5238a240ca5de30d4602 (pr24337.03 -> pr24337.05):
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Rebased c0a089b242150979aefe5238a240ca5de30d4602 -> 3ec7dc7c470a0c117ad601feda5fa7d45e9ecd93 (pr24337.05 -> pr24337.06).
1329 | @@ -1315,21 +1330,8 @@ if test "$enable_fuzz" = "yes"; then 1330 | ]],[[ 1331 | */ int not_main() { 1332 | ]])]) 1333 | -else 1334 | - BITCOIN_QT_INIT 1335 | 1336 | - dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
moving this seems unrelated?
It looks like a way the diff has been rendered. The actual diff is moving AX_CHECK_LINK_FLAG stuff.
1317 | + 1318 | +if test "$enable_fuzz_binary" = "yes"; then 1319 | AC_MSG_CHECKING([whether main function is needed for fuzz binary]) 1320 | AX_CHECK_LINK_FLAG( 1321 | - [-fsanitize=$use_sanitizers], 1322 | + [-fsanitize= -fsanitize=$use_sanitizers], dnl Avoid re-use of an unrelated cached result.
This looks like a hack, and the comment doesn't really explain why it's needed. If I understand what it's meant to be doing, couldn't you check that the AC_LANG_PROGRAM compiles while passing SANITIZER_LDFLAGS as extra flags?
Updated 3ec7dc7c470a0c117ad601feda5fa7d45e9ecd93 -> c9c4e6cadda85783a005af773a683d44a208bf67 (pr24337.06 -> pr24337.07, diff):
<!--9cd9c72976c961c55c7acef8f6ba82cd-->
Approach ACK c9c4e6cadda85783a005af773a683d44a208bf67 did not review or test 🐤
<details><summary>Show signature</summary>
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Approach ACK c9c4e6cadda85783a005af773a683d44a208bf67 did not review or test 🐤
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiutAv/UkJoJlQodqTvhH4MJ1Hy/QXpFzWdLaVWy3Uts0sXjd+FX7VfiHVaoikh
TuI0Zf22JJuvywfMWfdn1Dk/FTHsk06asCyADFFEzNzZjq5yOkLp6SrCb/CBbulg
TOhOYMYoLuFl/HoJEdUUlwIPmN6Bf26v0vCrrM7/tuoQhZNFBx84wliriyq44n43
FCs5JwcFI84XuDxsI2evH93qLuLuQ50cjw2XocI3cU3MQjleqEOpuVmjeSU2z40m
sBQb7hpCddtJ4PQe/YKYQNA+VAQ9Wz3jS8cVn2PMkhlQTOK+JzkWQEU/H8dC1TxV
dKGcUG9GQoYGVq6UVpP4J0IdfQq5i++1c5uHnxOEH7M+VcUe4LyeAX820S/v4a0n
ORRc5NicHpV7d1TKK4PRdYWL1egWib8dqhmbRuGRS9dvhyk1guhdvxOWQyBPveJi
XiwxUPIIb/N2gWbJsSEIGqMnN4jE17I3o3jXhdwlHR4MGqlX/DaA5zxGBbPRpTSF
aC8Pv1LA
=qSZS
-----END PGP SIGNATURE-----
</details>
ACK c9c4e6cadda85783a005af773a683d44a208bf67 Checked that PROVIDE_FUZZ_MAIN_FUNCTION isn't defined when configuring with --disable-fuzz-binary.