Merge bitcoin/bitcoin#27146: Fix various libbitcoinkernel DLL build problems

5da7c0b3e3 build: allow libitcoinkernel dll builds now that exports are fixed (Cory Fields)
130490aef9 build: always build bitcoin-chainstate against static libbitcoinkernel (Cory Fields)
545a74ef32 build: fix bitcoin-chainstate when libbitcoinkernel is static (Cory Fields)
9c253d2398 build: don't define DLL_EXPORT for windows (Cory Fields)

Pull request description:

  Fixes #25008.
  Fixes #19772.

  1. Fixup the build defines so that exports are clean.
  2. Work around a libtool issue wrt dependency calculation
  3. Simplify everything by only ever building in-tree bitcoin-chainstate against a static libbitcoinkernel
  4. Remove Windows-only hack that disabled dll creation

ACKs for top commit:
  TheCharlatan:
    ACK 5da7c0b3e3

Tree-SHA512: 61bab457e13842946387240da703d313509af30d4ca3371a19a26a5ef1716e4d7107b09567323041b549ab1fc97a064aa1d6992406936ab9c491a616bc7f4e7f
This commit is contained in:
fanquake 2023-02-27 14:31:17 +00:00
commit 82793f1984
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
2 changed files with 11 additions and 13 deletions

View file

@ -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

View file

@ -855,11 +855,12 @@ 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.
# libsecp256k1 only needs to be linked in when libbitcoinkernel is static.
bitcoin_chainstate_LDADD += $(LIBSECP256K1)
#
# bitcoinkernel library #
@ -878,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.