From 9ef9d98788b42b9a048d0d40f98e72a392cea680 Mon Sep 17 00:00:00 2001 From: frstrtr Date: Sun, 5 Jul 2026 09:08:26 +0000 Subject: [PATCH 1/2] build: Boost.Asio handler-invoke compat shim for conan 1.90 vs legacy system Boost conan pins Boost 1.90, which removed boost/asio/detail/handler_invoke_helpers.hpp and the boost_asio_handler_invoke_helpers namespace. On build hosts carrying a legacy system Boost (e.g. libboost-dev 1.83 under /usr/include), that trees --- CMakeLists.txt | 6 ++++ src/core/boost_asio_compat.hpp | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/core/boost_asio_compat.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cde81ab0..1c7d73d9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,12 @@ endif() include_directories(include) include_directories(src) +# Boost.Asio build compat (build-only, no behaviour change): force-include the +# handler_invoke_helpers shim ahead of every C++ TU so a legacy system Boost +# leaking boost/asio/impl/system_executor.hpp cannot break the conan-pinned +# build on any coin, regardless of ccache eviction. See core/boost_asio_compat.hpp. +add_compile_options("$<$:-include;core/boost_asio_compat.hpp>") + # Make secp256k1 headers available globally (needed by btclibs, impl/) if(SECP256K1_INCLUDE_DIRS) include_directories(${SECP256K1_INCLUDE_DIRS}) diff --git a/src/core/boost_asio_compat.hpp b/src/core/boost_asio_compat.hpp new file mode 100644 index 000000000..805578efa --- /dev/null +++ b/src/core/boost_asio_compat.hpp @@ -0,0 +1,57 @@ +#pragma once +// +// core/boost_asio_compat.hpp +// +// Build-only compatibility shim for Boost.Asio's removed +// boost_asio_handler_invoke_helpers namespace. This is NOT a behaviour change. +// +// c2pool pins Boost via conan (currently 1.90), which deleted +// boost/asio/detail/handler_invoke_helpers.hpp together with the +// boost_asio_handler_invoke_helpers namespace (the asio_handler_invoke hooks +// were deprecated in Boost 1.79 and dropped thereafter). On build hosts that +// also carry a legacy *system* Boost (e.g. libboost-dev 1.83 under +// /usr/include), that older tree's boost/asio/impl/system_executor.hpp can +// leak onto the include path and still calls +// boost_asio_handler_invoke_helpers::invoke(f, f); +// yielding "'boost_asio_handler_invoke_helpers' has not been declared" when +// the conan (>= 1.90) headers no longer provide it. +// +// This header supplies that namespace's historical *default* (hook-free) +// invoke so the leaked impl resolves. The body mirrors Boost's own +// BOOST_ASIO_HAS_HANDLER_HOOKS-disabled path (copy the function, then call +// it), which is identical to how Boost >= 1.90 dispatches internally. c2pool +// defines no asio_handler_invoke overloads, so behaviour is unchanged. +// +// It is force-included ahead of every C++ translation unit (see the top-level +// CMakeLists.txt) so all five coins keep building regardless of ccache +// eviction. Guarded so it stays inert on any Boost that still ships the +// namespace itself. +// +#include + +#if BOOST_VERSION >= 108400 +// Claim Boost's own include guard so that, if the real (legacy) header is +// reached later in the same TU, it becomes a no-op instead of a redefinition. +#ifndef BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP +#define BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP + +namespace boost_asio_handler_invoke_helpers { + +template +inline void invoke(Function& function, Context& /*context*/) +{ + Function tmp(function); + tmp(); +} + +template +inline void invoke(const Function& function, Context& /*context*/) +{ + Function tmp(function); + tmp(); +} + +} // namespace boost_asio_handler_invoke_helpers + +#endif // BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP +#endif // BOOST_VERSION >= 108400 From 7f38f72e4ebbfc04b9b00912565667fecd199c99 Mon Sep 17 00:00:00 2001 From: frstrtr Date: Sun, 5 Jul 2026 12:08:52 +0000 Subject: [PATCH 2/2] build: gate Boost.Asio compat force-include to non-MSVC Windows/MSVC has no legacy system Boost under /usr/include to leak boost/asio/impl/system_executor.hpp, so it never needs the shim and cannot resolve the relative force-include path (C1083). Wrap the add_compile_options in if(NOT MSVC); Linux/macOS keep the proven fix. --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c7d73d9a..22f213c88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,12 @@ include_directories(src) # handler_invoke_helpers shim ahead of every C++ TU so a legacy system Boost # leaking boost/asio/impl/system_executor.hpp cannot break the conan-pinned # build on any coin, regardless of ccache eviction. See core/boost_asio_compat.hpp. -add_compile_options("$<$:-include;core/boost_asio_compat.hpp>") +# MSVC/Windows carries no legacy *system* Boost under /usr/include, so it has +# nothing to leak and does not need (or resolve) this force-include. Gating to +# non-MSVC avoids C1083 on the MSVC path while keeping the Linux/macOS fix. +if(NOT MSVC) + add_compile_options("$<$:-include;core/boost_asio_compat.hpp>") +endif() # Make secp256k1 headers available globally (needed by btclibs, impl/) if(SECP256K1_INCLUDE_DIRS)