From f3b065cd9c5beaed079714fc02247d76aae8b62f Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 25 Sep 2021 09:33:01 +0200 Subject: [PATCH 01/13] merge bitcoin#23092: Remove Windows workaround in authproxy (WinError 10053) --- test/functional/test_framework/authproxy.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py index da9f6f2979..4f31d12798 100644 --- a/test/functional/test_framework/authproxy.py +++ b/test/functional/test_framework/authproxy.py @@ -116,10 +116,8 @@ class AuthServiceProxy(): self.__conn.request(method, path, postdata, headers) return self._get_response() except OSError as e: - retry = ( - '[WinError 10053] An established connection was aborted by the software in your host machine' in str(e)) # Workaround for a bug on macOS. See https://bugs.python.org/issue33450 - retry = retry or ('[Errno 41] Protocol wrong type for socket' in str(e)) + retry = '[Errno 41] Protocol wrong type for socket' in str(e) if retry: self.__conn.close() self.__conn.request(method, path, postdata, headers) From b65038ec9414c333ceea37d774540bd79f0ea23c Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Mon, 30 Aug 2021 21:04:06 -0400 Subject: [PATCH 02/13] merge bitcoin#23005: Delay wallet client construction --- src/init.cpp | 13 +++++++------ src/interfaces/node.h | 4 ++++ src/node/interfaces.cpp | 4 ++++ src/node/ui_interface.cpp | 3 +++ src/node/ui_interface.h | 3 +++ src/qt/bitcoin.cpp | 1 - src/qt/splashscreen.cpp | 1 + src/qt/splashscreen.h | 1 + 8 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 147f845859..fdd3d4a294 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1441,11 +1441,6 @@ bool AppInitLockDataDirectory() bool AppInitInterfaces(NodeContext& node) { node.chain = interfaces::MakeChain(node); - // Create client interfaces for wallets that are supposed to be loaded - // according to -wallet and -disablewallet options. This only constructs - // the interfaces, it doesn't load wallet data. Wallets actually get loaded - // when load() and start() interface methods are called below. - g_wallet_init_interface.Construct(node); return true; } @@ -1515,11 +1510,17 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) GetMainSignals().RegisterBackgroundSignalScheduler(*node.scheduler); - tableRPC.InitPlatformRestrictions(); + // Create client interfaces for wallets that are supposed to be loaded + // according to -wallet and -disablewallet options. This only constructs + // the interfaces, it doesn't load wallet data. Wallets actually get loaded + // when load() and start() interface methods are called below. + g_wallet_init_interface.Construct(node); + uiInterface.InitWallet(); /* Register RPC commands regardless of -server setting so they will be * available in the GUI RPC console even if external calls are disabled. */ + tableRPC.InitPlatformRestrictions(); RegisterAllCoreRPCCommands(tableRPC); for (const auto& client : node.chain_clients) { client->registerRpcs(); diff --git a/src/interfaces/node.h b/src/interfaces/node.h index 0b9abd07b7..9950762afd 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -309,6 +309,10 @@ public: using ShowProgressFn = std::function; virtual std::unique_ptr handleShowProgress(ShowProgressFn fn) = 0; + //! Register handler for wallet client constructed messages. + using InitWalletFn = std::function; + virtual std::unique_ptr handleInitWallet(InitWalletFn fn) = 0; + //! Register handler for number of connections changed messages. using NotifyNumConnectionsChangedFn = std::function; virtual std::unique_ptr handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) = 0; diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index ea4bce94d6..154b447aa3 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -527,6 +527,10 @@ public: { return MakeHandler(::uiInterface.ShowProgress_connect(fn)); } + std::unique_ptr handleInitWallet(InitWalletFn fn) override + { + return MakeHandler(::uiInterface.InitWallet_connect(fn)); + } std::unique_ptr handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) override { return MakeHandler(::uiInterface.NotifyNumConnectionsChanged_connect(fn)); diff --git a/src/node/ui_interface.cpp b/src/node/ui_interface.cpp index b87ae85ee7..23c5e2b255 100644 --- a/src/node/ui_interface.cpp +++ b/src/node/ui_interface.cpp @@ -15,6 +15,7 @@ struct UISignals { boost::signals2::signal> ThreadSafeMessageBox; boost::signals2::signal> ThreadSafeQuestion; boost::signals2::signal InitMessage; + boost::signals2::signal InitWallet; boost::signals2::signal NotifyNumConnectionsChanged; boost::signals2::signal NotifyNetworkActiveChanged; boost::signals2::signal NotifyAlertChanged; @@ -37,6 +38,7 @@ static UISignals g_ui_signals; ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox); ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeQuestion); ADD_SIGNALS_IMPL_WRAPPER(InitMessage); +ADD_SIGNALS_IMPL_WRAPPER(InitWallet); ADD_SIGNALS_IMPL_WRAPPER(NotifyNumConnectionsChanged); ADD_SIGNALS_IMPL_WRAPPER(NotifyNetworkActiveChanged); ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged); @@ -51,6 +53,7 @@ ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged); bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style).value_or(false);} bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style).value_or(false);} void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); } +void CClientUIInterface::InitWallet() { return g_ui_signals.InitWallet(); } void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); } void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); } void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); } diff --git a/src/node/ui_interface.h b/src/node/ui_interface.h index a3934341be..a21ffb088d 100644 --- a/src/node/ui_interface.h +++ b/src/node/ui_interface.h @@ -83,6 +83,9 @@ public: /** Progress message during initialization. */ ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message); + /** Wallet client created. */ + ADD_SIGNALS_DECL_WRAPPER(InitWallet, void, ); + /** Number of network connections changed. */ ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, int newNumConnections); diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index debab9e2a2..11b189b6c2 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -262,7 +262,6 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle) // We don't hold a direct pointer to the splash screen after creation, but the splash // screen will take care of deleting itself when finish() happens. m_splash->show(); - connect(this, &BitcoinApplication::requestedInitialize, m_splash, &SplashScreen::handleLoadWallet); connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish); connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close); } diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index 005c3bcdb4..56bb8c2f89 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -199,6 +199,7 @@ void SplashScreen::subscribeToCoreSignals() // Connect signals to client m_handler_init_message = m_node->handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1)); m_handler_show_progress = m_node->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + m_handler_init_wallet = m_node->handleInitWallet([this]() { handleLoadWallet(); }); } void SplashScreen::handleLoadWallet() diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h index bcb5f99b36..7c38490793 100644 --- a/src/qt/splashscreen.h +++ b/src/qt/splashscreen.h @@ -66,6 +66,7 @@ private: bool m_shutdown = false; std::unique_ptr m_handler_init_message; std::unique_ptr m_handler_show_progress; + std::unique_ptr m_handler_init_wallet; std::unique_ptr m_handler_load_wallet; std::list> m_connected_wallets; std::list> m_connected_wallet_handlers; From 548121d366e4e83c527901354f1a1b3388507328 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Tue, 29 Mar 2022 08:09:32 +0100 Subject: [PATCH 03/13] merge bitcoin#24704: remove strnlen back-compat code --- configure.ac | 1 - src/Makefile.am | 1 - src/compat.h | 4 ---- src/compat/strnlen.cpp | 18 ------------------ 4 files changed, 24 deletions(-) delete mode 100644 src/compat/strnlen.cpp diff --git a/configure.ac b/configure.ac index 499f539ceb..7ad8aa107b 100644 --- a/configure.ac +++ b/configure.ac @@ -1048,7 +1048,6 @@ AC_CHECK_DECLS([getifaddrs, freeifaddrs],[CHECK_SOCKET],, [#include #include ] ) -AC_CHECK_DECLS([strnlen]) dnl These are used for daemonization in dashd AC_CHECK_DECLS([fork]) diff --git a/src/Makefile.am b/src/Makefile.am index 55ffd7a6c6..7dfa2c6073 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -792,7 +792,6 @@ libbitcoin_util_a_SOURCES = \ support/lockedpool.cpp \ chainparamsbase.cpp \ clientversion.cpp \ - compat/strnlen.cpp \ fs.cpp \ interfaces/echo.cpp \ interfaces/handler.cpp \ diff --git a/src/compat.h b/src/compat.h index 41f2cd7398..e2f784b96f 100644 --- a/src/compat.h +++ b/src/compat.h @@ -81,10 +81,6 @@ typedef int32_t ssize_t; #endif #endif -#if HAVE_DECL_STRNLEN == 0 -size_t strnlen( const char *start, size_t max_len); -#endif // HAVE_DECL_STRNLEN - #ifndef WIN32 typedef void* sockopt_arg_type; #else diff --git a/src/compat/strnlen.cpp b/src/compat/strnlen.cpp deleted file mode 100644 index 72b69953d0..0000000000 --- a/src/compat/strnlen.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2009-2014 The Bitcoin Core developers -// 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 -#endif - -#include - -#if HAVE_DECL_STRNLEN == 0 -size_t strnlen( const char *start, size_t max_len) -{ - const char *end = (const char *)memchr(start, '\0', max_len); - - return end ? (size_t)(end - start) : max_len; -} -#endif // HAVE_DECL_STRNLEN \ No newline at end of file From 11323c38511f1e5b8e1a8154124f736628db6b76 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 18 Feb 2022 15:53:18 +0000 Subject: [PATCH 04/13] merge bitcoin#24391: stop overriding user autoconf flags --- build-aux/m4/bitcoin_qt.m4 | 10 +++--- configure.ac | 67 ++++++++++++++++++++++---------------- src/Makefile.am | 6 ++-- 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/build-aux/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4 index 89f3e188ee..25a5217345 100644 --- a/build-aux/m4/bitcoin_qt.m4 +++ b/build-aux/m4/bitcoin_qt.m4 @@ -116,8 +116,8 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ BITCOIN_QT_CHECK([ TEMP_CPPFLAGS=$CPPFLAGS TEMP_CXXFLAGS=$CXXFLAGS - CPPFLAGS="$QT_INCLUDES $CPPFLAGS" - CXXFLAGS="$PIC_FLAGS $CXXFLAGS" + CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS" + CXXFLAGS="$PIC_FLAGS $CORE_CXXFLAGS $CXXFLAGS" _BITCOIN_QT_IS_STATIC if test "x$bitcoin_cv_static_qt" = xyes; then _BITCOIN_QT_CHECK_STATIC_LIBS @@ -177,8 +177,8 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ AC_MSG_CHECKING(whether -fPIE can be used with this Qt config) TEMP_CPPFLAGS=$CPPFLAGS TEMP_CXXFLAGS=$CXXFLAGS - CPPFLAGS="$QT_INCLUDES $CPPFLAGS" - CXXFLAGS="$PIE_FLAGS $CXXFLAGS" + CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS" + CXXFLAGS="$PIE_FLAGS $CORE_CXXFLAGS $CXXFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #ifndef QT_VERSION @@ -200,7 +200,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ BITCOIN_QT_CHECK([ AC_MSG_CHECKING(whether -fPIC is needed with this Qt config) TEMP_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$QT_INCLUDES $CPPFLAGS" + CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #ifndef QT_VERSION diff --git a/configure.ac b/configure.ac index 7ad8aa107b..b852a2e729 100644 --- a/configure.ac +++ b/configure.ac @@ -372,7 +372,9 @@ case $host in esac if test "x$enable_debug" = xyes; then - dnl Clear default -g -O2 flags + dnl If debugging is enabled, and the user hasn't overriden CXXFLAGS, clear + dnl them, to prevent autoconfs "-g -O2" being added. Otherwise we'd end up + dnl with "-O0 -g3 -g -O2". if test "x$CXXFLAGS_overridden" = xno; then CXXFLAGS="" fi @@ -532,7 +534,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then fi dnl Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review. -AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers],[[CXXFLAGS="$CXXFLAGS -fno-extended-identifiers"]],,[[$CXXFLAG_WERROR]]) +AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers],[[CORE_CXXFLAGS="$CORE_CXXFLAGS -fno-extended-identifiers"]],,[[$CXXFLAG_WERROR]]) enable_arm_crc=no enable_arm_shani=no @@ -683,7 +685,7 @@ CXXFLAGS="$TEMP_CXXFLAGS" fi -CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -DGSL_NO_IOSTREAMS" +CORE_CPPFLAGS="$CORE_CPPFLAGS -DHAVE_BUILD_INFO -DGSL_NO_IOSTREAMS" AC_ARG_WITH([utils], [AS_HELP_STRING([--with-utils], @@ -755,7 +757,7 @@ case $host in AC_MSG_ERROR("windres not found") fi - CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN" + CORE_CPPFLAGS="$CORE_CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN" dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against. dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override @@ -766,14 +768,14 @@ case $host in postdeps_CXX= dnl We require Windows 7 (NT 6.1) or later - AX_CHECK_LINK_FLAG([[-Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1]],[LDFLAGS="$LDFLAGS -Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1"],,[[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1]],[CORE_LDFLAGS="$CORE_LDFLAGS -Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1"],,[[$LDFLAG_WERROR]]) ;; *darwin*) TARGET_OS=darwin if test x$cross_compiling != xyes; then BUILD_OS=darwin - AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-headerpad_max_install_names"],, [[$LDFLAG_WERROR]]) AC_CHECK_PROG([BREW],brew, brew) if test x$BREW = xbrew; then @@ -800,8 +802,8 @@ case $host in gmp_prefix=$($BREW --prefix gmp 2>/dev/null) if test x$gmp_prefix != x; then - CPPFLAGS="$CPPFLAGS -I$gmp_prefix/include" - LDFLAGS="$LDFLAGS -L$gmp_prefix/lib" + CORE_CPPFLAGS="$CORE_CPPFLAGS -I$gmp_prefix/include" + CORE_LDFLAGS="$CORE_LDFLAGS -L$gmp_prefix/lib" fi case $host in @@ -813,20 +815,20 @@ case $host in if test "x$use_upnp" != xno && $BREW list --versions miniupnpc >/dev/null; then miniupnpc_prefix=$($BREW --prefix miniupnpc 2>/dev/null) if test "x$suppress_external_warnings" != xno; then - CPPFLAGS="$CPPFLAGS -isystem $miniupnpc_prefix/include" + CORE_CPPFLAGS="$CORE_CPPFLAGS -isystem $miniupnpc_prefix/include" else - CPPFLAGS="$CPPFLAGS -I$miniupnpc_prefix/include" + CORE_CPPFLAGS="$CORE_CPPFLAGS -I$miniupnpc_prefix/include" fi - LDFLAGS="$LDFLAGS -L$miniupnpc_prefix/lib" + CORE_LDFLAGS="$CORE_LDFLAGS -L$miniupnpc_prefix/lib" fi if test "x$use_natpmp" != xno && $BREW list --versions libnatpmp >/dev/null; then libnatpmp_prefix=$($BREW --prefix libnatpmp 2>/dev/null) if test "x$suppress_external_warnings" != xno; then - CPPFLAGS="$CPPFLAGS -isystem $libnatpmp_prefix/include" + CORE_CPPFLAGS="$CORE_CPPFLAGS -isystem $libnatpmp_prefix/include" else - CPPFLAGS="$CPPFLAGS -I$libnatpmp_prefix/include" + CORE_CPPFLAGS="$CORE_CPPFLAGS -I$libnatpmp_prefix/include" fi - LDFLAGS="$LDFLAGS -L$libnatpmp_prefix/lib" + CORE_LDFLAGS="$CORE_LDFLAGS -L$libnatpmp_prefix/lib" fi ;; esac @@ -849,7 +851,7 @@ case $host in esac fi - CPPFLAGS="$CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0" + CORE_CPPFLAGS="$CORE_CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0" OBJCXXFLAGS="$CXXFLAGS" ;; *android*) @@ -912,11 +914,17 @@ if test x$use_lcov = xyes; then AC_SUBST(COV_TOOL_WRAPPER, "cov_tool_wrapper.sh") LCOV="$LCOV --gcov-tool $(pwd)/$COV_TOOL_WRAPPER" - AX_CHECK_LINK_FLAG([[--coverage]], [LDFLAGS="$LDFLAGS --coverage"], + AX_CHECK_LINK_FLAG([[--coverage]], [CORE_LDFLAGS="$CORE_LDFLAGS --coverage"], [AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")]) - AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"], + AX_CHECK_COMPILE_FLAG([--coverage],[CORE_CXXFLAGS="$CORE_CXXFLAGS --coverage"], [AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")]) - CXXFLAGS="$CXXFLAGS -Og" + dnl If coverage is enabled, and the user hasn't overriden CXXFLAGS, clear + dnl them, to prevent autoconfs "-g -O2" being added. Otherwise we'd end up + dnl with "--coverage -Og -O0 -g -O2". + if test "$CXXFLAGS_overridden" = "no"; then + CXXFLAGS="" + fi + CORE_CXXFLAGS="$CORE_CXXFLAGS -Og -O0" fi if test x$use_lcov_branch != xno; then @@ -942,13 +950,13 @@ AC_FUNC_STRERROR_R if test x$ac_cv_sys_file_offset_bits != x && test x$ac_cv_sys_file_offset_bits != xno && test x$ac_cv_sys_file_offset_bits != xunknown; then - CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits" + CORE_CPPFLAGS="$CORE_CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits" fi if test x$ac_cv_sys_large_files != x && test x$ac_cv_sys_large_files != xno && test x$ac_cv_sys_large_files != xunknown; then - CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files" + CORE_CPPFLAGS="$CORE_CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files" fi if test "x$enable_gprof" = xyes; then @@ -1037,8 +1045,8 @@ dnl These flags are specific to ld64, and may cause issues with other linkers. dnl For example: GNU ld will interpret -dead_strip as -de and then try and use dnl "ad_strip" as the symbol for the entry point. if test x$TARGET_OS = xdarwin; then - AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"],, [[$LDFLAG_WERROR]]) - AX_CHECK_LINK_FLAG([[-Wl,-dead_strip_dylibs]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip_dylibs"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-dead_strip_dylibs]], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip_dylibs"],, [[$LDFLAG_WERROR]]) AX_CHECK_LINK_FLAG([[-Wl,-fixup_chains]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-fixup_chains"], [], [[$LDFLAG_WERROR]]) fi @@ -1360,7 +1368,7 @@ if test "x$enable_fuzz" = "xyes"; then [[-fsanitize=$use_sanitizers]], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([yes]) - CPPFLAGS="$CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"], + CORE_CPPFLAGS="$CORE_CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"], [], [AC_LANG_PROGRAM([[ #include @@ -1384,7 +1392,7 @@ else QT_TEST_INCLUDES=SUPPRESS_WARNINGS($QT_TEST_INCLUDES) fi - CPPFLAGS="$CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION" + CORE_CPPFLAGS="$CORE_CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION" fi if test x$enable_wallet != xno; then @@ -1517,7 +1525,7 @@ fi dnl Check for reduced exports if test x$use_reduce_exports = xyes; then - AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[CXXFLAGS="$CXXFLAGS -fvisibility=hidden"], + AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[CORE_CXXFLAGS="$CORE_CXXFLAGS -fvisibility=hidden"], [AC_MSG_ERROR([Cannot set hidden symbol visibility. Use --disable-reduce-exports.])],[[$CXXFLAG_WERROR]]) AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]],[RELDFLAGS="-Wl,--exclude-libs,ALL"],,[[$LDFLAG_WERROR]]) AX_CHECK_LINK_FLAG([-Wl,-no_exported_symbols], [LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -Wl,-no_exported_symbols"], [], [$LDFLAG_WERROR]) @@ -1869,6 +1877,9 @@ AC_SUBST(BITCOIN_MP_NODE_NAME) AC_SUBST(BITCOIN_MP_GUI_NAME) AC_SUBST(RELDFLAGS) +AC_SUBST(CORE_LDFLAGS) +AC_SUBST(CORE_CPPFLAGS) +AC_SUBST(CORE_CXXFLAGS) AC_SUBST(DEBUG_CPPFLAGS) AC_SUBST(WARN_CXXFLAGS) AC_SUBST(NOWARN_CXXFLAGS) @@ -1995,9 +2006,9 @@ echo " build os = $build_os" echo echo " CC = $CC" echo " CFLAGS = $PTHREAD_CFLAGS $CFLAGS" -echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CPPFLAGS" +echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CORE_CPPFLAGS $CPPFLAGS" echo " CXX = $CXX" -echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS" -echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS" +echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CORE_CXXFLAGS $CXXFLAGS" +echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $GPROF_LDFLAGS $CORE_LDFLAGS $LDFLAGS" echo " ARFLAGS = $ARFLAGS" echo diff --git a/src/Makefile.am b/src/Makefile.am index 7dfa2c6073..2061684a4b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,9 +9,9 @@ print-%: FORCE DIST_SUBDIRS = secp256k1 -AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS) -AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS) -AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) +AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS) $(CORE_LDFLAGS) +AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS) $(CORE_CXXFLAGS) +AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) $(CORE_CPPFLAGS) AM_LIBTOOLFLAGS = --preserve-dup-deps PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) EXTRA_LIBRARIES = From 714ea55dbe07c33c38ad3531f41f03c0b84575b7 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 7 Dec 2024 09:49:33 +0000 Subject: [PATCH 05/13] build: migrate stacktrace-related flags to `DEBUG_`{`C`,`CXX`}`FLAGS` `DEBUG_CFLAGS` doesn't exist so we need to create it --- configure.ac | 11 ++++++----- src/Makefile.am | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index b852a2e729..61f58fd9a5 100644 --- a/configure.ac +++ b/configure.ac @@ -399,11 +399,11 @@ else # Stacktraces will be suboptimal due to optimization, but better than nothing. Also, -fno-omit-frame-pointer # mitigates this a little bit if test "x$GCC" = xyes; then - CFLAGS="$CFLAGS -g1 -fno-omit-frame-pointer" + DEBUG_CFLAGS="$DEBUG_CFLAGS -g1 -fno-omit-frame-pointer" fi if test "x$GXX" = xyes; then - CXXFLAGS="$CXXFLAGS -g1 -fno-omit-frame-pointer" + DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -g1 -fno-omit-frame-pointer" fi fi @@ -431,7 +431,7 @@ if test x$LINK_WRAP_SUPPORTED = "xyes"; then fi # Needed for MinGW targets when debug symbols are enabled as compiled objects get very large -AX_CHECK_COMPILE_FLAG([-Wa,-mbig-obj], [CXXFLAGS="$CXXFLAGS -Wa,-mbig-obj"],,,) +AX_CHECK_COMPILE_FLAG([-Wa,-mbig-obj], [DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -Wa,-mbig-obj"],,,) if test x$use_sanitizers != x; then dnl First check if the compiler accepts flags. If an incompatible pair like @@ -1880,10 +1880,11 @@ AC_SUBST(RELDFLAGS) AC_SUBST(CORE_LDFLAGS) AC_SUBST(CORE_CPPFLAGS) AC_SUBST(CORE_CXXFLAGS) +AC_SUBST(DEBUG_CFLAGS) AC_SUBST(DEBUG_CPPFLAGS) +AC_SUBST(DEBUG_CXXFLAGS) AC_SUBST(WARN_CXXFLAGS) AC_SUBST(NOWARN_CXXFLAGS) -AC_SUBST(DEBUG_CXXFLAGS) AC_SUBST(ERROR_CXXFLAGS) AC_SUBST(GPROF_CXXFLAGS) AC_SUBST(GPROF_LDFLAGS) @@ -2005,7 +2006,7 @@ echo " target os = $host_os" echo " build os = $build_os" echo echo " CC = $CC" -echo " CFLAGS = $PTHREAD_CFLAGS $CFLAGS" +echo " CFLAGS = $DEBUG_CFLAGS $PTHREAD_CFLAGS $CFLAGS" echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CORE_CPPFLAGS $CPPFLAGS" echo " CXX = $CXX" echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CORE_CXXFLAGS $CXXFLAGS" diff --git a/src/Makefile.am b/src/Makefile.am index 2061684a4b..d26553a25f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,6 +10,7 @@ print-%: FORCE DIST_SUBDIRS = secp256k1 AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS) $(CORE_LDFLAGS) +AM_CFLAGS = $(DEBUG_CFLAGS) AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS) $(CORE_CXXFLAGS) AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) $(CORE_CPPFLAGS) AM_LIBTOOLFLAGS = --preserve-dup-deps From 000495df8e8e7280288413f9df58618691f4c52d Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:04:44 +0000 Subject: [PATCH 06/13] merge bitcoin#25338: Avoid incompatibility with CMake AUTOUIC feature --- src/Makefile.am | 4 ++-- src/banman.cpp | 2 +- src/bitcoind.cpp | 2 +- src/httpserver.cpp | 2 +- src/index/base.cpp | 2 +- src/init.cpp | 2 +- src/init/common.cpp | 2 +- src/llmq/chainlocks.cpp | 2 +- src/masternode/sync.cpp | 4 ++-- src/net.cpp | 2 +- src/node/{ui_interface.cpp => interface_ui.cpp} | 2 +- src/node/{ui_interface.h => interface_ui.h} | 6 +++--- src/node/interfaces.cpp | 2 +- src/noui.cpp | 2 +- src/qt/bitcoin.cpp | 2 +- src/qt/bitcoingui.cpp | 2 +- src/qt/paymentserver.cpp | 2 +- src/qt/sendcoinsdialog.cpp | 2 +- src/qt/transactionview.cpp | 2 +- src/qt/walletframe.cpp | 2 +- src/qt/walletmodel.cpp | 2 +- src/qt/walletview.cpp | 2 +- src/shutdown.cpp | 2 +- src/timedata.cpp | 2 +- src/txdb.cpp | 2 +- src/validation.cpp | 2 +- src/wallet/init.cpp | 2 +- 27 files changed, 31 insertions(+), 31 deletions(-) rename src/node/{ui_interface.cpp => interface_ui.cpp} (99%) rename src/node/{ui_interface.h => interface_ui.h} (98%) diff --git a/src/Makefile.am b/src/Makefile.am index d26553a25f..7c615cc7dd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -280,7 +280,7 @@ BITCOIN_CORE_H = \ node/psbt.h \ node/transaction.h \ node/txreconciliation.h \ - node/ui_interface.h \ + node/interface_ui.h \ node/utxo_snapshot.h \ noui.h \ outputtype.h \ @@ -513,7 +513,7 @@ libbitcoin_server_a_SOURCES = \ node/psbt.cpp \ node/transaction.cpp \ node/txreconciliation.cpp \ - node/ui_interface.cpp \ + node/interface_ui.cpp \ noui.cpp \ policy/fees.cpp \ policy/packages.cpp \ diff --git a/src/banman.cpp b/src/banman.cpp index c162eb08fd..d319a2a996 100644 --- a/src/banman.cpp +++ b/src/banman.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index d026c7c1f3..c16167f412 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 504f3cf642..b4b263eb50 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include // For HTTP status codes #include #include diff --git a/src/index/base.cpp b/src/index/base.cpp index cae1cc75fd..9cc326b9e9 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/init.cpp b/src/init.cpp index fdd3d4a294..e85721ce74 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/init/common.cpp b/src/init/common.cpp index 2a83ae16b7..f775810a72 100644 --- a/src/init/common.cpp +++ b/src/init/common.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/llmq/chainlocks.cpp b/src/llmq/chainlocks.cpp index 1ef7d22b91..1b6f56f5c8 100644 --- a/src/llmq/chainlocks.cpp +++ b/src/llmq/chainlocks.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/masternode/sync.cpp b/src/masternode/sync.cpp index dc8cc60f76..09d89d9f0e 100644 --- a/src/masternode/sync.cpp +++ b/src/masternode/sync.cpp @@ -8,11 +8,11 @@ #include #include #include -#include +#include #include -#include #include #include +#include class CMasternodeSync; diff --git a/src/net.cpp b/src/net.cpp index db234f4876..5f82196c42 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/node/ui_interface.cpp b/src/node/interface_ui.cpp similarity index 99% rename from src/node/ui_interface.cpp rename to src/node/interface_ui.cpp index 23c5e2b255..b01d20bb3e 100644 --- a/src/node/ui_interface.cpp +++ b/src/node/interface_ui.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include +#include #include diff --git a/src/node/ui_interface.h b/src/node/interface_ui.h similarity index 98% rename from src/node/ui_interface.h rename to src/node/interface_ui.h index a21ffb088d..3f8b683de2 100644 --- a/src/node/ui_interface.h +++ b/src/node/interface_ui.h @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef BITCOIN_NODE_UI_INTERFACE_H -#define BITCOIN_NODE_UI_INTERFACE_H +#ifndef BITCOIN_NODE_INTERFACE_UI_H +#define BITCOIN_NODE_INTERFACE_UI_H #include #include @@ -131,4 +131,4 @@ constexpr auto AbortError = InitError; extern CClientUIInterface uiInterface; -#endif // BITCOIN_NODE_UI_INTERFACE_H +#endif // BITCOIN_NODE_INTERFACE_UI_H diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 154b447aa3..90a4c51d7e 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/noui.cpp b/src/noui.cpp index 57bbe39c90..11bfdbc80b 100644 --- a/src/noui.cpp +++ b/src/noui.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 11b189b6c2..79a1db9002 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 734360d53f..4e2d32b031 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 72553e81bb..2eb28aca35 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 1319d1d836..5012e9342c 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 55760147c5..8102c53de6 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index d97b1d7553..9e177c673e 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index f0ed7ef0fe..d4a88de83b 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include // for GetBoolArg #include diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 1a99436660..390df73576 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/src/shutdown.cpp b/src/shutdown.cpp index f500fa529e..fe88b3aa46 100644 --- a/src/shutdown.cpp +++ b/src/shutdown.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/src/timedata.cpp b/src/timedata.cpp index a0b8c33e7a..54378a5cf1 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/txdb.cpp b/src/txdb.cpp index 23e2480c4c..f780b56b44 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/validation.cpp b/src/validation.cpp index 5f093aa1b2..d1681a265b 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 15b3306f82..8f7a416939 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include From 3f143096c8b3ebfbd67ec9ad95276cde0509de5d Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Mon, 20 Jun 2022 11:43:21 +0100 Subject: [PATCH 07/13] merge bitcoin#25422: globally define NOMINMAX when building with mingw-w64 --- configure.ac | 3 +++ src/compat.h | 3 --- src/fs.cpp | 3 --- src/qt/guiutil.cpp | 3 --- src/support/lockedpool.cpp | 3 --- src/util/system.cpp | 3 --- 6 files changed, 3 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 61f58fd9a5..af682ac9c1 100644 --- a/configure.ac +++ b/configure.ac @@ -758,6 +758,9 @@ case $host in fi CORE_CPPFLAGS="$CORE_CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN" + dnl Prevent the definition of min/max macros. + dnl We always want to use the standard library. + CORE_CPPFLAGS="$CORE_CPPFLAGS -DNOMINMAX" dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against. dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override diff --git a/src/compat.h b/src/compat.h index e2f784b96f..7940d78103 100644 --- a/src/compat.h +++ b/src/compat.h @@ -11,9 +11,6 @@ #endif #ifdef WIN32 -#ifndef NOMINMAX -#define NOMINMAX -#endif #ifdef FD_SETSIZE #undef FD_SETSIZE // prevent redefinition compiler warning #endif diff --git a/src/fs.cpp b/src/fs.cpp index 7e216099ad..03afb11ba4 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -11,9 +11,6 @@ #include #include #else -#ifndef NOMINMAX -#define NOMINMAX -#endif #include #include #include diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 84afe40bba..2574adee48 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -29,9 +29,6 @@ #include #ifdef WIN32 -#ifndef NOMINMAX -#define NOMINMAX -#endif #include #include #include diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index 14ad4782d7..766e817a8a 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -10,9 +10,6 @@ #endif #ifdef WIN32 -#ifndef NOMINMAX -#define NOMINMAX -#endif #include #else #include // for mmap diff --git a/src/util/system.cpp b/src/util/system.cpp index 84d633db09..563a7bf4b0 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -60,9 +60,6 @@ #pragma warning(disable:4717) #endif -#ifndef NOMINMAX -#define NOMINMAX -#endif #include #include /* for _commit */ From bbb0cceb7a1926daad6bb5860d90e05caaaf7989 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:27:57 +0100 Subject: [PATCH 08/13] merge bitcoin#25493: document code in compat.h --- src/Makefile.am | 2 +- src/bitcoin-cli.cpp | 2 +- src/bitcoin-tx.cpp | 2 +- src/bitcoin-wallet.cpp | 2 +- src/bitcoind.cpp | 2 +- src/{ => compat}/compat.h | 52 +++++++++++++++----------- src/i2p.cpp | 2 +- src/i2p.h | 2 +- src/mapport.cpp | 2 +- src/net.cpp | 2 +- src/net.h | 2 +- src/netaddress.h | 2 +- src/netbase.cpp | 2 +- src/netbase.h | 2 +- src/qt/main.cpp | 2 +- src/random.cpp | 2 +- src/randomenv.cpp | 2 +- src/stats/rawsender.h | 2 +- src/test/fuzz/util.h | 2 +- src/test/fuzz/util/net.cpp | 2 +- src/test/net_peer_connection_tests.cpp | 2 +- src/test/net_tests.cpp | 2 +- src/test/sock_tests.cpp | 2 +- src/test/util/net.h | 2 +- src/torcontrol.cpp | 2 +- src/util/edge.h | 2 +- src/util/sock.cpp | 2 +- src/util/sock.h | 2 +- src/util/system.h | 2 +- src/util/time.cpp | 2 +- src/util/time.h | 2 +- src/wallet/bdb.cpp | 1 + 32 files changed, 61 insertions(+), 52 deletions(-) rename src/{ => compat}/compat.h (72%) diff --git a/src/Makefile.am b/src/Makefile.am index 7c615cc7dd..3b714b247c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -163,9 +163,9 @@ BITCOIN_CORE_H = \ coinjoin/util.h \ coins.h \ common/bloom.h \ - compat.h \ compat/assumptions.h \ compat/byteswap.h \ + compat/compat.h \ compat/cpuid.h \ compat/endian.h \ compressor.h \ diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 045cf0ae76..43790e9ac4 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 0eb122f086..cb40879f8e 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/bitcoin-wallet.cpp b/src/bitcoin-wallet.cpp index 8e7c1490fd..4dfb973042 100644 --- a/src/bitcoin-wallet.cpp +++ b/src/bitcoin-wallet.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index c16167f412..a3b9910e2d 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/compat.h b/src/compat/compat.h similarity index 72% rename from src/compat.h rename to src/compat/compat.h index 7940d78103..eeac0805db 100644 --- a/src/compat.h +++ b/src/compat/compat.h @@ -3,21 +3,24 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef BITCOIN_COMPAT_H -#define BITCOIN_COMPAT_H +#ifndef BITCOIN_COMPAT_COMPAT_H +#define BITCOIN_COMPAT_COMPAT_H #if defined(HAVE_CONFIG_H) #include #endif +// Windows defines FD_SETSIZE to 64 (see _fd_types.h in mingw-w64), +// which is too small for our usage, but allows us to redefine it safely. +// We redefine it to be 1024, to match glibc, see typesizes.h. #ifdef WIN32 #ifdef FD_SETSIZE -#undef FD_SETSIZE // prevent redefinition compiler warning +#undef FD_SETSIZE #endif -#define FD_SETSIZE 1024 // max number of fds in fd_set +#define FD_SETSIZE 1024 #include #include -#include +#include #else #include #include @@ -34,50 +37,55 @@ #include #endif +// We map Linux / BSD error functions and codes, to the equivalent +// Windows definitions, and use the WSA* names throughout our code. +// Note that glibc defines EWOULDBLOCK as EAGAIN (see errno.h). #ifndef WIN32 typedef unsigned int SOCKET; -#include +#include #define WSAGetLastError() errno #define WSAEINVAL EINVAL -#define WSAEALREADY EALREADY #define WSAEWOULDBLOCK EWOULDBLOCK #define WSAEAGAIN EAGAIN #define WSAEMSGSIZE EMSGSIZE #define WSAEINTR EINTR #define WSAEINPROGRESS EINPROGRESS #define WSAEADDRINUSE EADDRINUSE -#define WSAENOTSOCK EBADF #define INVALID_SOCKET (SOCKET)(~0) #define SOCKET_ERROR -1 #define SD_SEND SHUT_WR #else -#ifndef WSAEAGAIN +// WSAEAGAIN doesn't exist on Windows #ifdef EAGAIN #define WSAEAGAIN EAGAIN #else #define WSAEAGAIN WSAEWOULDBLOCK #endif #endif -#endif +// Windows doesn't define S_IRUSR or S_IWUSR. We define both +// here, with the same values as glibc (see stat.h). #ifdef WIN32 #ifndef S_IRUSR #define S_IRUSR 0400 #define S_IWUSR 0200 #endif -#else -#define MAX_PATH 1024 -#endif -#ifdef _MSC_VER -#if !defined(ssize_t) -#ifdef _WIN64 -typedef int64_t ssize_t; -#else -typedef int32_t ssize_t; -#endif -#endif #endif +// Windows defines MAX_PATH as it's maximum path length. +// We define MAX_PATH for use on non-Windows systems. +#ifndef WIN32 +#define MAX_PATH 1024 +#endif + +// ssize_t is POSIX, and not present when using MSVC. +#ifdef _MSC_VER +#include +typedef SSIZE_T ssize_t; +#endif + +// The type of the option value passed to getsockopt & setsockopt +// differs between Windows and non-Windows. #ifndef WIN32 typedef void* sockopt_arg_type; #else @@ -128,4 +136,4 @@ bool static inline IsSelectableSocket(const SOCKET& s) { #define MSG_DONTWAIT 0 #endif -#endif // BITCOIN_COMPAT_H +#endif // BITCOIN_COMPAT_COMPAT_H diff --git a/src/i2p.cpp b/src/i2p.cpp index 507bdeab55..8ecb50645f 100644 --- a/src/i2p.cpp +++ b/src/i2p.cpp @@ -3,7 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -#include +#include #include #include #include diff --git a/src/i2p.h b/src/i2p.h index f9619de9c5..fc9256160b 100644 --- a/src/i2p.h +++ b/src/i2p.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_I2P_H #define BITCOIN_I2P_H -#include +#include #include #include #include diff --git a/src/mapport.cpp b/src/mapport.cpp index ecdbcdff12..5a38353070 100644 --- a/src/mapport.cpp +++ b/src/mapport.cpp @@ -18,7 +18,7 @@ #include #ifdef USE_NATPMP -#include +#include #include #endif // USE_NATPMP diff --git a/src/net.cpp b/src/net.cpp index 5f82196c42..9bfb813178 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/net.h b/src/net.h index 446e687048..524f0a244b 100644 --- a/src/net.h +++ b/src/net.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/netaddress.h b/src/netaddress.h index 102de00225..4d53ed9694 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -10,7 +10,7 @@ #endif #include -#include +#include #include #include #include diff --git a/src/netbase.cpp b/src/netbase.cpp index cf1ba19e65..adaf3fa629 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -5,7 +5,7 @@ #include -#include +#include #include #include #include diff --git a/src/netbase.h b/src/netbase.h index 9478555d59..51233967b3 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -9,7 +9,7 @@ #include #endif -#include +#include #include #include #include diff --git a/src/qt/main.cpp b/src/qt/main.cpp index a1220b9a59..eca9e9d88f 100644 --- a/src/qt/main.cpp +++ b/src/qt/main.cpp @@ -4,7 +4,7 @@ #include -#include +#include #include #include diff --git a/src/random.cpp b/src/random.cpp index 7d3b20bd65..ec8a46b328 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -11,7 +11,7 @@ #include #include #ifdef WIN32 -#include // for Windows API +#include #include #endif #include diff --git a/src/randomenv.cpp b/src/randomenv.cpp index 06ac6d8f93..d722256544 100644 --- a/src/randomenv.cpp +++ b/src/randomenv.cpp @@ -16,7 +16,7 @@ #include #include // for GetTime() #ifdef WIN32 -#include // for Windows API +#include #endif #include diff --git a/src/stats/rawsender.h b/src/stats/rawsender.h index d91f6c0def..fc0b0d6795 100644 --- a/src/stats/rawsender.h +++ b/src/stats/rawsender.h @@ -6,7 +6,7 @@ #ifndef BITCOIN_STATS_RAWSENDER_H #define BITCOIN_STATS_RAWSENDER_H -#include +#include #include #include diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index 43864a5453..ebf741651b 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/test/fuzz/util/net.cpp b/src/test/fuzz/util/net.cpp index a1494f8d3b..f8e996cfa5 100644 --- a/src/test/fuzz/util/net.cpp +++ b/src/test/fuzz/util/net.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include +#include #include #include #include diff --git a/src/test/net_peer_connection_tests.cpp b/src/test/net_peer_connection_tests.cpp index 2a09791daf..c232baa93d 100644 --- a/src/test/net_peer_connection_tests.cpp +++ b/src/test/net_peer_connection_tests.cpp @@ -3,7 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -#include +#include #include #include #include diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index 02a958185f..1ff098cd1f 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/test/sock_tests.cpp b/src/test/sock_tests.cpp index 9e98f4f0b1..fa95fc0ba5 100644 --- a/src/test/sock_tests.cpp +++ b/src/test/sock_tests.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include +#include #include #include #include diff --git a/src/test/util/net.h b/src/test/util/net.h index 4c2be00e49..7ca37616e5 100644 --- a/src/test/util/net.h +++ b/src/test/util/net.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_TEST_UTIL_NET_H #define BITCOIN_TEST_UTIL_NET_H -#include +#include #include #include #include diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 26154a9939..a89099ecfd 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/util/edge.h b/src/util/edge.h index 8e3ec357a1..7ac354c8bf 100644 --- a/src/util/edge.h +++ b/src/util/edge.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_UTIL_EDGE_H #define BITCOIN_UTIL_EDGE_H -#include +#include #include #include diff --git a/src/util/sock.cpp b/src/util/sock.cpp index 1d12669652..87e63b70c3 100644 --- a/src/util/sock.cpp +++ b/src/util/sock.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include +#include #include #include #include diff --git a/src/util/sock.h b/src/util/sock.h index 4c18e71e0c..4d32d50e5e 100644 --- a/src/util/sock.h +++ b/src/util/sock.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_UTIL_SOCK_H #define BITCOIN_UTIL_SOCK_H -#include +#include #include #include diff --git a/src/util/system.h b/src/util/system.h index 5779beb065..2983107c22 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -16,8 +16,8 @@ #endif #include -#include #include +#include #include #include #include diff --git a/src/util/time.cpp b/src/util/time.cpp index 2b9a469d9a..80f6891328 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -7,7 +7,7 @@ #include #endif -#include +#include #include #include diff --git a/src/util/time.h b/src/util/time.h index 306a1ae3f2..32bdebb205 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -6,7 +6,7 @@ #ifndef BITCOIN_UTIL_TIME_H #define BITCOIN_UTIL_TIME_H -#include +#include #include #include diff --git a/src/wallet/bdb.cpp b/src/wallet/bdb.cpp index 1509f9c177..4d642192ce 100644 --- a/src/wallet/bdb.cpp +++ b/src/wallet/bdb.cpp @@ -3,6 +3,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include #include #include #include From 94e6637c33d1ea5616be3af486c8f75d18f55ad4 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 5 Jan 2023 19:36:10 +0000 Subject: [PATCH 09/13] merge bitcoin#26826: remove windows-only compat.h usage in randomenv --- src/randomenv.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/randomenv.cpp b/src/randomenv.cpp index d722256544..01e8f62e9c 100644 --- a/src/randomenv.cpp +++ b/src/randomenv.cpp @@ -14,21 +14,21 @@ #include #include #include -#include // for GetTime() -#ifdef WIN32 -#include -#endif +#include #include #include +#include +#include #include #include #include #include -#include -#include -#ifndef WIN32 +#ifdef WIN32 +#include +#include +#else #include // must go before a number of other headers #include #include From db676a7e5f4edc87fef2bc24fe698c99e3c6de01 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:20:50 +0000 Subject: [PATCH 10/13] merge bitcoin#26814: remove windows-only compat.h usage in random --- src/random.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/random.cpp b/src/random.cpp index ec8a46b328..e98b068d3c 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -9,24 +9,23 @@ #include #include #include -#include -#ifdef WIN32 -#include -#include -#endif #include #include -#include #include -#include // for Mutex -#include // for GetTimeMicros() +#include +#include +#include +#include #include #include #include #include -#ifndef WIN32 +#ifdef WIN32 +#include +#include +#else #include #endif @@ -729,7 +728,7 @@ bool Random_SanityCheck() * GetOSRand() overwrites all 32 bytes of the output given a maximum * number of tries. */ - static const ssize_t MAX_TRIES = 1024; + static constexpr int MAX_TRIES{1024}; uint8_t data[NUM_OS_RANDOM_BYTES]; bool overwritten[NUM_OS_RANDOM_BYTES] = {}; /* Tracks which bytes have been overwritten at least once */ int num_overwritten; From a497df03397f982ac5d4e3e2ce2ddd5cfeea95bf Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Tue, 24 Jan 2023 12:18:08 +0000 Subject: [PATCH 11/13] merge bitcoin#26832: move (win) S_* defines into bdb --- src/compat/compat.h | 9 --------- src/randomenv.cpp | 3 ++- src/test/util_tests.cpp | 4 +++- src/wallet/bdb.cpp | 9 ++++++++- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/compat/compat.h b/src/compat/compat.h index eeac0805db..5dd73eb717 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -63,15 +63,6 @@ typedef unsigned int SOCKET; #endif #endif -// Windows doesn't define S_IRUSR or S_IWUSR. We define both -// here, with the same values as glibc (see stat.h). -#ifdef WIN32 -#ifndef S_IRUSR -#define S_IRUSR 0400 -#define S_IWUSR 0200 -#endif -#endif - // Windows defines MAX_PATH as it's maximum path length. // We define MAX_PATH for use on non-Windows systems. #ifndef WIN32 diff --git a/src/randomenv.cpp b/src/randomenv.cpp index 01e8f62e9c..4cfe94acac 100644 --- a/src/randomenv.cpp +++ b/src/randomenv.cpp @@ -25,11 +25,12 @@ #include #include +#include // must go before a number of other headers + #ifdef WIN32 #include #include #else -#include // must go before a number of other headers #include #include #include diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 1a53f5cb16..fbdb851ae1 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -37,9 +37,11 @@ #include #include #include + +#include + #ifndef WIN32 #include -#include #include #endif diff --git a/src/wallet/bdb.cpp b/src/wallet/bdb.cpp index 4d642192ce..ef6947a25f 100644 --- a/src/wallet/bdb.cpp +++ b/src/wallet/bdb.cpp @@ -13,8 +13,15 @@ #include -#ifndef WIN32 #include + +// Windows may not define S_IRUSR or S_IWUSR. We define both +// here, with the same values as glibc (see stat.h). +#ifdef WIN32 +#ifndef S_IRUSR +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#endif #endif namespace { From 280988bee3f26857b248bff9ca1b5b934eaade9c Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Tue, 4 Apr 2023 13:25:41 +0200 Subject: [PATCH 12/13] merge bitcoin#27418: Remove windows workaround in authproxy --- test/functional/test_framework/authproxy.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py index 4f31d12798..5673f47826 100644 --- a/test/functional/test_framework/authproxy.py +++ b/test/functional/test_framework/authproxy.py @@ -39,7 +39,6 @@ from http import HTTPStatus import http.client import json import logging -import os import socket import time import urllib.parse @@ -101,11 +100,6 @@ class AuthServiceProxy(): 'User-Agent': USER_AGENT, 'Authorization': self.__auth_header, 'Content-type': 'application/json'} - if os.name == 'nt': - # Windows somehow does not like to re-use connections - # TODO: Find out why the connection would disconnect occasionally and make it reusable on Windows - # Avoid "ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine" - self._set_conn() try: self.__conn.request(method, path, postdata, headers) return self._get_response() From 2ab561d281f3429c239c7838996ab629c9b94ebe Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Wed, 15 Mar 2023 20:02:32 +0100 Subject: [PATCH 13/13] partial bitcoin#27254: Extract util/fs from util/system includes: - b202b3dd6393b415fa68e18dc49c9431dc6b58b2 --- src/compat/assumptions.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compat/assumptions.h b/src/compat/assumptions.h index 487ab9aa9e..0298f78b96 100644 --- a/src/compat/assumptions.h +++ b/src/compat/assumptions.h @@ -8,6 +8,7 @@ #ifndef BITCOIN_COMPAT_ASSUMPTIONS_H #define BITCOIN_COMPAT_ASSUMPTIONS_H +#include #include // Assumption: We assume that the macro NDEBUG is not defined.