Skip to content

Commit c9c4e6c

Browse files
committed
build: Do not define PROVIDE_FUZZ_MAIN_FUNCTION macro unconditionally
1 parent 9ce1c50 commit c9c4e6c

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
@@ -1818,10 +1820,6 @@ if test "$build_bitcoin_wallet$build_bitcoin_cli$build_bitcoin_tx$build_bitcoin_
18181820
AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon --with-gui --enable-bench or --enable-tests])
18191821
fi
18201822

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

0 commit comments

Comments
 (0)