Skip to content

Commit 7626e54

Browse files
committed
Merge bitcoin/bitcoin#24337: build: Do not define PROVIDE_FUZZ_MAIN_FUNCTION macro unconditionally
c9c4e6c build: Do not define `PROVIDE_FUZZ_MAIN_FUNCTION` macro unconditionally (Hennadii Stepanov) Pull request description: No need to define the `PROVIDE_FUZZ_MAIN_FUNCTION` macro when the build system has been configured with the `--disable-fuzz-binary` option. See bitcoin/bitcoin#24336 (review). ACKs for top commit: MarcoFalke: Approach ACK c9c4e6c did not review or test 🐤 fanquake: ACK c9c4e6c Checked that `PROVIDE_FUZZ_MAIN_FUNCTION` isn't defined when configuring with `--disable-fuzz-binary`. Tree-SHA512: 54fbf02ba9f5ecc61b176b8ea7d05e308788d4de3f97ed40913e731300d9dc0edfdfcbf8e0a6e74cf1b2e2ae63f6208a34e03b9c8d203d070c457c4a7d9b5f2c
2 parents 22e3b6f + c9c4e6c commit 7626e54

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

configure.ac

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,21 +1300,6 @@ if test "$enable_fuzz" = "yes"; then
13001300
enable_fuzz_binary=yes
13011301

13021302
AX_CHECK_PREPROC_FLAG([-DABORT_ON_FAILED_ASSUME], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DABORT_ON_FAILED_ASSUME"], [], [$CXXFLAG_WERROR])
1303-
1304-
AC_MSG_CHECKING([whether main function is needed for fuzz binary])
1305-
AX_CHECK_LINK_FLAG(
1306-
[-fsanitize=$use_sanitizers],
1307-
[AC_MSG_RESULT([no])],
1308-
[AC_MSG_RESULT([yes]); CORE_CPPFLAGS="$CORE_CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"],
1309-
[],
1310-
[AC_LANG_PROGRAM([[
1311-
#include <cstdint>
1312-
#include <cstddef>
1313-
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { return 0; }
1314-
/* comment to remove the main function ...
1315-
]],[[
1316-
*/ int not_main() {
1317-
]])])
13181303
else
13191304
BITCOIN_QT_INIT
13201305

@@ -1328,8 +1313,25 @@ else
13281313
QT_DBUS_INCLUDES=SUPPRESS_WARNINGS($QT_DBUS_INCLUDES)
13291314
QT_TEST_INCLUDES=SUPPRESS_WARNINGS($QT_TEST_INCLUDES)
13301315
fi
1316+
fi
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+
[],
1322+
[AC_MSG_RESULT([no])],
1323+
[AC_MSG_RESULT([yes]); CORE_CPPFLAGS="$CORE_CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"],
1324+
[$SANITIZER_LDFLAGS],
1325+
[AC_LANG_PROGRAM([[
1326+
#include <cstdint>
1327+
#include <cstddef>
1328+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return 0; }
1329+
/* comment to remove the main function ...
1330+
]],[[
1331+
*/ int not_main() {
1332+
]])])
13311333

1332-
CORE_CPPFLAGS="$CORE_CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"
1334+
CHECK_RUNTIME_LIB
13331335
fi
13341336

13351337
if test "$enable_wallet" != "no"; then
@@ -1819,10 +1821,6 @@ if test "$build_bitcoin_wallet$build_bitcoin_cli$build_bitcoin_tx$build_bitcoin_
18191821
AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon --with-gui --enable-bench or --enable-tests])
18201822
fi
18211823

1822-
if test "$enable_fuzz_binary" = "yes"; then
1823-
CHECK_RUNTIME_LIB
1824-
fi
1825-
18261824
AM_CONDITIONAL([TARGET_DARWIN], [test "$TARGET_OS" = "darwin"])
18271825
AM_CONDITIONAL([BUILD_DARWIN], [test "$BUILD_OS" = "darwin"])
18281826
AM_CONDITIONAL([TARGET_LINUX], [test "$TARGET_OS" = "linux"])

0 commit comments

Comments
 (0)