aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build-aux/m4/bitcoin_runtime_lib.m442
-rw-r--r--configure.ac2
-rw-r--r--src/Makefile.test.include2
-rw-r--r--src/test/fuzz/multiplication_overflow.cpp12
4 files changed, 9 insertions, 49 deletions
diff --git a/build-aux/m4/bitcoin_runtime_lib.m4 b/build-aux/m4/bitcoin_runtime_lib.m4
deleted file mode 100644
index 1a6922deca..0000000000
--- a/build-aux/m4/bitcoin_runtime_lib.m4
+++ /dev/null
@@ -1,42 +0,0 @@
-# On some platforms clang builtin implementations
-# require compiler-rt as a runtime library to use.
-#
-# See:
-# - https://bugs.llvm.org/show_bug.cgi?id=28629
-
-m4_define([_CHECK_RUNTIME_testbody], [[
- bool f(long long x, long long y, long long* p)
- {
- return __builtin_mul_overflow(x, y, p);
- }
- int main() { return 0; }
-]])
-
-AC_DEFUN([CHECK_RUNTIME_LIB], [
-
- AC_LANG_PUSH([C++])
-
- AC_MSG_CHECKING([for __builtin_mul_overflow])
- AC_LINK_IFELSE(
- [AC_LANG_SOURCE([_CHECK_RUNTIME_testbody])],
- [
- AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_BUILTIN_MUL_OVERFLOW], [1], [Define if you have a working __builtin_mul_overflow])
- ],
- [
- ax_check_save_flags="$LDFLAGS"
- LDFLAGS="$LDFLAGS --rtlib=compiler-rt -lgcc_s"
- AC_LINK_IFELSE(
- [AC_LANG_SOURCE([_CHECK_RUNTIME_testbody])],
- [
- AC_MSG_RESULT([yes, with additional linker flags])
- RUNTIME_LDFLAGS="--rtlib=compiler-rt -lgcc_s"
- AC_DEFINE([HAVE_BUILTIN_MUL_OVERFLOW], [1], [Define if you have a working __builtin_mul_overflow])
- ],
- [AC_MSG_RESULT([no])])
- LDFLAGS="$ax_check_save_flags"
- ])
-
- AC_LANG_POP
- AC_SUBST([RUNTIME_LDFLAGS])
-])
diff --git a/configure.ac b/configure.ac
index bcff6c79f8..1de0aba747 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1338,8 +1338,6 @@ if test "$enable_fuzz_binary" = "yes"; then
]],[[
*/ int not_main() {
]])])
-
- CHECK_RUNTIME_LIB
fi
if test "$enable_wallet" != "no"; then
diff --git a/src/Makefile.test.include b/src/Makefile.test.include
index 416a11b0c0..870e49bd75 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -240,7 +240,7 @@ if ENABLE_FUZZ_BINARY
test_fuzz_fuzz_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
test_fuzz_fuzz_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
test_fuzz_fuzz_LDADD = $(FUZZ_SUITE_LD_COMMON)
-test_fuzz_fuzz_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) $(RUNTIME_LDFLAGS)
+test_fuzz_fuzz_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS)
test_fuzz_fuzz_SOURCES = \
$(FUZZ_WALLET_SRC) \
test/fuzz/addition_overflow.cpp \
diff --git a/src/test/fuzz/multiplication_overflow.cpp b/src/test/fuzz/multiplication_overflow.cpp
index fbe4d061bf..e45ed503f0 100644
--- a/src/test/fuzz/multiplication_overflow.cpp
+++ b/src/test/fuzz/multiplication_overflow.cpp
@@ -2,10 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
-
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
@@ -14,6 +10,14 @@
#include <string>
#include <vector>
+#if defined(__has_builtin)
+#if __has_builtin(__builtin_mul_overflow)
+#define HAVE_BUILTIN_MUL_OVERFLOW
+#endif
+#elif defined(__GNUC__)
+#define HAVE_BUILTIN_MUL_OVERFLOW
+#endif
+
namespace {
template <typename T>
void TestMultiplicationOverflow(FuzzedDataProvider& fuzzed_data_provider)