From 88f12bba8a27232c8f7a808bd2e17b51ccd95806 Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Tue, 22 Mar 2022 23:36:52 +0100 Subject: [PATCH 1/4] fs: make wallet/load path compatible with boost 1.78+ Imports the fix for Bitcoin Core for boost 1.78, minus all the extras, as this is a one-liner. Backport conflict pressure will remain one line too. Taken from: dc5d6b0d @ bitcoin/bitcoin Original author: Andrew Chow --- src/wallet/load.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp index 036fd4956f2..f6b1a7100c5 100644 --- a/src/wallet/load.cpp +++ b/src/wallet/load.cpp @@ -22,7 +22,7 @@ bool VerifyWallets(interfaces::Chain& chain) fs::path wallet_dir = gArgs.GetArg("-walletdir", ""); boost::system::error_code error; // The canonical path cleans the path, preventing >1 Berkeley environment instances for the same directory - fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error); + fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error).remove_trailing_separator(); if (error || !fs::exists(wallet_dir)) { chain.initError(strprintf(_("Specified -walletdir \"%s\" does not exist"), wallet_dir.string())); return false; From 517dc4876abd2967570a1afb0d68544b186e17bc Mon Sep 17 00:00:00 2001 From: Bertrand Jacquin Date: Sat, 21 Aug 2021 23:45:41 +0100 Subject: [PATCH 2/4] Update to Berkeley DB 5.3 Old BerkeleyDB version such as 5.1 are being removed from most Linux distribution. See: https://bugs.gentoo.org/792222 See: https://fedoraproject.org/wiki/Changes/Libdb_deprecated --- ...n_find_bdb48.m4 => dogecoin_find_bdb53.m4} | 31 ++++---- ci/test/00_setup_env_i686_centos.sh | 2 +- ci/test/00_setup_env_native_msan.sh | 4 +- ci/test/05_before_script.sh | 4 +- configure.ac | 10 +-- contrib/{install_db4.sh => install_db5.sh} | 35 ++------- depends/packages/bdb.mk | 11 +-- depends/patches/bdb/clang_cxx_11.patch | 76 +++++++++---------- depends/patches/bdb/winioctl.patch | 13 ++++ doc/build-freebsd.md | 4 +- doc/build-netbsd.md | 6 +- doc/build-openbsd.md | 6 +- doc/build-osx.md | 8 +- doc/build-unix.md | 30 ++++---- 14 files changed, 117 insertions(+), 123 deletions(-) rename build-aux/m4/{bitcoin_find_bdb48.m4 => dogecoin_find_bdb53.m4} (73%) rename contrib/{install_db4.sh => install_db5.sh} (55%) create mode 100644 depends/patches/bdb/winioctl.patch diff --git a/build-aux/m4/bitcoin_find_bdb48.m4 b/build-aux/m4/dogecoin_find_bdb53.m4 similarity index 73% rename from build-aux/m4/bitcoin_find_bdb48.m4 rename to build-aux/m4/dogecoin_find_bdb53.m4 index aa0111e5a20..258cad01687 100644 --- a/build-aux/m4/bitcoin_find_bdb48.m4 +++ b/build-aux/m4/dogecoin_find_bdb53.m4 @@ -1,8 +1,9 @@ dnl Copyright (c) 2013-2015 The Bitcoin Core developers +dnl Copyright (c) 2018-2021 The Dogecoin Core developers dnl Distributed under the MIT software license, see the accompanying dnl file COPYING or http://www.opensource.org/licenses/mit-license.php. -AC_DEFUN([BITCOIN_FIND_BDB48],[ +AC_DEFUN([BITCOIN_FIND_BDB53],[ AC_ARG_VAR(BDB_CFLAGS, [C compiler flags for BerkeleyDB, bypasses autodetection]) AC_ARG_VAR(BDB_LIBS, [Linker flags for BerkeleyDB, bypasses autodetection]) @@ -10,9 +11,9 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[ AC_MSG_CHECKING([for Berkeley DB C++ headers]) BDB_CPPFLAGS= bdbpath=X - bdb48path=X + bdb53path=X bdbdirlist= - for _vn in 4.8 48 4 5 5.3 ''; do + for _vn in 5.3 53 5 4.8 48 4 ''; do for _pfx in b lib ''; do bdbdirlist="$bdbdirlist ${_pfx}db${_vn}" done @@ -22,8 +23,8 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <${searchpath}db_cxx.h> ]],[[ - #if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4) - #error "failed to find bdb 4.8+" + #if !((DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR >= 3) || DB_VERSION_MAJOR > 5) + #error "failed to find bdb 5.3+" #endif ]])],[ if test "x$bdbpath" = "xX"; then @@ -35,27 +36,27 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <${searchpath}db_cxx.h> ]],[[ - #if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8) - #error "failed to find bdb 4.8" + #if !(DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR == 3) + #error "failed to find bdb 5.3" #endif ]])],[ - bdb48path="${searchpath}" + bdb53path="${searchpath}" break ],[]) done if test "x$bdbpath" = "xX"; then AC_MSG_RESULT([no]) AC_MSG_ERROR([libdb_cxx headers missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)]) - elif test "x$bdb48path" = "xX"; then + elif test "x$bdb53path" = "xX"; then BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx) - AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[ - AC_MSG_WARN([Found Berkeley DB other than 4.8; wallets opened by this build will not be portable!]) + AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 5.3])],[ + AC_MSG_WARN([Found Berkeley DB other than 5.3; wallets opened by this build will not be portable!]) ],[ - AC_MSG_ERROR([Found Berkeley DB other than 4.8, required for portable wallets (--with-incompatible-bdb to ignore or --disable-wallet to disable wallet functionality)]) + AC_MSG_ERROR([Found Berkeley DB other than 5.3, required for portable wallets (--with-incompatible-bdb to ignore or --disable-wallet to disable wallet functionality)]) ]) else - BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx) - bdbpath="${bdb48path}" + BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb53path}],db_cxx) + bdbpath="${bdb53path}" fi else BDB_CPPFLAGS=${BDB_CFLAGS} @@ -64,7 +65,7 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[ if test "x$BDB_LIBS" = "x"; then # TODO: Ideally this could find the library version and make sure it matches the headers being used - for searchlib in db_cxx-4.8 db_cxx db4_cxx; do + for searchlib in db_cxx-5.3 db_cxx db5_cxx; do AC_CHECK_LIB([$searchlib],[main],[ BDB_LIBS="-l${searchlib}" break diff --git a/ci/test/00_setup_env_i686_centos.sh b/ci/test/00_setup_env_i686_centos.sh index 99f63825a2b..ef4ebb128b3 100644 --- a/ci/test/00_setup_env_i686_centos.sh +++ b/ci/test/00_setup_env_i686_centos.sh @@ -11,5 +11,5 @@ export CONTAINER_NAME=ci_i686_centos_7 export DOCKER_NAME_TAG=centos:7 export DOCKER_PACKAGES="gcc-c++ glibc-devel.x86_64 libstdc++-devel.x86_64 glibc-devel.i686 libstdc++-devel.i686 ccache libtool make git python3 python36-devel python36-zmq which patch lbzip2 dash" export GOAL="install" -export BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-reduce-exports --with-boost-process" +export BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-reduce-exports --with-incompatible-bdb --with-boost-process" export CONFIG_SHELL="/bin/dash" diff --git a/ci/test/00_setup_env_native_msan.sh b/ci/test/00_setup_env_native_msan.sh index b88ee2b50fb..f1467837653 100644 --- a/ci/test/00_setup_env_native_msan.sh +++ b/ci/test/00_setup_env_native_msan.sh @@ -11,13 +11,13 @@ LIBCXX_DIR="${BASE_ROOT_DIR}/ci/scratch/msan/build/" export MSAN_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g -O1 -fno-optimize-sibling-calls" LIBCXX_FLAGS="-nostdinc++ -stdlib=libc++ -L${LIBCXX_DIR}lib -lc++abi -I${LIBCXX_DIR}include -I${LIBCXX_DIR}include/c++/v1 -lpthread -Wl,-rpath,${LIBCXX_DIR}lib -Wno-unused-command-line-argument" export MSAN_AND_LIBCXX_FLAGS="${MSAN_FLAGS} ${LIBCXX_FLAGS}" -export BDB_PREFIX="${BASE_ROOT_DIR}/db4" +export BDB_PREFIX="${BASE_ROOT_DIR}/db5" export CONTAINER_NAME="ci_native_msan" export PACKAGES="clang-9 llvm-9 cmake" export DEP_OPTS="NO_BDB=1 NO_QT=1 CC='clang' CXX='clang++' CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}' boost_cxxflags='-std=c++11 -fvisibility=hidden -fPIC ${MSAN_AND_LIBCXX_FLAGS}' zeromq_cxxflags='-std=c++11 ${MSAN_AND_LIBCXX_FLAGS}'" export GOAL="install" -export BITCOIN_CONFIG="--enable-wallet --with-sanitizers=memory --with-asm=no --prefix=${BASE_ROOT_DIR}/depends/x86_64-pc-linux-gnu/ CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}' BDB_LIBS='-L${BDB_PREFIX}/lib -ldb_cxx-4.8' BDB_CFLAGS='-I${BDB_PREFIX}/include'" +export BITCOIN_CONFIG="--enable-wallet --with-sanitizers=memory --with-asm=no --prefix=${BASE_ROOT_DIR}/depends/x86_64-pc-linux-gnu/ CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}' BDB_LIBS='-L${BDB_PREFIX}/lib -ldb_cxx-5.3' BDB_CFLAGS='-I${BDB_PREFIX}/include'" export USE_MEMORY_SANITIZER="true" export RUN_FUNCTIONAL_TESTS="false" export CCACHE_SIZE=250M diff --git a/ci/test/05_before_script.sh b/ci/test/05_before_script.sh index 9f1a4bbcf53..5d0034be129 100755 --- a/ci/test/05_before_script.sh +++ b/ci/test/05_before_script.sh @@ -25,10 +25,10 @@ if [ -n "$XCODE_VERSION" ] && [ ! -f "$OSX_SDK_PATH" ]; then fi if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then - # Use BDB compiled using install_db4.sh script to work around linking issue when using BDB + # Use BDB compiled using install_db5.sh script to work around linking issue when using BDB # from depends. See https://github.com/bitcoin/bitcoin/pull/18288#discussion_r433189350 for # details. - DOCKER_EXEC "contrib/install_db4.sh \$(pwd) --enable-umrw CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'" + DOCKER_EXEC "contrib/install_db5.sh \$(pwd) --enable-umrw CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'" fi if [ -n "$XCODE_VERSION" ] && [ -f "$OSX_SDK_PATH" ]; then diff --git a/configure.ac b/configure.ac index 5751256a217..632046d2da4 100644 --- a/configure.ac +++ b/configure.ac @@ -652,11 +652,11 @@ case $host in dnl It's safe to add these paths even if the functionality is disabled by dnl the user (--without-wallet or --without-gui for example). - if test "x$use_bdb" != xno && $BREW list --versions berkeley-db4 >/dev/null && test "x$BDB_CFLAGS" = "x" && test "x$BDB_LIBS" = "x"; then - bdb_prefix=$($BREW --prefix berkeley-db4 2>/dev/null) - dnl This must precede the call to BITCOIN_FIND_BDB48 below. + if test "x$use_bdb" != xno && $BREW list --versions berkeley-db5 >/dev/null && test "x$BDB_CFLAGS" = "x" && test "x$BDB_LIBS" = "x"; then + bdb_prefix=$($BREW --prefix berkeley-db5 2>/dev/null) + dnl This must precede the call to BITCOIN_FIND_BDB53 below. BDB_CFLAGS="-I$bdb_prefix/include" - BDB_LIBS="-L$bdb_prefix/lib -ldb_cxx-4.8" + BDB_LIBS="-L$bdb_prefix/lib -ldb_cxx-5.3" fi if test "x$use_sqlite" != xno && $BREW list --versions sqlite3 >/dev/null; then @@ -1233,7 +1233,7 @@ fi if test x$enable_wallet != xno; then dnl Check for libdb_cxx only if wallet enabled - BITCOIN_FIND_BDB48 + BITCOIN_FIND_BDB53 if test x$suppress_external_warnings != xno ; then BDB_CPPFLAGS=SUPPRESS_WARNINGS($BDB_CPPFLAGS) fi diff --git a/contrib/install_db4.sh b/contrib/install_db5.sh similarity index 55% rename from contrib/install_db4.sh rename to contrib/install_db5.sh index e9130a21ded..0d05340f2df 100755 --- a/contrib/install_db4.sh +++ b/contrib/install_db5.sh @@ -1,9 +1,10 @@ #!/bin/sh # Copyright (c) 2017-2019 The Bitcoin Core developers +# Copyright (c) 2021 The Dogecoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -# Install libdb4.8 (Berkeley DB). +# Install libdb5.3 (Berkeley DB). export LC_ALL=C set -e @@ -11,7 +12,7 @@ set -e if [ -z "${1}" ]; then echo "Usage: $0 [ ...]" echo - echo "Must specify a single argument: the directory in which db4 will be built." + echo "Must specify a single argument: the directory in which db5 will be built." echo "This is probably \`pwd\` if you're at the root of the bitcoin repository." exit 1 fi @@ -20,9 +21,9 @@ expand_path() { cd "${1}" && pwd -P } -BDB_PREFIX="$(expand_path ${1})/db4"; shift; -BDB_VERSION='db-4.8.30.NC' -BDB_HASH='12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef' +BDB_PREFIX="$(expand_path ${1})/db5"; shift; +BDB_VERSION='db-5.3.28.NC' +BDB_HASH='76a25560d9e52a198d37a31440fd07632b5f1f8f9f2b6d5438f4bc3e7c9013ef' BDB_URL="https://download.oracle.com/berkeley-db/${BDB_VERSION}.tar.gz" check_exists() { @@ -67,26 +68,6 @@ http_get "${BDB_URL}" "${BDB_VERSION}.tar.gz" "${BDB_HASH}" tar -xzvf ${BDB_VERSION}.tar.gz -C "$BDB_PREFIX" cd "${BDB_PREFIX}/${BDB_VERSION}/" -# Apply a patch necessary when building with clang and c++11 (see https://community.oracle.com/thread/3952592) -CLANG_CXX11_PATCH_URL='https://gist.githubusercontent.com/LnL7/5153b251fd525fe15de69b67e63a6075/raw/7778e9364679093a32dec2908656738e16b6bdcb/clang.patch' -CLANG_CXX11_PATCH_HASH='7a9a47b03fd5fb93a16ef42235fa9512db9b0829cfc3bdf90edd3ec1f44d637c' -http_get "${CLANG_CXX11_PATCH_URL}" clang.patch "${CLANG_CXX11_PATCH_HASH}" -patch -p2 < clang.patch - -# The packaged config.guess and config.sub are ancient (2009) and can cause build issues. -# Replace them with modern versions. -# See https://github.com/bitcoin/bitcoin/issues/16064 -CONFIG_GUESS_URL='https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=55eaf3e779455c4e5cc9f82efb5278be8f8f900b' -CONFIG_GUESS_HASH='2d1ff7bca773d2ec3c6217118129220fa72d8adda67c7d2bf79994b3129232c1' -CONFIG_SUB_URL='https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=55eaf3e779455c4e5cc9f82efb5278be8f8f900b' -CONFIG_SUB_HASH='3a4befde9bcdf0fdb2763fc1bfa74e8696df94e1ad7aac8042d133c8ff1d2e32' - -rm -f "dist/config.guess" -rm -f "dist/config.sub" - -http_get "${CONFIG_GUESS_URL}" dist/config.guess "${CONFIG_GUESS_HASH}" -http_get "${CONFIG_SUB_URL}" dist/config.sub "${CONFIG_SUB_HASH}" - cd build_unix/ "${BDB_PREFIX}/${BDB_VERSION}/dist/configure" \ @@ -96,11 +77,11 @@ cd build_unix/ make install echo -echo "db4 build complete." +echo "db5 build complete." echo # shellcheck disable=SC2016 echo 'When compiling bitcoind, run `./configure` in the following way:' echo echo " export BDB_PREFIX='${BDB_PREFIX}'" # shellcheck disable=SC2016 -echo ' ./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" ...' +echo ' ./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-5.3" BDB_CFLAGS="-I${BDB_PREFIX}/include" ...' diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk index 5953341d9f7..568fe6f1785 100644 --- a/depends/packages/bdb.mk +++ b/depends/packages/bdb.mk @@ -1,10 +1,10 @@ package=bdb -$(package)_version=4.8.30 -$(package)_download_path=https://download.oracle.com/berkeley-db +$(package)_version=5.3.28 +$(package)_download_path=http://download.oracle.com/berkeley-db $(package)_file_name=db-$($(package)_version).NC.tar.gz -$(package)_sha256_hash=12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef +$(package)_sha256_hash=76a25560d9e52a198d37a31440fd07632b5f1f8f9f2b6d5438f4bc3e7c9013ef $(package)_build_subdir=build_unix -$(package)_patches=clang_cxx_11.patch +$(package)_patches=clang_cxx_11.patch winioctl.patch define $(package)_set_vars $(package)_config_opts=--disable-shared --enable-cxx --disable-replication --enable-option-checking @@ -17,6 +17,7 @@ endef define $(package)_preprocess_cmds patch -p1 < $($(package)_patch_dir)/clang_cxx_11.patch && \ + patch -p1 < $($(package)_patch_dir)/winioctl.patch && \ cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub dist endef @@ -25,7 +26,7 @@ define $(package)_config_cmds endef define $(package)_build_cmds - $(MAKE) libdb_cxx-4.8.a libdb-4.8.a + $(MAKE) libdb_cxx-5.3.a libdb-5.3.a endef define $(package)_stage_cmds diff --git a/depends/patches/bdb/clang_cxx_11.patch b/depends/patches/bdb/clang_cxx_11.patch index 58f7ddc7d50..635b9dc076a 100644 --- a/depends/patches/bdb/clang_cxx_11.patch +++ b/depends/patches/bdb/clang_cxx_11.patch @@ -1,13 +1,7 @@ -commit 3311d68f11d1697565401eee6efc85c34f022ea7 -Author: fanquake -Date: Mon Aug 17 20:03:56 2020 +0800 - - Fix C++11 compatibility - -diff --git a/dbinc/atomic.h b/dbinc/atomic.h -index 0034dcc..7c11d4a 100644 ---- a/dbinc/atomic.h -+++ b/dbinc/atomic.h +diff --git a/src/dbinc/atomic.h b/src/dbinc/atomic.h +index 6a858f7..9f338dc 100644 +--- a/src/dbinc/atomic.h ++++ b/src/dbinc/atomic.h @@ -70,7 +70,7 @@ typedef struct { * These have no memory barriers; the caller must include them when necessary. */ @@ -44,11 +38,11 @@ index 0034dcc..7c11d4a 100644 #else #define atomic_inc(env, p) __atomic_inc(env, p) #define atomic_dec(env, p) __atomic_dec(env, p) -diff --git a/mp/mp_fget.c b/mp/mp_fget.c -index 5fdee5a..0b75f57 100644 ---- a/mp/mp_fget.c -+++ b/mp/mp_fget.c -@@ -617,7 +617,7 @@ alloc: /* Allocate a new buffer header and data space. */ +diff --git a/src/mp/mp_fget.c b/src/mp/mp_fget.c +index 16de695..d0dcc29 100644 +--- a/src/mp/mp_fget.c ++++ b/src/mp/mp_fget.c +@@ -649,7 +649,7 @@ alloc: /* Allocate a new buffer header and data space. */ /* Initialize enough so we can call __memp_bhfree. */ alloc_bhp->flags = 0; @@ -56,9 +50,9 @@ index 5fdee5a..0b75f57 100644 + atomic_init_db(&alloc_bhp->ref, 1); #ifdef DIAGNOSTIC if ((uintptr_t)alloc_bhp->buf & (sizeof(size_t) - 1)) { - __db_errx(env, -@@ -911,7 +911,7 @@ alloc: /* Allocate a new buffer header and data space. */ - MVCC_MPROTECT(bhp->buf, mfp->stat.st_pagesize, + __db_errx(env, DB_STR("3025", +@@ -955,7 +955,7 @@ alloc: /* Allocate a new buffer header and data space. */ + MVCC_MPROTECT(bhp->buf, mfp->pagesize, PROT_READ); - atomic_init(&alloc_bhp->ref, 1); @@ -66,10 +60,10 @@ index 5fdee5a..0b75f57 100644 MUTEX_LOCK(env, alloc_bhp->mtx_buf); alloc_bhp->priority = bhp->priority; alloc_bhp->pgno = bhp->pgno; -diff --git a/mp/mp_mvcc.c b/mp/mp_mvcc.c -index 34467d2..f05aa0c 100644 ---- a/mp/mp_mvcc.c -+++ b/mp/mp_mvcc.c +diff --git a/src/mp/mp_mvcc.c b/src/mp/mp_mvcc.c +index 770bad8..e28cce0 100644 +--- a/src/mp/mp_mvcc.c ++++ b/src/mp/mp_mvcc.c @@ -276,7 +276,7 @@ __memp_bh_freeze(dbmp, infop, hp, bhp, need_frozenp) #else memcpy(frozen_bhp, bhp, SSZA(BH, buf)); @@ -88,11 +82,11 @@ index 34467d2..f05aa0c 100644 F_CLR(alloc_bhp, BH_FROZEN); } -diff --git a/mp/mp_region.c b/mp/mp_region.c -index e6cece9..ddbe906 100644 ---- a/mp/mp_region.c -+++ b/mp/mp_region.c -@@ -224,7 +224,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg) +diff --git a/src/mp/mp_region.c b/src/mp/mp_region.c +index 4952030..47645f8 100644 +--- a/src/mp/mp_region.c ++++ b/src/mp/mp_region.c +@@ -245,7 +245,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg) MTX_MPOOL_FILE_BUCKET, 0, &htab[i].mtx_hash)) != 0) return (ret); SH_TAILQ_INIT(&htab[i].hash_bucket); @@ -101,20 +95,20 @@ index e6cece9..ddbe906 100644 } /* -@@ -269,7 +269,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg) - hp->mtx_hash = (mtx_base == MUTEX_INVALID) ? MUTEX_INVALID : - mtx_base + i; +@@ -302,7 +302,7 @@ no_prealloc: + } else + hp->mtx_hash = mtx_base + (i % dbenv->mp_mtxcount); SH_TAILQ_INIT(&hp->hash_bucket); - atomic_init(&hp->hash_page_dirty, 0); + atomic_init_db(&hp->hash_page_dirty, 0); #ifdef HAVE_STATISTICS hp->hash_io_wait = 0; hp->hash_frozen = hp->hash_thawed = hp->hash_frozen_freed = 0; -diff --git a/mutex/mut_method.c b/mutex/mut_method.c -index 2588763..5c6d516 100644 ---- a/mutex/mut_method.c -+++ b/mutex/mut_method.c -@@ -426,7 +426,7 @@ atomic_compare_exchange(env, v, oldval, newval) +diff --git a/src/mutex/mut_method.c b/src/mutex/mut_method.c +index 09353b0..177353c 100644 +--- a/src/mutex/mut_method.c ++++ b/src/mutex/mut_method.c +@@ -474,7 +474,7 @@ atomic_compare_exchange(env, v, oldval, newval) MUTEX_LOCK(env, mtx); ret = atomic_read(v) == oldval; if (ret) @@ -123,11 +117,11 @@ index 2588763..5c6d516 100644 MUTEX_UNLOCK(env, mtx); return (ret); -diff --git a/mutex/mut_tas.c b/mutex/mut_tas.c -index f3922e0..e40fcdf 100644 ---- a/mutex/mut_tas.c -+++ b/mutex/mut_tas.c -@@ -46,7 +46,7 @@ __db_tas_mutex_init(env, mutex, flags) +diff --git a/src/mutex/mut_tas.c b/src/mutex/mut_tas.c +index 106b161..fc4de9d 100644 +--- a/src/mutex/mut_tas.c ++++ b/src/mutex/mut_tas.c +@@ -47,7 +47,7 @@ __db_tas_mutex_init(env, mutex, flags) #ifdef HAVE_SHARED_LATCHES if (F_ISSET(mutexp, DB_MUTEX_SHARED)) @@ -136,7 +130,7 @@ index f3922e0..e40fcdf 100644 else #endif if (MUTEX_INIT(&mutexp->tas)) { -@@ -486,7 +486,7 @@ __db_tas_mutex_unlock(env, mutex) +@@ -536,7 +536,7 @@ __db_tas_mutex_unlock(env, mutex) F_CLR(mutexp, DB_MUTEX_LOCKED); /* Flush flag update before zeroing count */ MEMBAR_EXIT(); diff --git a/depends/patches/bdb/winioctl.patch b/depends/patches/bdb/winioctl.patch new file mode 100644 index 00000000000..1fdd036161f --- /dev/null +++ b/depends/patches/bdb/winioctl.patch @@ -0,0 +1,13 @@ +diff --git a/src/dbinc/win_db.h b/src/dbinc/win_db.h +index 6544558..6cb6878 100644 +--- a/src/dbinc/win_db.h ++++ b/src/dbinc/win_db.h +@@ -46,7 +46,7 @@ + #include + #include + #ifndef DB_WINCE +-#include ++#include + #endif + + #ifdef HAVE_GETADDRINFO diff --git a/doc/build-freebsd.md b/doc/build-freebsd.md index f48855a344f..16412977be2 100644 --- a/doc/build-freebsd.md +++ b/doc/build-freebsd.md @@ -30,8 +30,8 @@ BerkeleyDB is only necessary for the wallet functionality. To skip this, pass `--disable-wallet` to `./configure` and skip to the next section. ```bash -./contrib/install_db4.sh `pwd` -export BDB_PREFIX="$PWD/db4" +./contrib/install_db5.sh `pwd` +export BDB_PREFIX="$PWD/db5" ``` ## Building Bitcoin Core diff --git a/doc/build-netbsd.md b/doc/build-netbsd.md index 47049a780ed..5b37f19ee8d 100644 --- a/doc/build-netbsd.md +++ b/doc/build-netbsd.md @@ -35,16 +35,16 @@ BerkeleyDB is only necessary for the wallet functionality. To skip this, pass It is recommended to use Berkeley DB 4.8. You cannot use the BerkeleyDB library from ports, for the same reason as boost above (g++/libstd++ incompatibility). If you have to build it yourself, you can use [the installation script included -in contrib/](/contrib/install_db4.sh) like so: +in contrib/](/contrib/install_db5.sh) like so: ```bash -./contrib/install_db4.sh `pwd` +./contrib/install_db5.sh `pwd` ``` from the root of the repository. Then set `BDB_PREFIX` for the next section: ```bash -export BDB_PREFIX="$PWD/db4" +export BDB_PREFIX="$PWD/db5" ``` ### Building Bitcoin Core diff --git a/doc/build-openbsd.md b/doc/build-openbsd.md index 2b051c078c8..c2dd349dff7 100644 --- a/doc/build-openbsd.md +++ b/doc/build-openbsd.md @@ -35,16 +35,16 @@ BerkeleyDB is only necessary for the wallet functionality. To skip this, pass It is recommended to use Berkeley DB 4.8. You cannot use the BerkeleyDB library from ports, for the same reason as boost above (g++/libstd++ incompatibility). If you have to build it yourself, you can use [the installation script included -in contrib/](/contrib/install_db4.sh) like so: +in contrib/](/contrib/install_db5.sh) like so: ```bash -./contrib/install_db4.sh `pwd` CC=cc CXX=c++ +./contrib/install_db5.sh `pwd` CC=cc CXX=c++ ``` from the root of the repository. Then set `BDB_PREFIX` for the next section: ```bash -export BDB_PREFIX="$PWD/db4" +export BDB_PREFIX="$PWD/db5" ``` ### Building Bitcoin Core diff --git a/doc/build-osx.md b/doc/build-osx.md index 300a9a922a3..c165d6abce6 100644 --- a/doc/build-osx.md +++ b/doc/build-osx.md @@ -46,12 +46,12 @@ In that case the Homebrew package will prevail. #### Berkeley DB -It is recommended to use Berkeley DB 4.8. If you have to build it yourself, -you can use [this](/contrib/install_db4.sh) script to install it +It is recommended to use Berkeley DB 5.3. If you have to build it yourself, +you can use [this](/contrib/install_db5.sh) script to install it like so: ```shell -./contrib/install_db4.sh . +./contrib/install_db5.sh . ``` from the root of the repository. @@ -59,7 +59,7 @@ from the root of the repository. Also, the Homebrew package could be installed: ```shell -brew install berkeley-db4 +brew install berkeley-db5 ``` ## Build Bitcoin Core diff --git a/doc/build-unix.md b/doc/build-unix.md index ab83ceff3dc..12d19e72bc2 100644 --- a/doc/build-unix.md +++ b/doc/build-unix.md @@ -41,7 +41,7 @@ Optional dependencies: Library | Purpose | Description ------------|------------------|---------------------- miniupnpc | UPnP Support | Firewall-jumping support - libdb4.8 | Berkeley DB | Wallet storage (only needed when wallet enabled) + libdb5.3 | Berkeley DB | Wallet storage (only needed when wallet enabled) qt | GUI | GUI toolkit (only needed when GUI enabled) libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled) univalue | Utility | JSON parsing and encoding (bundled version will be used unless --with-system-univalue passed to configure) @@ -85,10 +85,14 @@ Now, you can either build from self-compiled [depends](/depends/README.md) or in BerkeleyDB is required for the wallet. -Ubuntu and Debian have their own `libdb-dev` and `libdb++-dev` packages, but these will install -BerkeleyDB 5.1 or later. This will break binary wallet compatibility with the distributed executables, which -are based on BerkeleyDB 4.8. If you do not care about wallet compatibility, -pass `--with-incompatible-bdb` to configure. + Note that if you have Berkeley DB 4.8 packages installed (i.e. for other + wallet software), they are incompatible with the packages for 5.3. You + will have to manually download 5.3 from + http://download.oracle.com/berkeley-db/db-5.3.28.NC.tar.gz and compile + it, install it to /usr/local where the configure script should locate it + automatically. + +If you do not care about wallet compatibility, pass `--with-incompatible-bdb` to configure. Otherwise, you can build from self-compiled `depends` (see above). @@ -131,7 +135,7 @@ built by default. Build requirements: - sudo dnf install gcc-c++ libtool make autoconf automake libevent-devel boost-devel libdb4-devel libdb4-cxx-devel python3 + sudo dnf install gcc-c++ libtool make autoconf automake libevent-devel boost-devel libdb5-devel libdb5-cxx-devel python3 Optional (see `--with-miniupnpc` and `--enable-upnp-default`): @@ -173,12 +177,12 @@ turned off by default. See the configure options for upnp behavior desired: Berkeley DB ----------- -It is recommended to use Berkeley DB 4.8. If you have to build it yourself, -you can use [the installation script included in contrib/](/contrib/install_db4.sh) +It is recommended to use Berkeley DB 5.3. If you have to build it yourself, +you can use [the installation script included in contrib/](/contrib/install_db5.sh) like so: ```shell -./contrib/install_db4.sh `pwd` +./contrib/install_db5.sh `pwd` ``` from the root of the repository. @@ -247,7 +251,7 @@ disable-wallet mode with: ./configure --disable-wallet -In this case there is no dependency on Berkeley DB 4.8 and SQLite. +In this case there is no dependency on Berkeley DB 5.3 and SQLite. Mining is also possible in disable-wallet mode using the `getblocktemplate` RPC call. @@ -270,11 +274,11 @@ This example lists the steps necessary to setup and build a command line only, n make check Note: -Enabling wallet support requires either compiling against a Berkeley DB newer than 4.8 (package `db`) using `--with-incompatible-bdb`, -or building and depending on a local version of Berkeley DB 4.8. The readily available Arch Linux packages are currently built using +Enabling wallet support requires either compiling against a Berkeley DB newer than 5.3 (package `db`) using `--with-incompatible-bdb`, +or building and depending on a local version of Berkeley DB 5.3. The readily available Arch Linux packages are currently built using `--with-incompatible-bdb` according to the [PKGBUILD](https://projects.archlinux.org/svntogit/community.git/tree/bitcoin/trunk/PKGBUILD). As mentioned above, when maintaining portability of the wallet between the standard Bitcoin Core distributions and independently built -node software is desired, Berkeley DB 4.8 must be used. +node software is desired, Berkeley DB 5.3 must be used. ARM Cross-compilation From 2ada4adf9249079e0ae45ed2f054113efa7e52e0 Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Tue, 30 Nov 2021 01:06:36 +0000 Subject: [PATCH 3/4] Embed clang and macos patches for db5.3 Inspired by 92370033a2606ee88f4d080193e0bf6da481dc2e --- contrib/install_db5.sh | 401 ++++++++++++++++++++++++++++ depends/patches/bdb/configure.patch | 256 ++++++++++++++++++ 2 files changed, 657 insertions(+) create mode 100644 depends/patches/bdb/configure.patch diff --git a/contrib/install_db5.sh b/contrib/install_db5.sh index 0d05340f2df..411973cd2fd 100755 --- a/contrib/install_db5.sh +++ b/contrib/install_db5.sh @@ -68,6 +68,407 @@ http_get "${BDB_URL}" "${BDB_VERSION}.tar.gz" "${BDB_HASH}" tar -xzvf ${BDB_VERSION}.tar.gz -C "$BDB_PREFIX" cd "${BDB_PREFIX}/${BDB_VERSION}/" +# Apply a patch necessary when building with clang and c++11 (see https://community.oracle.com/thread/3952592) +patch --ignore-whitespace -p1 << 'EOF' +diff --git a/src/dbinc/atomic.h b/src/dbinc/atomic.h +index 6a858f7..9f338dc 100644 +--- a/src/dbinc/atomic.h ++++ b/src/dbinc/atomic.h +@@ -70,7 +70,7 @@ typedef struct { + * These have no memory barriers; the caller must include them when necessary. + */ + #define atomic_read(p) ((p)->value) +-#define atomic_init(p, val) ((p)->value = (val)) ++#define atomic_init_db(p, val) ((p)->value = (val)) + + #ifdef HAVE_ATOMIC_SUPPORT + +@@ -144,7 +144,7 @@ typedef LONG volatile *interlocked_val; + #define atomic_inc(env, p) __atomic_inc(p) + #define atomic_dec(env, p) __atomic_dec(p) + #define atomic_compare_exchange(env, p, o, n) \ +- __atomic_compare_exchange((p), (o), (n)) ++ __atomic_compare_exchange_db((p), (o), (n)) + static inline int __atomic_inc(db_atomic_t *p) + { + int temp; +@@ -176,7 +176,7 @@ static inline int __atomic_dec(db_atomic_t *p) + * http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html + * which configure could be changed to use. + */ +-static inline int __atomic_compare_exchange( ++static inline int __atomic_compare_exchange_db( + db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval) + { + atomic_value_t was; +@@ -206,7 +206,7 @@ static inline int __atomic_compare_exchange( + #define atomic_dec(env, p) (--(p)->value) + #define atomic_compare_exchange(env, p, oldval, newval) \ + (DB_ASSERT(env, atomic_read(p) == (oldval)), \ +- atomic_init(p, (newval)), 1) ++ atomic_init_db(p, (newval)), 1) + #else + #define atomic_inc(env, p) __atomic_inc(env, p) + #define atomic_dec(env, p) __atomic_dec(env, p) +diff --git a/src/mp/mp_fget.c b/src/mp/mp_fget.c +index 16de695..d0dcc29 100644 +--- a/src/mp/mp_fget.c ++++ b/src/mp/mp_fget.c +@@ -649,7 +649,7 @@ alloc: /* Allocate a new buffer header and data space. */ + + /* Initialize enough so we can call __memp_bhfree. */ + alloc_bhp->flags = 0; +- atomic_init(&alloc_bhp->ref, 1); ++ atomic_init_db(&alloc_bhp->ref, 1); + #ifdef DIAGNOSTIC + if ((uintptr_t)alloc_bhp->buf & (sizeof(size_t) - 1)) { + __db_errx(env, DB_STR("3025", +@@ -955,7 +955,7 @@ alloc: /* Allocate a new buffer header and data space. */ + MVCC_MPROTECT(bhp->buf, mfp->pagesize, + PROT_READ); + +- atomic_init(&alloc_bhp->ref, 1); ++ atomic_init_db(&alloc_bhp->ref, 1); + MUTEX_LOCK(env, alloc_bhp->mtx_buf); + alloc_bhp->priority = bhp->priority; + alloc_bhp->pgno = bhp->pgno; +diff --git a/src/mp/mp_mvcc.c b/src/mp/mp_mvcc.c +index 770bad8..e28cce0 100644 +--- a/src/mp/mp_mvcc.c ++++ b/src/mp/mp_mvcc.c +@@ -276,7 +276,7 @@ __memp_bh_freeze(dbmp, infop, hp, bhp, need_frozenp) + #else + memcpy(frozen_bhp, bhp, SSZA(BH, buf)); + #endif +- atomic_init(&frozen_bhp->ref, 0); ++ atomic_init_db(&frozen_bhp->ref, 0); + if (mutex != MUTEX_INVALID) + frozen_bhp->mtx_buf = mutex; + else if ((ret = __mutex_alloc(env, MTX_MPOOL_BH, +@@ -428,7 +428,7 @@ __memp_bh_thaw(dbmp, infop, hp, frozen_bhp, alloc_bhp) + #endif + alloc_bhp->mtx_buf = mutex; + MUTEX_LOCK(env, alloc_bhp->mtx_buf); +- atomic_init(&alloc_bhp->ref, 1); ++ atomic_init_db(&alloc_bhp->ref, 1); + F_CLR(alloc_bhp, BH_FROZEN); + } + +diff --git a/src/mp/mp_region.c b/src/mp/mp_region.c +index 4952030..47645f8 100644 +--- a/src/mp/mp_region.c ++++ b/src/mp/mp_region.c +@@ -245,7 +245,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg) + MTX_MPOOL_FILE_BUCKET, 0, &htab[i].mtx_hash)) != 0) + return (ret); + SH_TAILQ_INIT(&htab[i].hash_bucket); +- atomic_init(&htab[i].hash_page_dirty, 0); ++ atomic_init_db(&htab[i].hash_page_dirty, 0); + } + + /* +@@ -302,7 +302,7 @@ no_prealloc: + } else + hp->mtx_hash = mtx_base + (i % dbenv->mp_mtxcount); + SH_TAILQ_INIT(&hp->hash_bucket); +- atomic_init(&hp->hash_page_dirty, 0); ++ atomic_init_db(&hp->hash_page_dirty, 0); + #ifdef HAVE_STATISTICS + hp->hash_io_wait = 0; + hp->hash_frozen = hp->hash_thawed = hp->hash_frozen_freed = 0; +diff --git a/src/mutex/mut_method.c b/src/mutex/mut_method.c +index 09353b0..177353c 100644 +--- a/src/mutex/mut_method.c ++++ b/src/mutex/mut_method.c +@@ -474,7 +474,7 @@ atomic_compare_exchange(env, v, oldval, newval) + MUTEX_LOCK(env, mtx); + ret = atomic_read(v) == oldval; + if (ret) +- atomic_init(v, newval); ++ atomic_init_db(v, newval); + MUTEX_UNLOCK(env, mtx); + + return (ret); +diff --git a/src/mutex/mut_tas.c b/src/mutex/mut_tas.c +index 106b161..fc4de9d 100644 +--- a/src/mutex/mut_tas.c ++++ b/src/mutex/mut_tas.c +@@ -47,7 +47,7 @@ __db_tas_mutex_init(env, mutex, flags) + + #ifdef HAVE_SHARED_LATCHES + if (F_ISSET(mutexp, DB_MUTEX_SHARED)) +- atomic_init(&mutexp->sharecount, 0); ++ atomic_init_db(&mutexp->sharecount, 0); + else + #endif + if (MUTEX_INIT(&mutexp->tas)) { +@@ -536,7 +536,7 @@ __db_tas_mutex_unlock(env, mutex) + F_CLR(mutexp, DB_MUTEX_LOCKED); + /* Flush flag update before zeroing count */ + MEMBAR_EXIT(); +- atomic_init(&mutexp->sharecount, 0); ++ atomic_init_db(&mutexp->sharecount, 0); + } else { + DB_ASSERT(env, sharecount > 0); + MEMBAR_EXIT(); +EOF + +# Apply a patch for compatibility with X-Code 12.1 +patch --ignore-whitespace -p1 << 'EOF' +--- a/dist/configure 2013-09-09 16:35:02.000000000 +0100 ++++ b/dist/configure 2021-11-30 19:46:10.341486676 +0000 +@@ -21275,7 +21275,7 @@ + static lwp_cond_t ci = SHAREDCV; + lwp_mutex_t mutex = mi; + lwp_cond_t cond = ci; +- exit ( ++ return ( + _lwp_mutex_lock(&mutex) || + _lwp_mutex_unlock(&mutex)); + +@@ -21305,7 +21305,7 @@ + mutex_t mutex; + cond_t cond; + int type = USYNC_PROCESS; +- exit ( ++ return ( + mutex_init(&mutex, type, NULL) || + cond_init(&cond, type, NULL) || + mutex_lock(&mutex) || +@@ -21335,7 +21335,7 @@ + mutex_t mutex; + cond_t cond; + int type = USYNC_PROCESS; +- exit ( ++ return ( + mutex_init(&mutex, type, NULL) || + cond_init(&cond, type, NULL) || + mutex_lock(&mutex) || +@@ -21370,7 +21370,7 @@ + { + + #if (defined(i386) || defined(__i386__)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21393,7 +21393,7 @@ + { + + #if (defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21445,7 +21445,7 @@ + + #if defined(__sparc__) && defined(__GNUC__) + asm volatile ("membar #StoreStore|#StoreLoad|#LoadStore"); +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21516,7 +21516,7 @@ + msem_init(&x, 0); + msem_lock(&x, 0); + msem_unlock(&x, 0); +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21548,7 +21548,7 @@ + msem_init(&x, 0); + msem_lock(&x, 0); + msem_unlock(&x, 0); +- exit(0); ++ return (0); + + ; + return 0; +@@ -21600,7 +21600,7 @@ + { + + #if defined(__USLC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21731,7 +21731,7 @@ + { + + #if defined(__alpha) && defined(__DECC) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21756,7 +21756,7 @@ + { + + #if defined(__alpha) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21781,7 +21781,7 @@ + { + + #if defined(__arm__) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21806,7 +21806,7 @@ + { + + #if (defined(__mips) || defined(__mips__)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21831,7 +21831,7 @@ + { + + #if (defined(__hppa) || defined(__hppa__)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21856,7 +21856,7 @@ + { + + #if (defined(__powerpc__) || defined(__ppc__)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21881,7 +21881,7 @@ + { + + #if (defined(mc68020) || defined(sun3)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21906,7 +21906,7 @@ + { + + #if defined(__MVS__) && defined(__IBMC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21931,7 +21931,7 @@ + { + + #if defined(__s390__) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21956,7 +21956,7 @@ + { + + #if defined(__ia64) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21981,7 +21981,7 @@ + { + + #if defined(_UTS) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -22464,9 +22464,9 @@ + { + + #if ((defined(i386) || defined(__i386__)) && defined(__GNUC__)) +- exit(0); ++ return (0); + #elif ((defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__)) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -22491,7 +22491,7 @@ + { + + volatile unsigned val = 1; +- exit (atomic_inc_uint_nv(&val) != 2 || ++ return (atomic_inc_uint_nv(&val) != 2 || + atomic_dec_uint_nv(&val) != 1 || + atomic_cas_32(&val, 1, 3) != 3); + +@@ -24192,6 +24192,11 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + ++#include ++#if HAVE_STRING_H ++#include ++#endif ++ + int + main () + { +@@ -24226,7 +24231,12 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +- main() { ++#include ++#if HAVE_STRING_H ++#include ++#endif ++ ++ int main() { + $db_cv_seq_type l; + unsigned $db_cv_seq_type u; + char buf[100]; +@@ -24309,6 +24319,9 @@ + #include + #include + #include ++ #if HAVE_UNISTD_H ++ #include ++ #endif + + #define TEST_MMAP_BUFSIZE (16 * 1024) + #define TEST_MMAP_EXTENDSIZE (16 * 1024 * 1024) +@@ -24319,10 +24332,10 @@ + int catch_sig(sig) + int sig; + { +- exit(1); ++ return (1); + } + +- main() { ++ int main() { + const char *underlying; + unsigned gapsize; + char *base; +EOF + cd build_unix/ "${BDB_PREFIX}/${BDB_VERSION}/dist/configure" \ diff --git a/depends/patches/bdb/configure.patch b/depends/patches/bdb/configure.patch new file mode 100644 index 00000000000..03b2d4012e9 --- /dev/null +++ b/depends/patches/bdb/configure.patch @@ -0,0 +1,256 @@ +Taken from https://github.com/macports/macports-ports/commit/b661c0e483b08cd4d19a1d50dfc8ebbe93966631 + +Fixes compatibility with Xcode 12.1 + +--- a/dist/configure 2013-09-09 16:35:02.000000000 +0100 ++++ b/dist/configure 2021-11-30 19:46:10.341486676 +0000 +@@ -21275,7 +21275,7 @@ + static lwp_cond_t ci = SHAREDCV; + lwp_mutex_t mutex = mi; + lwp_cond_t cond = ci; +- exit ( ++ return ( + _lwp_mutex_lock(&mutex) || + _lwp_mutex_unlock(&mutex)); + +@@ -21305,7 +21305,7 @@ + mutex_t mutex; + cond_t cond; + int type = USYNC_PROCESS; +- exit ( ++ return ( + mutex_init(&mutex, type, NULL) || + cond_init(&cond, type, NULL) || + mutex_lock(&mutex) || +@@ -21335,7 +21335,7 @@ + mutex_t mutex; + cond_t cond; + int type = USYNC_PROCESS; +- exit ( ++ return ( + mutex_init(&mutex, type, NULL) || + cond_init(&cond, type, NULL) || + mutex_lock(&mutex) || +@@ -21370,7 +21370,7 @@ + { + + #if (defined(i386) || defined(__i386__)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21393,7 +21393,7 @@ + { + + #if (defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21445,7 +21445,7 @@ + + #if defined(__sparc__) && defined(__GNUC__) + asm volatile ("membar #StoreStore|#StoreLoad|#LoadStore"); +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21516,7 +21516,7 @@ + msem_init(&x, 0); + msem_lock(&x, 0); + msem_unlock(&x, 0); +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21548,7 +21548,7 @@ + msem_init(&x, 0); + msem_lock(&x, 0); + msem_unlock(&x, 0); +- exit(0); ++ return (0); + + ; + return 0; +@@ -21600,7 +21600,7 @@ + { + + #if defined(__USLC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21731,7 +21731,7 @@ + { + + #if defined(__alpha) && defined(__DECC) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21756,7 +21756,7 @@ + { + + #if defined(__alpha) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21781,7 +21781,7 @@ + { + + #if defined(__arm__) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21806,7 +21806,7 @@ + { + + #if (defined(__mips) || defined(__mips__)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21831,7 +21831,7 @@ + { + + #if (defined(__hppa) || defined(__hppa__)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21856,7 +21856,7 @@ + { + + #if (defined(__powerpc__) || defined(__ppc__)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21881,7 +21881,7 @@ + { + + #if (defined(mc68020) || defined(sun3)) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21906,7 +21906,7 @@ + { + + #if defined(__MVS__) && defined(__IBMC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21931,7 +21931,7 @@ + { + + #if defined(__s390__) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21956,7 +21956,7 @@ + { + + #if defined(__ia64) && defined(__GNUC__) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -21981,7 +21981,7 @@ + { + + #if defined(_UTS) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -22464,9 +22464,9 @@ + { + + #if ((defined(i386) || defined(__i386__)) && defined(__GNUC__)) +- exit(0); ++ return (0); + #elif ((defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__)) +- exit(0); ++ return (0); + #else + FAIL TO COMPILE/LINK + #endif +@@ -22491,7 +22491,7 @@ + { + + volatile unsigned val = 1; +- exit (atomic_inc_uint_nv(&val) != 2 || ++ return (atomic_inc_uint_nv(&val) != 2 || + atomic_dec_uint_nv(&val) != 1 || + atomic_cas_32(&val, 1, 3) != 3); + +@@ -24192,6 +24192,11 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + ++#include ++#if HAVE_STRING_H ++#include ++#endif ++ + int + main () + { +@@ -24226,7 +24231,12 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +- main() { ++#include ++#if HAVE_STRING_H ++#include ++#endif ++ ++ int main() { + $db_cv_seq_type l; + unsigned $db_cv_seq_type u; + char buf[100]; +@@ -24309,6 +24319,9 @@ + #include + #include + #include ++ #if HAVE_UNISTD_H ++ #include ++ #endif + + #define TEST_MMAP_BUFSIZE (16 * 1024) + #define TEST_MMAP_EXTENDSIZE (16 * 1024 * 1024) +@@ -24319,10 +24332,10 @@ + int catch_sig(sig) + int sig; + { +- exit(1); ++ return (1); + } + +- main() { ++ int main() { + const char *underlying; + unsigned gapsize; + char *base; From e9c393bdf1f78f8cf3cb191df3f6b954b6a24508 Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Wed, 23 Mar 2022 16:26:26 +0100 Subject: [PATCH 4/4] qa: Use packaged bdb5 install script for macos native CI - Self-compile bdb5.3 using contrib/install_db5.sh - Enable posixthreads flag on bdb5 macos native compilation - Install db5 files into an absolute path - Add the BDB_LIBS and BDB_CLFAGS env vars to ./configure Co-authored-by: Ross Nicoll --- .cirrus.yml | 2 +- ci/test/00_setup_env_mac_host.sh | 3 ++- ci/test/05_before_script.sh | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 93f94af7319..750c3e86337 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -138,7 +138,7 @@ task: name: 'macOS 10.14 native [GOAL: install] [GUI] [no depends]' brew_install_script: - brew update - - brew install boost libevent berkeley-db4 qt@5 miniupnpc ccache zeromq qrencode sqlite libtool automake pkg-config gnu-getopt + - brew install boost libevent qt@5 miniupnpc ccache zeromq qrencode sqlite libtool automake pkg-config gnu-getopt << : *GLOBAL_TASK_TEMPLATE osx_instance: # Use latest image, but hardcode version to avoid silent upgrades (and breaks) diff --git a/ci/test/00_setup_env_mac_host.sh b/ci/test/00_setup_env_mac_host.sh index a710d983e5d..1ca92535c1e 100644 --- a/ci/test/00_setup_env_mac_host.sh +++ b/ci/test/00_setup_env_mac_host.sh @@ -9,7 +9,8 @@ export LC_ALL=C.UTF-8 export HOST=x86_64-apple-darwin16 export PIP_PACKAGES="zmq" export GOAL="install" -export BITCOIN_CONFIG="--with-gui --enable-reduce-exports --with-boost-process" +export BDB_PREFIX="${BASE_ROOT_DIR}/db5" +export BITCOIN_CONFIG="--with-gui --enable-reduce-exports --with-boost-process BDB_LIBS='-L${BDB_PREFIX}/lib -ldb_cxx-5.3' BDB_CFLAGS='-I${BDB_PREFIX}/include'" export CI_OS_NAME="macos" export NO_DEPENDS=1 export OSX_SDK="" diff --git a/ci/test/05_before_script.sh b/ci/test/05_before_script.sh index 5d0034be129..89ecb4ac7a5 100755 --- a/ci/test/05_before_script.sh +++ b/ci/test/05_before_script.sh @@ -31,6 +31,11 @@ if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then DOCKER_EXEC "contrib/install_db5.sh \$(pwd) --enable-umrw CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'" fi +if [[ $HOST = *-apple-darwin16 ]]; then + # Use BDB compiled using install_db5.sh script as Brew does not supply BDB 5.3 + DOCKER_EXEC "contrib/install_db5.sh \$BASE_ROOT_DIR --enable-posixmutexes" +fi + if [ -n "$XCODE_VERSION" ] && [ -f "$OSX_SDK_PATH" ]; then DOCKER_EXEC tar -C "${DEPENDS_DIR}/SDKs" -xf "$OSX_SDK_PATH" fi