aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-10-03 10:54:28 +0200
committerMarcoFalke <falke.marco@gmail.com>2020-10-04 17:49:07 +0200
commitfae7a1c18803675e70b9bf66575e1e0a6e01f6f6 (patch)
tree538acb915905380a857319bc834d6f631917d2d8
parent54fc96ffa70ad3a53d32709101b7a2ce064d822e (diff)
downloadbitcoin-fae7a1c18803675e70b9bf66575e1e0a6e01f6f6.tar.xz
fuzz: Configure check for main function
-rw-r--r--configure.ac14
-rw-r--r--src/test/fuzz/fuzz.cpp9
2 files changed, 14 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac
index fbf56443f1..674ed1ee73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1165,6 +1165,20 @@ if test "x$enable_fuzz" = "xyes"; then
use_bench=no
use_upnp=no
use_zmq=no
+
+ AC_MSG_CHECKING([whether main function is needed])
+ AX_CHECK_LINK_FLAG(
+ [[-fsanitize=$use_sanitizers]],
+ [AC_MSG_RESULT([no])],
+ [AC_MSG_RESULT([yes])
+ CPPFLAGS="$CPPFLAGS -DPROVIDE_MAIN_FUNCTION"],
+ [],
+ [AC_LANG_PROGRAM([[
+ #include <cstdint>
+ #include <cstddef>
+ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { return 0; }
+ /* unterminated comment to remove the main function ...
+ ]],[[]])])
else
BITCOIN_QT_INIT
diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp
index 1e1807d734..753cfffdcb 100644
--- a/src/test/fuzz/fuzz.cpp
+++ b/src/test/fuzz/fuzz.cpp
@@ -12,15 +12,6 @@
const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
-// Decide if main(...) should be provided:
-// * AFL needs main(...) regardless of platform.
-// * macOS handles __attribute__((weak)) main(...) poorly when linking
-// against libFuzzer. See https://github.com/bitcoin/bitcoin/pull/18008
-// for details.
-#if defined(__AFL_COMPILER) || !defined(MAC_OSX)
-#define PROVIDE_MAIN_FUNCTION
-#endif
-
#if defined(PROVIDE_MAIN_FUNCTION)
static bool read_stdin(std::vector<uint8_t>& data)
{