Skip to content

Commit e3fa615

Browse files
committed
Integrate univalue into our buildsystem
Requires bitcoin-core/univalue-subtree#19 . This addresses issues like the one in bitcoin#12467, where some of our compiler flags end up being dropped during the subconfigure of Univalue. Specifically, we're still using the compiler-default c++ version rather than forcing c++17. We can drop the need subconfigure completely in favor of a tighter build integration, where the sources are listed separately from the build recipes, so that they may be included directly by upstream projects. This is similar to the way leveldb build integration works in Core. Core benefits of this approach include: - Better caching (for ex. ccache and autoconf) - No need for a slow subconfigure - Faster autoconf - No more missing compile flags - Compile only the objects needed There are no benefits to Univalue itself that I can think of. These changes should be a no-op there, and to downstreams as well until they take advantage of the new sources.mk. This also removes the option to use an external univalue to avoid similar ABI issues with mystery binaries.
1 parent a88fa1a commit e3fa615

File tree

4 files changed

+29
-52
lines changed

4 files changed

+29
-52
lines changed

configure.ac

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,6 @@ if test "x$use_asm" = xyes; then
262262
AC_DEFINE(USE_ASM, 1, [Define this symbol to build in assembly routines])
263263
fi
264264

265-
AC_ARG_WITH([system-univalue],
266-
[AS_HELP_STRING([--with-system-univalue],
267-
[Build with system UniValue (default is no)])],
268-
[system_univalue=$withval],
269-
[system_univalue=no]
270-
)
271265
AC_ARG_ENABLE([zmq],
272266
[AS_HELP_STRING([--disable-zmq],
273267
[disable ZMQ notifications])],
@@ -1500,34 +1494,6 @@ if test "x$use_zmq" = xyes; then
15001494
esac
15011495
fi
15021496

1503-
dnl univalue check
1504-
1505-
need_bundled_univalue=yes
1506-
if test x$build_bitcoin_wallet$build_bitcoin_cli$build_bitcoin_tx$build_bitcoin_util$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench = xnononononononono; then
1507-
need_bundled_univalue=no
1508-
else
1509-
if test x$system_univalue != xno; then
1510-
PKG_CHECK_MODULES([UNIVALUE], [libunivalue >= 1.0.4], [found_univalue=yes], [found_univalue=no])
1511-
if test x$found_univalue = xyes; then
1512-
system_univalue=yes
1513-
need_bundled_univalue=no
1514-
elif test x$system_univalue = xyes; then
1515-
AC_MSG_ERROR([univalue not found])
1516-
else
1517-
system_univalue=no
1518-
fi
1519-
fi
1520-
1521-
if test x$need_bundled_univalue = xyes; then
1522-
UNIVALUE_CFLAGS='-I$(srcdir)/univalue/include'
1523-
UNIVALUE_LIBS='univalue/libunivalue.la'
1524-
fi
1525-
fi
1526-
1527-
AM_CONDITIONAL([EMBEDDED_UNIVALUE],[test x$need_bundled_univalue = xyes])
1528-
AC_SUBST(UNIVALUE_CFLAGS)
1529-
AC_SUBST(UNIVALUE_LIBS)
1530-
15311497
dnl libmultiprocess library check
15321498

15331499
libmultiprocess_found=no
@@ -1889,10 +1855,6 @@ PKGCONFIG_LIBDIR_TEMP="$PKG_CONFIG_LIBDIR"
18891855
unset PKG_CONFIG_LIBDIR
18901856
PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP"
18911857

1892-
if test x$need_bundled_univalue = xyes; then
1893-
AC_CONFIG_SUBDIRS([src/univalue])
1894-
fi
1895-
18961858
ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-benchmark=no --enable-module-recovery --enable-module-schnorrsig --enable-experimental"
18971859
AC_CONFIG_SUBDIRS([src/secp256k1])
18981860

src/Makefile.am

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,7 @@ AM_LIBTOOLFLAGS = --preserve-dup-deps
1515
PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
1616
EXTRA_LIBRARIES =
1717

18-
if EMBEDDED_UNIVALUE
19-
LIBUNIVALUE = univalue/libunivalue.la
20-
21-
$(LIBUNIVALUE): $(wildcard univalue/lib/*) $(wildcard univalue/include/*)
22-
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
23-
else
24-
LIBUNIVALUE = $(UNIVALUE_LIBS)
25-
endif
26-
27-
BITCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/secp256k1/include $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS)
18+
BITCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/secp256k1/include -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS)
2819

2920
BITCOIN_INCLUDES += $(UNIVALUE_CFLAGS)
3021

@@ -80,6 +71,7 @@ EXTRA_LIBRARIES += \
8071
$(LIBBITCOIN_ZMQ)
8172

8273
lib_LTLIBRARIES = $(LIBBITCOINCONSENSUS)
74+
noinst_LTLIBRARIES =
8375

8476
bin_PROGRAMS =
8577
noinst_PROGRAMS =
@@ -801,7 +793,6 @@ $(top_srcdir)/$(subdir)/config/bitcoin-config.h.in: $(am__configure_deps)
801793

802794
clean-local:
803795
-$(MAKE) -C secp256k1 clean
804-
-$(MAKE) -C univalue clean
805796
-rm -f leveldb/*/*.gcda leveldb/*/*.gcno leveldb/helpers/memenv/*.gcda leveldb/helpers/memenv/*.gcno
806797
-rm -f config.h
807798
-rm -rf test/__pycache__
@@ -889,3 +880,5 @@ endif
889880
if ENABLE_QT_TESTS
890881
include Makefile.qttest.include
891882
endif
883+
884+
include Makefile.univalue.include

src/Makefile.test.include

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,25 @@ if ENABLE_BENCH
348348
endif
349349
endif
350350
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
351-
if EMBEDDED_UNIVALUE
352-
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
353-
endif
351+
352+
UNIVALUE_TESTS = univalue/test/object univalue/test/unitester univalue/test/no_nul
353+
noinst_PROGRAMS += $(UNIVALUE_TESTS)
354+
TESTS += $(UNIVALUE_TESTS)
355+
356+
univalue_test_unitester_SOURCES = $(UNIVALUE_TEST_UNITESTER_INT)
357+
univalue_test_unitester_LDADD = $(LIBUNIVALUE)
358+
univalue_test_unitester_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) -DJSON_TEST_SRC=\"$(srcdir)/$(UNIVALUE_TEST_DATA_DIR_INT)\"
359+
univalue_test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
360+
361+
univalue_test_no_nul_SOURCES = $(UNIVALUE_TEST_NO_NUL_INT)
362+
univalue_test_no_nul_LDADD = $(LIBUNIVALUE)
363+
univalue_test_no_nul_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)
364+
univalue_test_no_nul_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
365+
366+
univalue_test_object_SOURCES = $(UNIVALUE_TEST_OBJECT_INT)
367+
univalue_test_object_LDADD = $(LIBUNIVALUE)
368+
univalue_test_object_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)
369+
univalue_test_object_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
354370

355371
%.cpp.test: %.cpp
356372
@echo Running tests: `cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1` from $<

src/Makefile.univalue.include

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include univalue/sources.mk
2+
3+
LIBUNIVALUE = libunivalue.la
4+
noinst_LTLIBRARIES += $(LIBUNIVALUE)
5+
libunivalue_la_SOURCES = $(UNIVALUE_LIB_SOURCES_INT)
6+
libunivalue_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)

0 commit comments

Comments
 (0)