From 9c253d2398005d852cab77c4456bc1f44831a16b Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 26 Apr 2022 16:36:33 +0000 Subject: [PATCH 1/4] build: don't define DLL_EXPORT for windows This fixes libbitcoinkernel dll linking. --- configure.ac | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure.ac b/configure.ac index 72503f2b1ce..5f09c8a5b62 100644 --- a/configure.ac +++ b/configure.ac @@ -76,6 +76,12 @@ dnl we have those under control, re-enable that functionality. case $host in *mingw*) lt_cv_deplibs_check_method="pass_all" + + dnl Remove unwanted -DDLL_EXPORT from these variables. + dnl We do not use this macro, but system headers may export unwanted symbols + dnl if it's set. + lt_cv_prog_compiler_pic="-DPIC" + lt_cv_prog_compiler_pic_CXX="-DPIC" ;; esac From 545a74ef320d0abb1e45f88ed857ccee951e81c3 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Wed, 22 Feb 2023 20:31:55 +0000 Subject: [PATCH 2/4] build: fix bitcoin-chainstate when libbitcoinkernel is static Libtool is unable to calculate dependencies correctly so give it some help. --- src/Makefile.am | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Makefile.am b/src/Makefile.am index 7b9ffe427dc..d64e2fe3bbf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -860,6 +860,10 @@ bitcoin_chainstate_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) # setting --{en,dis}able-shared. bitcoin_chainstate_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(PTHREAD_FLAGS) bitcoin_chainstate_LDADD = $(LIBBITCOINKERNEL) + +# libtool is unable to calculate this indirect dependency, presumably because it's a subproject. +# libsecp256k1 only needs to be linked in when libbitcoinkernel is static. +bitcoin_chainstate_LDADD += $(LIBSECP256K1) # # bitcoinkernel library # From 130490aef95e4b352a47dfbd55df855db56760c7 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 21 Feb 2023 21:41:01 +0000 Subject: [PATCH 3/4] build: always build bitcoin-chainstate against static libbitcoinkernel Building binaries against our uninstalled shared libs is impractical. Instead, to test them, we'll need to work on a runtime shared-lib execution harness. --- src/Makefile.am | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index d64e2fe3bbf..3e340a5b992 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -855,10 +855,7 @@ bitcoin_chainstate_SOURCES = bitcoin-chainstate.cpp bitcoin_chainstate_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS) bitcoin_chainstate_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -# $(LIBTOOL_APP_LDFLAGS) deliberately omitted here so that we can test linking -# bitcoin-chainstate against libbitcoinkernel as a shared or static library by -# setting --{en,dis}able-shared. -bitcoin_chainstate_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(PTHREAD_FLAGS) +bitcoin_chainstate_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(PTHREAD_FLAGS) $(LIBTOOL_APP_LDFLAGS) -static bitcoin_chainstate_LDADD = $(LIBBITCOINKERNEL) # libtool is unable to calculate this indirect dependency, presumably because it's a subproject. From 5da7c0b3e34626ca57d1f0773db61e7d8351d8c7 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 21 Feb 2023 21:28:53 +0000 Subject: [PATCH 4/4] build: allow libitcoinkernel dll builds now that exports are fixed Symbol visibility issues are not actually fixed yet because we have not yet defined an api and exported symbols, but everything is now in place for that. --- src/Makefile.am | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 3e340a5b992..72e7db53348 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -879,15 +879,6 @@ libbitcoinkernel_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp # to export from the library. libbitcoinkernel_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -fvisibility=default -# TODO: For now, Specify -static in both CXXFLAGS and LDFLAGS when building for -# windows targets so libtool will only build a static version of this -# library. There are unresolved problems when building dll's for mingw-w64 -# and attempting to statically embed libstdc++, libpthread, etc. -if TARGET_WINDOWS -libbitcoinkernel_la_LDFLAGS += -static -libbitcoinkernel_la_CXXFLAGS += -static -endif - # TODO: libbitcoinkernel is a work in progress consensus engine library, as more # and more modules are decoupled from the consensus engine, this list will # shrink to only those which are absolutely necessary.