From b0e0d211d22bd933d6eba4cc3af0385baa76545f Mon Sep 17 00:00:00 2001 From: DanS Date: Fri, 20 Nov 2026 19:04:51 -0600 Subject: [PATCH] build: list libbitcoin_server again after libbitcoin_wallet when linking libbitcoin_server and libbitcoin_wallet use each other: the server's init and RPC code calls into the wallet, and the wallet's async operations derive from the server's AsyncRPCOperation. GNU ld (Linux and mingw) scans each static archive once, in order, so dragonxd and hush-gtest only linked because some server object happened to reference asyncrpcoperation.o directly and pull it in on the first pass: AsyncRPCQueue called the non-virtual AsyncRPCOperation::cancel(). Making cancel() virtual, as the next commit does, removes that reference, and dragonxd fails to link with undefined AsyncRPCOperation members from libbitcoin_wallet.a. List libbitcoin_server again after the wallet, spelled ./libbitcoin_server.a: libtool drops a repeated archive and keeps only its last copy, which would put the server after the wallet and break the other direction, and it compares the literal strings. LINK_GROUP_START/END cannot do it either: libtool moves both flags ahead of all the archives, so the group is empty (that is true of the existing mingw link group too). macOS's ld64 does not depend on archive order; a repeated archive is at most a warning there. test_bitcoin already lists the server twice but is not built (its include is commented out in Makefile.am); if it is revived it needs the same spelling. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/Makefile.am | 7 ++++++- src/Makefile.gtest.include | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 96b509435..ae96754a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -504,7 +504,12 @@ dragonxd_LDADD = $(LINK_GROUP_START) \ $(LIBRANDOMX) if ENABLE_WALLET -dragonxd_LDADD += $(LIBBITCOIN_WALLET) +# libbitcoin_server again after the wallet: the two archives use each other (the wallet's async +# operations derive from libbitcoin_server's AsyncRPCOperation), and GNU ld scans each archive once, +# in order. Spelled ./ on purpose: libtool drops a repeated archive, keeping only the last copy, which +# would put the server after the wallet and break the other direction. (LINK_GROUP_START/END cannot +# do it either: libtool moves both flags ahead of the archives.) +dragonxd_LDADD += $(LIBBITCOIN_WALLET) ./$(LIBBITCOIN_SERVER) endif dragonxd_LDADD += \ diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include index 14fbf92b4..7858124a6 100644 --- a/src/Makefile.gtest.include +++ b/src/Makefile.gtest.include @@ -47,7 +47,8 @@ hush_gtest_LDADD = -lgtest -lgmock \ $(LIBSECP256K1) \ $(LIBRANDOMX) if ENABLE_WALLET -hush_gtest_LDADD += $(LIBBITCOIN_WALLET) +# libbitcoin_server again after the wallet, spelled ./ so libtool keeps both copies (see dragonxd_LDADD). +hush_gtest_LDADD += $(LIBBITCOIN_WALLET) ./$(LIBBITCOIN_SERVER) endif hush_gtest_LDADD += \