Skip to content

Commit ad61e67

Browse files
committed
Merge #2970: [CI] Stop relying on system BerkeleyDB packages for native builds
de55dd9 CI: Run configure before cmake on macOS (Fuzzbawls) 5865b1e CI: Build BDB for native runners (Fuzzbawls) 2af6478 Contrib: Update install_db4.sh (Fuzzbawls) 8a21052 CI: Silence brew install warnings (Fuzzbawls) f2f456a CMake: Stop explicitly setting `BerkeleyDB_ROOT_DIR` (Fuzzbawls) ada1bae Build: Check if Homebrew BDB is actually installed (Fuzzbawls) Pull request description: This removes the dependence on system package managers to provide the BerkeleyDB library for native build jobs. Instead, use the supplied `install_db4.sh` script to compile and install BerkeleyDB into a system path (`/usr/local`). Rationale for this change is that Homebrew is going to remove BerkeleyDB 4 from it's package manager soon, so this is a proactive change to prevent CI build jobs from breaking when that happens. Homebrew based BerkeleyDB 4 support is still retained on our end for those that already have the package installed. Linux native CI build jobs are also switched over to this method of compiling/installing BerkeleyDB 4, rather than using the package manager's BerkeleyDB 5. ACKs for top commit: de55dd9 Duddino: ACK de55dd9 Liquid369: ACK de55dd9 Tree-SHA512: 337e058d836dd07f6e379e305c094c8c458f94bec044d126ffde7ef9e34e13fcbab0a09d1312922681c3964dd710b6d382b950dfa07a8bc5f714598447f33402
2 parents 38f5978 + de55dd9 commit ad61e67

File tree

5 files changed

+63
-47
lines changed

5 files changed

+63
-47
lines changed

.github/workflows/build-and-test.yml

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -152,32 +152,32 @@ jobs:
152152
- name: Linux
153153
os: ubuntu-22.04
154154
python-version: '3.8'
155-
packages: python3-zmq qttools5-dev qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
155+
packages: python3-zmq qttools5-dev qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
156156
cc: gcc
157157
cxx: g++
158158

159159
- name: Linux-latest
160160
os: ubuntu-24.04
161161
python-version: '3.8'
162-
packages: python3-zmq qttools5-dev qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system1.74-dev libboost-filesystem1.74-dev libboost-chrono1.74-dev libboost-test1.74-dev libboost-thread1.74-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
162+
packages: python3-zmq qttools5-dev qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system1.74-dev libboost-filesystem1.74-dev libboost-chrono1.74-dev libboost-test1.74-dev libboost-thread1.74-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
163163
cc: gcc
164164
cxx: g++
165165

166166
- name: macOS
167167
os: macos-13
168168
python-version: '3.10'
169-
packages: llvm@14 autoconf automake berkeley-db@4 libtool boost miniupnpc libnatpmp pkg-config qt@5 zmq libevent qrencode gmp libsodium
169+
packages: autoconf automake libtool boost miniupnpc libnatpmp pkg-config qt@5 zmq libevent qrencode gmp libsodium
170170
boost_root: true
171-
cc: $(brew --prefix llvm@14)/bin/clang
172-
cxx: $(brew --prefix llvm@14)/bin/clang++
171+
cc: clang
172+
cxx: clang++
173173

174174
- name: macOS-latest
175175
os: macos-14
176176
python-version: '3.12'
177-
packages: llvm@14 autoconf automake berkeley-db@4 libtool boost miniupnpc libnatpmp pkg-config qt@5 zmq libevent qrencode gmp libsodium
177+
packages: autoconf automake libtool boost miniupnpc libnatpmp pkg-config qt@5 zmq libevent qrencode gmp libsodium
178178
boost_root: true
179-
cc: $(brew --prefix llvm@14)/bin/clang
180-
cxx: $(brew --prefix llvm@14)/bin/clang++
179+
cc: clang
180+
cxx: clang++
181181

182182
steps:
183183
- name: Get Source
@@ -195,9 +195,13 @@ jobs:
195195
sudo apt-get install --no-install-recommends --no-upgrade -qq "$APT_BASE" ${{ matrix.config.packages }}
196196
fi
197197
if [[ ${{ matrix.config.os }} = macos* ]]; then
198-
brew install "$APT_BASE" ${{ matrix.config.packages }}
198+
brew install -q "$APT_BASE" ${{ matrix.config.packages }}
199199
fi
200200
201+
- name: Install BerkeleyDB
202+
run: |
203+
sudo ./contrib/install_db4.sh /usr/local true
204+
201205
- name: Setup cmake
202206
uses: jwlawson/actions-setup-cmake@v2
203207
with:
@@ -227,18 +231,16 @@ jobs:
227231
fi
228232
if [ "${{ matrix.config.boost_root }}" = "true" ]; then
229233
export CI_BOOST=1
230-
if [ "${{ matrix.config.os }}" = "macos-14" ]; then
231-
export LDFLAGS="-L/opt/homebrew/opt/boost/lib"
232-
export CPPFLAGS="-I/opt/homebrew/opt/boost/include"
233-
else
234-
export CPPFLAGS="-I/usr/local/opt/boost/include -I/usr/local/opt/berkeley-db@4/include"
235-
export LDFLAGS="-L/usr/local/opt/boost/lib -L/usr/local/opt/berkeley-db@4/lib"
236-
fi
237234
fi
238235
fi
239236
export CC
240237
export CXX
241238
export PYTHON
239+
# workaround for macos runners not being able to properly test the native clang++ from within cmake
240+
if [[ ${{ matrix.config.os }} = macos* ]]; then
241+
./autogen.sh
242+
./configure
243+
fi
242244
mkdir -p ${{ github.workspace }}/cmake-build-debug && cd ${{ github.workspace }}/cmake-build-debug
243245
cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" ${{ github.workspace }}
244246
@@ -271,27 +273,27 @@ jobs:
271273
id: Linux-x86_64-nodepends
272274
os: ubuntu-22.04
273275
python-version: '3.8'
274-
packages: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
276+
packages: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
275277
unit_tests: true
276278
functional_tests: true
277279
goal: install
278-
BITCOIN_CONFIG: "--enable-zmq --enable-debug --with-incompatible-bdb --with-gui=qt5 CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER'"
280+
BITCOIN_CONFIG: "--enable-zmq --enable-debug --with-gui=qt5 CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER'"
279281

280282
- name: x64-Linux-latest
281283
id: Linux-x86_64-nodepends-latest
282284
os: ubuntu-24.04
283285
python-version: '3.8'
284-
packages: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system1.74-dev libboost-filesystem1.74-dev libboost-chrono1.74-dev libboost-test1.74-dev libboost-thread1.74-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
286+
packages: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system1.74-dev libboost-filesystem1.74-dev libboost-chrono1.74-dev libboost-test1.74-dev libboost-thread1.74-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
285287
unit_tests: true
286288
functional_tests: true
287289
goal: install
288-
BITCOIN_CONFIG: "--enable-zmq --enable-debug --with-incompatible-bdb --with-gui=qt5 CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER'"
290+
BITCOIN_CONFIG: "--enable-zmq --enable-debug --with-gui=qt5 CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER'"
289291

290292
- name: x64-macOS
291293
id: macOS-nodepends
292294
os: macos-13
293295
python-version: '3.10'
294-
packages: autoconf automake ccache berkeley-db@4 libtool boost miniupnpc libnatpmp pkg-config qt@5 zmq libevent qrencode gmp libsodium librsvg
296+
packages: autoconf automake ccache libtool boost miniupnpc libnatpmp pkg-config qt@5 zmq libevent qrencode gmp libsodium librsvg
295297
unit_tests: true
296298
functional_tests: true
297299
goal: deploy
@@ -303,7 +305,7 @@ jobs:
303305
id: macOS-nodepends-latest
304306
os: macos-14
305307
python-version: '3.12'
306-
packages: autoconf automake ccache berkeley-db@4 libtool boost miniupnpc libnatpmp pkg-config qt@5 zmq libevent qrencode gmp libsodium librsvg
308+
packages: autoconf automake ccache libtool boost miniupnpc libnatpmp pkg-config qt@5 zmq libevent qrencode gmp libsodium librsvg
307309
unit_tests: true
308310
functional_tests: true
309311
goal: deploy
@@ -327,10 +329,14 @@ jobs:
327329
sudo apt-get install --no-install-recommends --no-upgrade -qq "$APT_BASE" ${{ matrix.config.packages }}
328330
fi
329331
if [[ ${{ matrix.config.os }} = macos* ]]; then
330-
brew install ${{ matrix.config.packages }}
332+
brew install -q ${{ matrix.config.packages }}
331333
pip install ds_store mac_alias
332334
fi
333335
336+
- name: Install BerkeleyDB
337+
run: |
338+
sudo ./contrib/install_db4.sh /usr/local true
339+
334340
- name: ccache cache files
335341
uses: actions/cache@v4
336342
with:
@@ -438,25 +444,25 @@ jobs:
438444
id: Linux-x86_64-nodepends-tests
439445
os: ubuntu-22.04
440446
python-version: '3.8'
441-
packages: python3-zmq libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev
447+
packages: python3-zmq libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev
442448

443449
- name: x64-Linux-latest
444450
id: Linux-x86_64-nodepends-latest-tests
445451
os: ubuntu-24.04
446452
python-version: '3.8'
447-
packages: python3-zmq libevent-dev bsdmainutils libboost-system1.74-dev libboost-filesystem1.74-dev libboost-chrono1.74-dev libboost-test1.74-dev libboost-thread1.74-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev
453+
packages: python3-zmq libevent-dev bsdmainutils libboost-system1.74-dev libboost-filesystem1.74-dev libboost-chrono1.74-dev libboost-test1.74-dev libboost-thread1.74-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev
448454

449455
- name: x64-macOS
450456
id: macOS-nodepends
451457
os: macos-13
452458
python-version: '3.10'
453-
packages: berkeley-db@4 boost miniupnpc libnatpmp pkg-config zmq libevent qrencode gmp libsodium
459+
packages: boost miniupnpc libnatpmp pkg-config zmq libevent qrencode gmp libsodium
454460

455461
- name: arm64-macOS-latest
456462
id: macOS-nodepends-latest
457463
os: macos-14
458464
python-version: '3.12'
459-
packages: berkeley-db@4 boost miniupnpc libnatpmp pkg-config zmq libevent qrencode gmp libsodium
465+
packages: boost miniupnpc libnatpmp pkg-config zmq libevent qrencode gmp libsodium
460466

461467
steps:
462468
- name: Initialize Python
@@ -471,7 +477,7 @@ jobs:
471477
sudo apt-get install --no-install-recommends --no-upgrade -qq ${{ matrix.config.packages }}
472478
fi
473479
if [[ ${{ matrix.config.os }} = macos* ]]; then
474-
brew install ${{ matrix.config.packages }}
480+
brew install -q ${{ matrix.config.packages }}
475481
fi
476482
pip install pyzmq
477483

CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
3939
add_definitions("-DMAC_OSX")
4040
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D'NS_FORMAT_ARGUMENT\(A\)='")
4141
list(APPEND CMAKE_PREFIX_PATH /usr/local/opt/qt5 /usr/local/opt/qt@5 /opt/homebrew/opt/qt5 /opt/homebrew/opt/qt@5)
42-
list(APPEND CMAKE_PREFIX_PATH /usr/local/Cellar/berkeley-db@4 /opt/homebrew/Cellar/berkeley-db@4)
43-
# Homebrew default path for apple silicon CPUs is different than for intel CPUs
44-
if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm")
45-
set(BerkeleyDB_ROOT_DIR "/opt/homebrew/Cellar/berkeley-db@4/${BDB_VER}/")
46-
else()
47-
set(BerkeleyDB_ROOT_DIR "/usr/local/Cellar/berkeley-db@4/${BDB_VER}/" )
48-
endif()
42+
list(APPEND CMAKE_PREFIX_PATH /usr/local/Cellar/berkeley-db@4/${BDB_VER} /opt/homebrew/Cellar/berkeley-db@4/${BDB_VER})
4943
# Github Actions specific Boost override (macOS only)
5044
if(DEFINED ENV{CI_BOOST})
5145
if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm")

configure.ac

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,13 @@ case $host in
570570
dnl It's safe to add these paths even if the functionality is disabled by
571571
dnl the user (--without-wallet or --without-gui for example).
572572

573-
bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null`
574573
qt5_prefix=`$BREW --prefix qt5 2>/dev/null`
575574
gmp_prefix=`$BREW --prefix gmp 2>/dev/null`
576-
if test x$bdb_prefix != x; then
577-
CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include"
578-
LIBS="$LIBS -L$bdb_prefix/lib"
575+
if $BREW list --versions berkeley-db@4 >/dev/null && test "x$BDB_CFLAGS" = "x" && test "x$BDB_LIBS" = "x"; then
576+
bdb_prefix=$($BREW --prefix berkeley-db@4 2>/dev/null)
577+
dnl This must precede the call to BITCOIN_FIND_BDB48 below.
578+
BDB_CFLAGS="-I$bdb_prefix/include"
579+
BDB_LIBS="-L$bdb_prefix/lib -ldb_cxx-4.8"
579580
fi
580581
if test x$qt5_prefix != x; then
581582
PKG_CONFIG_PATH="$qt5_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"

contrib/cmake/FindBerkeleyDB.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ else()
2929
list(APPEND _BERKELEYDB_PATHS
3030
"/usr/local/Cellar/berkeley-db@4"
3131
"/usr/local/Cellar/berkeley-db"
32+
"/opt/homebrew/Cellar/berkeley-db@4"
33+
"/opt/homebrew/Cellar/berkeley-db"
3234
"/opt"
3335
"/opt/local"
3436
"/usr/local"

contrib/install_db4.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export LC_ALL=C
66
set -e
77

88
if [ -z "${1}" ]; then
9-
echo "Usage: $0 <base-dir> [<extra-bdb-configure-flag> ...]"
9+
echo "Usage: $0 <base-dir> [<ci-mode>] [<extra-bdb-configure-flag> ...]"
1010
echo
1111
echo "Must specify a single argument: the directory in which db4 will be built."
1212
echo "This is probably \`pwd\` if you're at the root of the pivx repository."
@@ -17,7 +17,15 @@ expand_path() {
1717
cd "${1}" && pwd -P
1818
}
1919

20-
BDB_PREFIX="$(expand_path ${1})/db4"; shift;
20+
if [ "$#" -ge 2 ]; then
21+
if [ "${2}" != 'true' ]; then
22+
BDB_PREFIX="$(expand_path ${1})/db4"; shift;
23+
echo "Installing in user mode..."
24+
else
25+
BDB_PREFIX="$(expand_path ${1})"; shift; shift;
26+
echo "Installing in CI mode..."
27+
fi
28+
fi
2129
BDB_VERSION='db-4.8.30.NC'
2230
BDB_HASH='12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef'
2331
BDB_URL="https://download.oracle.com/berkeley-db/${BDB_VERSION}.tar.gz"
@@ -61,7 +69,7 @@ http_get() {
6169

6270
mkdir -p "${BDB_PREFIX}"
6371
http_get "${BDB_URL}" "${BDB_VERSION}.tar.gz" "${BDB_HASH}"
64-
tar -xzvf ${BDB_VERSION}.tar.gz -C "$BDB_PREFIX"
72+
tar -xzf ${BDB_VERSION}.tar.gz -C "$BDB_PREFIX"
6573
cd "${BDB_PREFIX}/${BDB_VERSION}/"
6674

6775
# Apply a patch necessary when building with clang and c++11 (see https://community.oracle.com/thread/3952592)
@@ -70,13 +78,18 @@ CLANG_CXX11_PATCH_HASH='7a9a47b03fd5fb93a16ef42235fa9512db9b0829cfc3bdf90edd3ec1
7078
http_get "${CLANG_CXX11_PATCH_URL}" clang.patch "${CLANG_CXX11_PATCH_HASH}"
7179
patch -p2 < clang.patch
7280

81+
BIGSUR_PATCH_URL='https://gist.githubusercontent.com/Fuzzbawls/51f8cc35e03d18f35b82e7b36e66491d/raw/d57f6731def206db65191932f5ae7016a325fde5/configure-pre-0.4.2.418-big_sur.diff'
82+
BIGSUR_PATCH_HASH='83af02f2aa2b746bb7225872cab29a253264be49db0ecebb12f841562d9a2923'
83+
http_get "${BIGSUR_PATCH_URL}" bigsur.patch "${BIGSUR_PATCH_HASH}"
84+
patch dist/configure < bigsur.patch
85+
7386
# The packaged config.guess and config.sub are ancient (2009) and can cause build issues.
7487
# Replace them with modern versions.
7588
# See https://github.com/bitcoin/bitcoin/issues/16064
76-
CONFIG_GUESS_URL='https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=55eaf3e779455c4e5cc9f82efb5278be8f8f900b'
77-
CONFIG_GUESS_HASH='2d1ff7bca773d2ec3c6217118129220fa72d8adda67c7d2bf79994b3129232c1'
78-
CONFIG_SUB_URL='https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=55eaf3e779455c4e5cc9f82efb5278be8f8f900b'
79-
CONFIG_SUB_HASH='3a4befde9bcdf0fdb2763fc1bfa74e8696df94e1ad7aac8042d133c8ff1d2e32'
89+
CONFIG_GUESS_URL='https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=00b15927496058d23e6258a28d8996f87cf1f191'
90+
CONFIG_GUESS_HASH='e3d148130e9151735f8b9a8e69a70d06890ece51468a9762eb7ac0feddddcc2f'
91+
CONFIG_SUB_URL='https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=00b15927496058d23e6258a28d8996f87cf1f191'
92+
CONFIG_SUB_HASH='11c54f55c3ac99e5d2c3dc2bb0bcccbf69f8223cc68f6b2438daa806cf0d16d8'
8093

8194
rm -f "dist/config.guess"
8295
rm -f "dist/config.sub"
@@ -86,7 +99,7 @@ http_get "${CONFIG_SUB_URL}" dist/config.sub "${CONFIG_SUB_HASH}"
8699

87100
cd build_unix/
88101

89-
"${BDB_PREFIX}/${BDB_VERSION}/dist/configure" \
102+
CFLAGS="-Wno-error=implicit-function-declaration" "${BDB_PREFIX}/${BDB_VERSION}/dist/configure" \
90103
--enable-cxx --disable-shared --disable-replication --with-pic --prefix="${BDB_PREFIX}" \
91104
"${@}"
92105

0 commit comments

Comments
 (0)