From 1a6738f920f8334efdc4c811ccbf1855d81e8384 Mon Sep 17 00:00:00 2001 From: Bertrand Jacquin Date: Sat, 21 Aug 2021 23:45:41 +0100 Subject: [PATCH] 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_bdb51.m4 => dogecoin_find_bdb53.m4} | 28 +++++++------- configure.ac | 2 +- depends/packages/bdb.mk | 6 +-- .../patches/bdb-5.1.29-clang-osx/README.md | 4 -- .../bdb-5.1.29-clang-osx/atomic.h.patch | 38 ------------------- .../bdb-5.1.29-clang-osx/mp_fget.c.patch | 20 ---------- .../bdb-5.1.29-clang-osx/mp_mvcc.c.patch | 20 ---------- .../bdb-5.1.29-clang-osx/mp_region.c.patch | 20 ---------- .../bdb-5.1.29-clang-osx/mut_method.c.patch | 11 ------ .../bdb-5.1.29-clang-osx/mut_tas.c.patch | 20 ---------- doc/Building-Dogecoin-1.14-for-Mac.md | 37 ++++++------------ doc/build-osx.md | 2 +- doc/build-unix.md | 14 +++---- 13 files changed, 37 insertions(+), 185 deletions(-) rename build-aux/m4/{dogecoin_find_bdb51.m4 => dogecoin_find_bdb53.m4} (73%) delete mode 100644 depends/patches/bdb-5.1.29-clang-osx/README.md delete mode 100644 depends/patches/bdb-5.1.29-clang-osx/atomic.h.patch delete mode 100644 depends/patches/bdb-5.1.29-clang-osx/mp_fget.c.patch delete mode 100644 depends/patches/bdb-5.1.29-clang-osx/mp_mvcc.c.patch delete mode 100644 depends/patches/bdb-5.1.29-clang-osx/mp_region.c.patch delete mode 100644 depends/patches/bdb-5.1.29-clang-osx/mut_method.c.patch delete mode 100644 depends/patches/bdb-5.1.29-clang-osx/mut_tas.c.patch diff --git a/build-aux/m4/dogecoin_find_bdb51.m4 b/build-aux/m4/dogecoin_find_bdb53.m4 similarity index 73% rename from build-aux/m4/dogecoin_find_bdb51.m4 rename to build-aux/m4/dogecoin_find_bdb53.m4 index 22d71dfd3..c04c43463 100644 --- a/build-aux/m4/dogecoin_find_bdb51.m4 +++ b/build-aux/m4/dogecoin_find_bdb53.m4 @@ -1,11 +1,11 @@ -AC_DEFUN([BITCOIN_FIND_BDB51],[ +AC_DEFUN([BITCOIN_FIND_BDB53],[ AC_MSG_CHECKING([for Berkeley DB C++ headers]) BDB_CPPFLAGS= BDB_LIBS= bdbpath=X - bdb51path=X + bdb53path=X bdbdirlist= - for _vn in 5.1 51 5 ''; do + for _vn in 5.3 53 5 ''; do for _pfx in b lib ''; do bdbdirlist="$bdbdirlist ${_pfx}db${_vn}" done @@ -15,8 +15,8 @@ AC_DEFUN([BITCOIN_FIND_BDB51],[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <${searchpath}db_cxx.h> ]],[[ - #if !((DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR >= 1) || DB_VERSION_MAJOR > 5) - #error "failed to find bdb 5.1+" + #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 @@ -28,32 +28,32 @@ AC_DEFUN([BITCOIN_FIND_BDB51],[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <${searchpath}db_cxx.h> ]],[[ - #if !(DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR == 1) - #error "failed to find bdb 5.1" + #if !(DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR == 3) + #error "failed to find bdb 5.3" #endif ]])],[ - bdb51path="${searchpath}" + bdb53path="${searchpath}" break ],[]) done if test "x$bdbpath" = "xX"; then AC_MSG_RESULT([no]) AC_MSG_ERROR([libdb_cxx headers missing, Dogecoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality)]) - elif test "x$bdb51path" = "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 5.1; wallets opened by this build will not be portable!]) + 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 5.1, 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,[${bdb51path}],db_cxx) - bdbpath="${bdb51path}" + BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb53path}],db_cxx) + bdbpath="${bdb53path}" fi AC_SUBST(BDB_CPPFLAGS) # TODO: Ideally this could find the library version and make sure it matches the headers being used - for searchlib in db_cxx-5.1 db_cxx; do + for searchlib in db_cxx-5.3 db_cxx; do AC_CHECK_LIB([$searchlib],[main],[ BDB_LIBS="-l${searchlib}" break diff --git a/configure.ac b/configure.ac index b96febce8..25723142d 100644 --- a/configure.ac +++ b/configure.ac @@ -597,7 +597,7 @@ AC_SUBST(LIBMEMENV) if test x$enable_wallet != xno; then dnl Check for libdb_cxx only if wallet enabled - BITCOIN_FIND_BDB51 + BITCOIN_FIND_BDB53 fi dnl Check for libminiupnpc (optional) diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk index 0b7142d9a..52bdbca6e 100644 --- a/depends/packages/bdb.mk +++ b/depends/packages/bdb.mk @@ -1,8 +1,8 @@ package=bdb -$(package)_version=5.1.29 +$(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=08238e59736d1aacdd47cfb8e68684c695516c37f4fbe1b8267dde58dc3a576c +$(package)_sha256_hash=76a25560d9e52a198d37a31440fd07632b5f1f8f9f2b6d5438f4bc3e7c9013ef $(package)_build_subdir=build_unix define $(package)_set_vars @@ -24,7 +24,7 @@ define $(package)_config_cmds endef define $(package)_build_cmds - $(MAKE) libdb_cxx-5.1.a libdb-5.1.a + $(MAKE) libdb_cxx-5.3.a libdb-5.3.a endef define $(package)_stage_cmds diff --git a/depends/patches/bdb-5.1.29-clang-osx/README.md b/depends/patches/bdb-5.1.29-clang-osx/README.md deleted file mode 100644 index 4af7cffb7..000000000 --- a/depends/patches/bdb-5.1.29-clang-osx/README.md +++ /dev/null @@ -1,4 +0,0 @@ -These patches are to allow bdb-5.1.29 to compile using clang / c++11 under later MacOSX versions (Sierra+). -These patches must be applied to the bdb-5.1.29 source from Oracle, and then compiled, for the Mac client to build. - -Note some of these exist in bdb.mk but we don't want to use the -stdlib=libstd++ flag that's indicated in there on OSX. diff --git a/depends/patches/bdb-5.1.29-clang-osx/atomic.h.patch b/depends/patches/bdb-5.1.29-clang-osx/atomic.h.patch deleted file mode 100644 index c702e2b53..000000000 --- a/depends/patches/bdb-5.1.29-clang-osx/atomic.h.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- old-bdb/src/dbinc/atomic.h 2011-10-25 14:39:34.000000000 -0600 -+++ new-bdb/src/dbinc/atomic.h 2018-06-01 19:59:37.000000000 -0600 -@@ -70,7 +70,7 @@ - * 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 @@ - #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 @@ - * 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 @@ - #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/depends/patches/bdb-5.1.29-clang-osx/mp_fget.c.patch b/depends/patches/bdb-5.1.29-clang-osx/mp_fget.c.patch deleted file mode 100644 index a524da7ac..000000000 --- a/depends/patches/bdb-5.1.29-clang-osx/mp_fget.c.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- old-bdb/src/mp/mp_fget.c 2011-10-25 14:39:35.000000000 -0600 -+++ new-bdb/src/mp/mp_fget.c 2018-06-01 20:01:48.000000000 -0600 -@@ -629,7 +629,7 @@ - - /* 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, -@@ -931,7 +931,7 @@ - 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/depends/patches/bdb-5.1.29-clang-osx/mp_mvcc.c.patch b/depends/patches/bdb-5.1.29-clang-osx/mp_mvcc.c.patch deleted file mode 100644 index a12084208..000000000 --- a/depends/patches/bdb-5.1.29-clang-osx/mp_mvcc.c.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- old-bdb/src/mp/mp_mvcc.c 2011-10-25 14:39:35.000000000 -0600 -+++ new-bdb/src/mp/mp_mvcc.c 2018-06-01 20:02:45.000000000 -0600 -@@ -276,7 +276,7 @@ - #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 @@ - #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/depends/patches/bdb-5.1.29-clang-osx/mp_region.c.patch b/depends/patches/bdb-5.1.29-clang-osx/mp_region.c.patch deleted file mode 100644 index 713d9ca69..000000000 --- a/depends/patches/bdb-5.1.29-clang-osx/mp_region.c.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- old-bdb/src/mp/mp_region.c 2011-10-25 14:39:35.000000000 -0600 -+++ new-bdb/src/mp/mp_region.c 2018-06-01 20:03:28.000000000 -0600 -@@ -229,7 +229,7 @@ - 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); - } - - /* -@@ -275,7 +275,7 @@ - hp->mtx_hash = (mtx_base == MUTEX_INVALID) ? MUTEX_INVALID : - 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/depends/patches/bdb-5.1.29-clang-osx/mut_method.c.patch b/depends/patches/bdb-5.1.29-clang-osx/mut_method.c.patch deleted file mode 100644 index 95efc8dad..000000000 --- a/depends/patches/bdb-5.1.29-clang-osx/mut_method.c.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- old-bdb/src/mutex/mut_method.c 2011-10-25 14:39:35.000000000 -0600 -+++ new-bdb/src/mutex/mut_method.c 2018-06-01 20:04:05.000000000 -0600 -@@ -428,7 +428,7 @@ - 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/depends/patches/bdb-5.1.29-clang-osx/mut_tas.c.patch b/depends/patches/bdb-5.1.29-clang-osx/mut_tas.c.patch deleted file mode 100644 index 5f9ed1398..000000000 --- a/depends/patches/bdb-5.1.29-clang-osx/mut_tas.c.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- old-bdb/src/mutex/mut_tas.c 2011-10-25 14:39:35.000000000 -0600 -+++ new-bdb/src/mutex/mut_tas.c 2018-06-01 20:04:25.000000000 -0600 -@@ -48,7 +48,7 @@ - - #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)) { -@@ -521,7 +521,7 @@ - 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(); diff --git a/doc/Building-Dogecoin-1.14-for-Mac.md b/doc/Building-Dogecoin-1.14-for-Mac.md index 22e2b0fe9..242e9e875 100644 --- a/doc/Building-Dogecoin-1.14-for-Mac.md +++ b/doc/Building-Dogecoin-1.14-for-Mac.md @@ -40,49 +40,34 @@ Install Boost lib via Brew from source, and link it to be sure: $brew install boost --build-from-source --HEAD $brew link boost167 -### Get, Patch And Compile BDB 5.1 ### +### Get, Patch And Compile BDB 5.3 ### -Download bdb 5.1.29 source from Oracle. +Download bdb 5.3.28 source from Oracle. - $curl -o db-5.1.29.tar.gz http://download.oracle.com/berkeley-db/db-5.1.29.tar.gz - $tar xvfz db-5.1.29.tar.gz - $cd db-5.1.29 + $curl -o db-5.3.28.tar.gz http://download.oracle.com/berkeley-db/db-5.3.28.tar.gz + $tar xvfz db-5.3.28.tar.gz + $cd db-5.3.28 -Patch bdb 5.1.29 from our patchfiles - - $cd src - $cd dbinc - $patch -b atomic.h ~/dogecoin/depends/patches/bdb-5.1.29-clang-osx/atomic.h.patch - $cd .. - $cd mp - $patch -b mp_fget.c ~/dogecoin/depends/patches/bdb-5.1.29-clang-osx/mp_fget.c.patch - $patch -b mp_mvcc.c ~/dogecoin/depends/patches/bdb-5.1.29-clang-osx/mp_mvcc.c.patch - $patch -b mp_region.c ~/dogecoin/depends/patches/bdb-5.1.29-clang-osx/mp_region.c.patch - $cd .. - $cd mutex - $patch -b mut_method.c ~/dogecoin/depends/patches/bdb-5.1.29-clang-osx/mut_method.c.patch - $patch -b mut_tas.c ~/dogecoin/depends/patches/bdb-5.1.29-clang-osx/mut_tas.c.patch - -Build BDB 5.1.29 +Build BDB 5.3.28 $cd ../.. $cd build_unix $../dist/configure CXX=clang++ --enable-cxx $make - $sudo mkdir /usr/local/BerkeleyDB.5.1 - $sudo chown $(whoami):admin /usr/local/BerkeleyDB.5.1 + $sudo mkdir /usr/local/BerkeleyDB.5.3 + $sudo chown $(whoami):admin /usr/local/BerkeleyDB.5.3 $sudo make install ### Set some environment variables and links for bdb and openssl ### - $export LDFLAGS=-L/usr/local/BerkeleyDB.5.1/lib - $export CPPFLAGS=-I/usr/local/BerkeleyDB.5.1/include + $export LDFLAGS=-L/usr/local/BerkeleyDB.5.3/lib + $export CPPFLAGS=-I/usr/local/BerkeleyDB.5.3/include _**NOTE:** for MacOS BigSur (11.1) or later, and possibly Catalina (10.15) you will also have to include the "OBJC_OLD_DISPATCH_PROTOTYPES=1" flag._ _So in this case you want the above export to be:_ - $export CPPFLAGS="-I/usr/local/BerkeleyDB.5.1/include -DOBJC_OLD_DISPATCH_PROTOTYPES=1" + $export CPPFLAGS="-I/usr/local/BerkeleyDB.5.3/include -DOBJC_OLD_DISPATCH_PROTOTYPES=1" _(Note that the quotes are required.)_ diff --git a/doc/build-osx.md b/doc/build-osx.md index 97536bbea..d00aac366 100644 --- a/doc/build-osx.md +++ b/doc/build-osx.md @@ -17,7 +17,7 @@ Dependencies ---------------------- brew install automake libtool boost miniupnpc openssl pkg-config protobuf qt5 libevent - brew install berkeley-db # You need to make sure you install a version >= 5.1.29, but as close to 5.1.29 as possible. Check the homebrew docs to find out how to install older versions. + brew install berkeley-db # You need to make sure you install a version >= 5.3.28, but as close to 5.3.28 as possible. Check the homebrew docs to find out how to install older versions. If you want to build the disk image with `make deploy` (.dmg / optional), you need RSVG diff --git a/doc/build-unix.md b/doc/build-unix.md index 21927e149..4821cade0 100644 --- a/doc/build-unix.md +++ b/doc/build-unix.md @@ -43,7 +43,7 @@ Wallet is optional to run a node, see [Wallet](#wallet) section to enable them. Library | Purpose | Description ------------|------------------|---------------------- miniupnpc | UPnP Support | Firewall-jumping support - libdb5.1 | 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) protobuf | Payments in GUI | Data interchange format used for payment protocol (only needed when GUI enabled) libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled) @@ -108,24 +108,24 @@ Create `dogecoin-qt`, the core wallet GUI. #### Wallet BerkeleyDB is required for wallet functionality and use the `wallet.dat` file. -By default, **Dogecoin Core expect BerkeleyDB 5.1**. +By default, **Dogecoin Core expect BerkeleyDB 5.3**. You can use a different version by specifying `--with-incompatible-bdb` flag. If no package is available for your distribution in optional dependencies, you can build BerkeleyDB from source : ```bash -# Install script for BerkeleyDB 5.1 +# Install script for BerkeleyDB 5.3 # BerkeleyDB installation directory BDB_PREFIX=$(pwd)/bdb mkdir $BDB_PREFIX # Fetch the source and verify shasum -wget 'http://download.oracle.com/berkeley-db/db-5.1.29.NC.tar.gz' -echo '08238e59736d1aacdd47cfb8e68684c695516c37f4fbe1b8267dde58dc3a576c db-5.1.29.NC.tar.gz' | sha256sum -c +wget 'http://download.oracle.com/berkeley-db/db-5.3.28.NC.tar.gz' +echo '76a25560d9e52a198d37a31440fd07632b5f1f8f9f2b6d5438f4bc3e7c9013efdb-5.3.28.NC.tar.gz' | sha256sum -c # Extract sources -tar -xzvf db-5.1.29.NC.tar.gz -cd db-5.1.29.NC/build_unix/ +tar -xzvf db-5.3.28.NC.tar.gz +cd db-5.3.28.NC/build_unix/ # Apply patch (see https://gist.github.com/danieldk/5700533) sed -i 's/__atomic_compare_exchange/__atomic_compare_exchange_db/g' ../src/dbinc/atomic.h