Skip to content

Commit 0f95247

Browse files
theunifanquake
andcommitted
Integrate univalue into our buildsystem
This addresses issues like the one in #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. Co-authored-by: fanquake <[email protected]>
1 parent 3043193 commit 0f95247

File tree

6 files changed

+32
-57
lines changed

6 files changed

+32
-57
lines changed

ci/test/06_script_b.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ export LC_ALL=C.UTF-8
99
if [[ $HOST = *-mingw32 ]]; then
1010
# Generate all binaries, so that they can be wrapped
1111
DOCKER_EXEC make $MAKEJOBS -C src/secp256k1 VERBOSE=1
12-
DOCKER_EXEC make $MAKEJOBS -C src/univalue VERBOSE=1
1312
DOCKER_EXEC "${BASE_ROOT_DIR}/ci/test/wrap-wine.sh"
1413
fi
1514

1615
if [ -n "$QEMU_USER_CMD" ]; then
1716
# Generate all binaries, so that they can be wrapped
1817
DOCKER_EXEC make $MAKEJOBS -C src/secp256k1 VERBOSE=1
19-
DOCKER_EXEC make $MAKEJOBS -C src/univalue VERBOSE=1
2018
DOCKER_EXEC "${BASE_ROOT_DIR}/ci/test/wrap-qemu.sh"
2119
fi
2220

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])],
@@ -1546,34 +1540,6 @@ if test "x$use_zmq" = xyes; then
15461540
esac
15471541
fi
15481542

1549-
dnl univalue check
1550-
1551-
need_bundled_univalue=yes
1552-
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
1553-
need_bundled_univalue=no
1554-
else
1555-
if test x$system_univalue != xno; then
1556-
PKG_CHECK_MODULES([UNIVALUE], [libunivalue >= 1.0.4], [found_univalue=yes], [found_univalue=no])
1557-
if test x$found_univalue = xyes; then
1558-
system_univalue=yes
1559-
need_bundled_univalue=no
1560-
elif test x$system_univalue = xyes; then
1561-
AC_MSG_ERROR([univalue not found])
1562-
else
1563-
system_univalue=no
1564-
fi
1565-
fi
1566-
1567-
if test x$need_bundled_univalue = xyes; then
1568-
UNIVALUE_CFLAGS='-I$(srcdir)/univalue/include'
1569-
UNIVALUE_LIBS='univalue/libunivalue.la'
1570-
fi
1571-
fi
1572-
1573-
AM_CONDITIONAL([EMBEDDED_UNIVALUE],[test x$need_bundled_univalue = xyes])
1574-
AC_SUBST(UNIVALUE_CFLAGS)
1575-
AC_SUBST(UNIVALUE_LIBS)
1576-
15771543
dnl libmultiprocess library check
15781544

15791545
libmultiprocess_found=no
@@ -1936,10 +1902,6 @@ PKGCONFIG_LIBDIR_TEMP="$PKG_CONFIG_LIBDIR"
19361902
unset PKG_CONFIG_LIBDIR
19371903
PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP"
19381904

1939-
if test x$need_bundled_univalue = xyes; then
1940-
AC_CONFIG_SUBDIRS([src/univalue])
1941-
fi
1942-
19431905
ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-benchmark=no --enable-module-recovery --enable-module-schnorrsig --enable-experimental"
19441906
AC_CONFIG_SUBDIRS([src/secp256k1])
19451907

contrib/guix/libexec/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ mkdir -p "$DISTSRC"
297297
${HOST_CXXFLAGS:+CXXFLAGS="${HOST_CXXFLAGS}"} \
298298
${HOST_LDFLAGS:+LDFLAGS="${HOST_LDFLAGS}"}
299299

300-
sed -i.old 's/-lstdc++ //g' config.status libtool src/univalue/config.status src/univalue/libtool
300+
sed -i.old 's/-lstdc++ //g' config.status libtool
301301

302302
# Build Bitcoin Core
303303
make --jobs="$JOBS" ${V:+V=1}

src/Makefile.am

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
print-%: FORCE
77
@echo '$*'='$($*)'
88

9-
DIST_SUBDIRS = secp256k1 univalue
9+
DIST_SUBDIRS = secp256k1
1010

1111
AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS)
1212
AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS)
@@ -15,18 +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)
28-
29-
BITCOIN_INCLUDES += $(UNIVALUE_CFLAGS)
18+
BITCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/secp256k1/include -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS)
3019

3120
LIBBITCOIN_SERVER=libbitcoin_server.a
3221
LIBBITCOIN_COMMON=libbitcoin_common.a
@@ -80,6 +69,7 @@ EXTRA_LIBRARIES += \
8069
$(LIBBITCOIN_ZMQ)
8170

8271
lib_LTLIBRARIES = $(LIBBITCOINCONSENSUS)
72+
noinst_LTLIBRARIES =
8373

8474
bin_PROGRAMS =
8575
noinst_PROGRAMS =
@@ -797,7 +787,6 @@ $(top_srcdir)/$(subdir)/config/bitcoin-config.h.in: $(am__configure_deps)
797787

798788
clean-local:
799789
-$(MAKE) -C secp256k1 clean
800-
-$(MAKE) -C univalue clean
801790
-rm -f leveldb/*/*.gcda leveldb/*/*.gcno leveldb/helpers/memenv/*.gcda leveldb/helpers/memenv/*.gcno
802791
-rm -f config.h
803792
-rm -rf test/__pycache__
@@ -887,3 +876,5 @@ endif
887876
if ENABLE_QT_TESTS
888877
include Makefile.qttest.include
889878
endif
879+
880+
include Makefile.univalue.include

src/Makefile.test.include

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,26 @@ if ENABLE_BENCH
350350
endif
351351
endif
352352
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
353-
if EMBEDDED_UNIVALUE
354-
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
353+
354+
if !ENABLE_FUZZ
355+
UNIVALUE_TESTS = univalue/test/object univalue/test/unitester univalue/test/no_nul
356+
noinst_PROGRAMS += $(UNIVALUE_TESTS)
357+
TESTS += $(UNIVALUE_TESTS)
358+
359+
univalue_test_unitester_SOURCES = $(UNIVALUE_TEST_UNITESTER_INT)
360+
univalue_test_unitester_LDADD = $(LIBUNIVALUE)
361+
univalue_test_unitester_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) -DJSON_TEST_SRC=\"$(srcdir)/$(UNIVALUE_TEST_DATA_DIR_INT)\"
362+
univalue_test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
363+
364+
univalue_test_no_nul_SOURCES = $(UNIVALUE_TEST_NO_NUL_INT)
365+
univalue_test_no_nul_LDADD = $(LIBUNIVALUE)
366+
univalue_test_no_nul_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)
367+
univalue_test_no_nul_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
368+
369+
univalue_test_object_SOURCES = $(UNIVALUE_TEST_OBJECT_INT)
370+
univalue_test_object_LDADD = $(LIBUNIVALUE)
371+
univalue_test_object_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)
372+
univalue_test_object_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
355373
endif
356374

357375
%.cpp.test: %.cpp

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) $(UNIVALUE_DIST_HEADERS_INT) $(UNIVALUE_LIB_HEADERS_INT) $(UNIVALUE_TEST_FILES_INT)
6+
libunivalue_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)

0 commit comments

Comments
 (0)