From 60d0ae4ef967761823cc78b6ba8c6359afba5170 Mon Sep 17 00:00:00 2001 From: a-k-l-sdao Date: Sun, 17 May 2026 12:09:01 -0600 Subject: [PATCH] build: fix compilation on modern toolchains (GCC 13+, CMake 4, miniupnpc 2.3) The 2019-era code no longer builds on current Linux toolchains. Changes: * CMakeLists.txt: set CMAKE_POLICY_VERSION_MINIMUM=3.5 so bundled subprojects (bls, secp256k1, leveldb, univalue, qt) that declare cmake_minimum_required(<3.5) still configure under CMake 4.x, which removed that compatibility. * src/compat/modern_prelude.h (new) + force-include via CMakeLists.txt: modern libstdc++ (GCC 13+) no longer transitively pulls in , , container headers, etc. A small force-included prelude fixes this tree-wide instead of editing hundreds of files. * cmake/modules/FindBerkeleyDB.cmake: also search db5.x include path suffixes and version-suffixed library names (libdb_cxx-5.3), as used by current distros. * cmake/modules/FindMiniupnpc.cmake: prepend stddef.h to the header self-compile check. miniupnpc 2.3.x headers reference size_t without including it, which otherwise wrongly marked miniupnpc as missing and broke linking. * src/net.cpp: use the 7-argument UPNP_GetValidIGD signature (added wanaddr/wanaddrlen) for MINIUPNPC_API_VERSION >= 18. * src/support/lockedpool.cpp, src/validation.cpp: add explicit standard includes that were previously available only transitively. Result: a clean `cmake .. && make` builds devaultd, devault-cli, devault-tx and devault-qt with no extra flags. Co-Authored-By: Claude Opus 4.7 --- CMakeLists.txt | 15 +++++++++++++ cmake/modules/FindBerkeleyDB.cmake | 6 +++-- cmake/modules/FindMiniupnpc.cmake | 5 ++++- src/compat/modern_prelude.h | 36 ++++++++++++++++++++++++++++++ src/net.cpp | 6 +++++ src/support/lockedpool.cpp | 1 + src/validation.cpp | 2 ++ 7 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 src/compat/modern_prelude.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 821ec5fba..64b180ad6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,12 +3,27 @@ cmake_minimum_required(VERSION 3.12) +# CMake 4.x removed compatibility with cmake_minimum_required(<3.5), which +# several bundled subprojects (bls, secp256k1, leveldb, univalue, qt) still +# declare. Allow them to configure under modern CMake. +if(NOT DEFINED CMAKE_POLICY_VERSION_MINIMUM) + set(CMAKE_POLICY_VERSION_MINIMUM 3.5) +endif() + project(devault VERSION 1.2.1 # DESCRIPTION "DeVault is a full node implementation of the DeVault protocol." # HOMEPAGE_URL "https://www.devault.cc" ) +# Modern libstdc++ (GCC 13+) no longer transitively includes many standard +# headers (, , containers, ...) that this 2019-era code +# relied on. Force-include a small compatibility prelude into every C++ TU +# instead of editing hundreds of files. +add_compile_options( + "$<$:-include;${CMAKE_CURRENT_SOURCE_DIR}/src/compat/modern_prelude.h>" +) + enable_testing() # Package information diff --git a/cmake/modules/FindBerkeleyDB.cmake b/cmake/modules/FindBerkeleyDB.cmake index c71865f5a..d5fc284bd 100644 --- a/cmake/modules/FindBerkeleyDB.cmake +++ b/cmake/modules/FindBerkeleyDB.cmake @@ -10,19 +10,21 @@ find_brew_prefix(BREW_HINT berkeley-db) find_path(BDB_INCLUDE_DIR NAMES db.h + PATH_SUFFIXES db5.3 db5 db4.8 db4 HINTS ${BREW_HINT} ) find_library(BDB_LIBRARY - NAMES db libdb + NAMES db libdb db-5.3 db-5 db-4.8 HINTS ${BREW_HINT} ) find_path(BDBXX_INCLUDE_DIR NAMES db_cxx.h + PATH_SUFFIXES db5.3 db5 db4.8 db4 HINTS ${BREW_HINT} ) find_library(BDBXX_LIBRARY - NAMES db_cxx libdb_cxx + NAMES db_cxx libdb_cxx db_cxx-5.3 db_cxx-5 db_cxx-4.8 HINTS ${BREW_HINT} ) diff --git a/cmake/modules/FindMiniupnpc.cmake b/cmake/modules/FindMiniupnpc.cmake index c2b0b8db3..4ef7138f1 100644 --- a/cmake/modules/FindMiniupnpc.cmake +++ b/cmake/modules/FindMiniupnpc.cmake @@ -21,7 +21,10 @@ if(MINIUPNPC_INCLUDE_DIR) set(CMAKE_REQUIRED_INCLUDES ${MINIUPNPC_INCLUDE_DIR}) foreach(_miniupnpc_header ${MINIUPNPC_REQUIRED_HEADERS}) sanitize_variable(HAVE_MINIUPNPC_ ${_miniupnpc_header} HEADER_FOUND) - check_include_files(${_miniupnpc_header} ${HEADER_FOUND}) + # Prepend stddef.h: newer miniupnpc headers (2.3.x) reference size_t + # without including it, which would otherwise fail this self-compile + # check and wrongly mark miniupnpc as missing. + check_include_files("stddef.h;${_miniupnpc_header}" ${HEADER_FOUND}) if(NOT ${HEADER_FOUND}) set(MINIUPNPC_MISSING_HEADER ON) endif() diff --git a/src/compat/modern_prelude.h b/src/compat/modern_prelude.h new file mode 100644 index 000000000..bccd32dfd --- /dev/null +++ b/src/compat/modern_prelude.h @@ -0,0 +1,36 @@ +// Compatibility prelude force-included for all C++ TUs (see top-level +// CMAKE_CXX_FLAGS "-include"). Modern libstdc++ (GCC 13+) no longer pulls +// these in transitively the way the 2019-era code assumed. Including the +// common set here once avoids sprinkling includes across the tree (and +// avoids many slow rebuild cycles) just to build on a current toolchain. +#ifndef DEVAULT_COMPAT_MODERN_PRELUDE_H +#define DEVAULT_COMPAT_MODERN_PRELUDE_H + +// C library shims +#include +#include +#include +#include +#include +#include + +// Common utilities +#include +#include +#include +#include +#include +#include +#include + +// Common containers +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // DEVAULT_COMPAT_MODERN_PRELUDE_H diff --git a/src/net.cpp b/src/net.cpp index e6e2dea65..18e5599d3 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1420,7 +1420,13 @@ static void ThreadMapPort() { struct IGDdatas data; int r; +#if MINIUPNPC_API_VERSION >= 18 + char wanaddr[64]; + r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr), + wanaddr, sizeof(wanaddr)); +#else r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); +#endif if (r == 1) { if (fDiscover) { char externalIPAddress[40]; diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index 1c5271f8a..a19fee9e7 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -25,6 +25,7 @@ #endif #include +#include LockedPoolManager *LockedPoolManager::_instance = nullptr; std::once_flag LockedPoolManager::init_flag; diff --git a/src/validation.cpp b/src/validation.cpp index c2ddbf562..52861a617 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -54,7 +54,9 @@ #include // Temporary #include +#include #include +#include #include #include