It looks like the linker error is simply due to the linking order. Everywhere else we have LIBBITCOIN_WALLET
, it is always before LIBBITCOIN_COMMON
. But if you go up to where FUZZ_SUITE_LD_COMMON
is first set, you see that we will end up having LIBBITCOIN_COMMON
set before LIBBITCOIN_WALLET
which means that the linker will have problems linking things common things that the wallet uses. Because the order is correct for the other targets, we only see a linker error for test/fuzz/fuzz
.
I would consider the following diff to be more correct than currently implemented:
0diff --git a/src/Makefile.test.include b/src/Makefile.test.include
1index 157d8ee2e1..fc2fd80166 100644
2--- a/src/Makefile.test.include
3+++ b/src/Makefile.test.include
4@@ -35,11 +35,12 @@ BITCOIN_TEST_SUITE = \
5 $(TEST_UTIL_H)
6
7 FUZZ_SUITE_LD_COMMON = \
8+ $(LIBTEST_UTIL) \
9+ $(LIBTEST_FUZZ) \
10 $(LIBBITCOIN_SERVER) \
11+ $(LIBBITCOIN_WALLET) \
12 $(LIBBITCOIN_COMMON) \
13 $(LIBBITCOIN_UTIL) \
14- $(LIBTEST_UTIL) \
15- $(LIBTEST_FUZZ) \
16 $(LIBBITCOIN_CONSENSUS) \
17 $(LIBBITCOIN_CRYPTO) \
18 $(LIBBITCOIN_CLI) \
19@@ -159,12 +160,7 @@ BITCOIN_TESTS += \
20 wallet/test/ismine_tests.cpp \
21 wallet/test/scriptpubkeyman_tests.cpp
22
23-# This adds libbitcoin again to fix linking external_signer_scriptpubkeyman.cpp
24-# when configured with --disable-external-signer. It is unclear why this is
25-# needed and may indicate a bug elsewhere.
26 FUZZ_SUITE_LD_COMMON +=\
27- $(LIBBITCOIN_WALLET) \
28- $(LIBBITCOIN_COMMON) \
29 $(SQLITE_LIBS) \
30 $(BDB_LIBS)
31
In this diff, LIBTEST_UTIL
and LIBTEST_FUZZ
are moved to the top because they include LIBBITCOIN_SERVER
and LIBBITCOIN_COMMON
. LIBBITCOIN_SERVER
always needs to be the first item in the linker order since it has the most dependencies.
I think, in general, the makefiles for making the fuzz and test binaries should be revisited so that the linking order is made consistent with the rest of the code and to avoid other linker order issues that may crop up in the future.
Also 5c06af49efba407f062fdbf124b6d571fedd73fa does not build because of the linker error. This commit that fixes the linker order should go first so that all commits build.