Skip to content

Commit

Permalink
Merge pull request #252 from cculianu/cpp20
Browse files Browse the repository at this point in the history
Switch to C++20, RocksDB to 9.1.1, update docker images, GCC to 13.x, jemalloc to 5.3.0, and other misc fixups + bump version to 1.11.0
  • Loading branch information
cculianu authored May 23, 2024
2 parents f4e8e9a + c3711aa commit 4db19aa
Show file tree
Hide file tree
Showing 124 changed files with 15,116 additions and 4,664 deletions.
62 changes: 32 additions & 30 deletions Fulcrum.pro
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ load(configure)
QT -= gui
QT += network

CONFIG += c++17 console warn_on
versionAtLeast(QT_VERSION, 6.5.0) {
CONFIG += c++20
} else {
# Old alias for C++20 was "c++2a"
CONFIG += c++2a
}
CONFIG += console warn_on
CONFIG -= app_bundle

versionAtMost(QT_VERSION, 5.12.4) {
error("Fulcrum requires Qt 5.12.5 (or later) or Qt 5.13.1 (or later) to be successfully built without errors. Please use Qt 5.12.5+ or Qt 5.13.1+ to build this codebase.")
versionAtMost(QT_VERSION, 5.15.1) {
error("Fulcrum requires Qt 5.15.2 (or later) to be successfully built without errors. Please use Qt 5.15.2+ to build this codebase.")
}

QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
Expand Down Expand Up @@ -87,7 +93,6 @@ win32 {
CONFIG += warn_off
}
linux {
QMAKE_CXXFLAGS += -std=c++1z
DEFINES += HAVE_ENDIAN_H HAVE_DECL_HTOBE16 HAVE_DECL_HTOLE16 HAVE_DECL_BE16TOH HAVE_DECL_LE16TOH HAVE_DECL_HTOBE32 \
HAVE_DECL_HTOLE32 HAVE_DECL_BE32TOH HAVE_DECL_LE32TOH HAVE_DECL_HTOBE64 HAVE_DECL_HTOLE64 HAVE_DECL_BE64TOH \
HAVE_DECL_LE64TOH
Expand All @@ -97,7 +102,6 @@ linux-g++ {
CONFIG += warn_off
}
freebsd {
QMAKE_CXXFLAGS += -std=c++1z
DEFINES += HAVE_SYS_ENDIAN_H HAVE_DECL_HTOBE16 HAVE_DECL_HTOLE16 HAVE_DECL_BE16TOH HAVE_DECL_LE16TOH HAVE_DECL_HTOBE32 \
HAVE_DECL_HTOLE32 HAVE_DECL_BE32TOH HAVE_DECL_LE32TOH HAVE_DECL_HTOBE64 HAVE_DECL_HTOLE64 HAVE_DECL_BE64TOH \
HAVE_DECL_LE64TOH
Expand Down Expand Up @@ -182,42 +186,40 @@ contains(CONFIG, config_endian_big) {
#
# Currently this was built from github sources of the v6.14.6 rocksdb release:
# https://github.com/facebook/rocksdb.git
# Commit tag v6.14.6, commit hash (from Tue Dec 1 15:05:35 2020 -0800):
# ed4316166f67ec892603014634840d29f460f611
# Commit tag v9.1.1, commit hash (from Mon Apr 22 11:35:44 2024 -0700):
# 6f7cabeac80a3a6150be2c8a8369fcecb107bf43
#
# OSX:
# Built on Apple clang version 11.0.0 (clang-1100.0.33.17), from Xcode 113.1.
# command: USE_RTTI=1 PORTABLE=1 DEBUG_LEVEL=0 make static_lib -j4 V=1
# Annoyingly, the produced .a file has debug symbols which we strip with: strip -S.
# Built on Apple clang version 15.0.0 (clang-1500.3.9.4), from Xcode 15.4.
# x86_64 (native build) command:
# USE_RTTI=1 PORTABLE=1 DEBUG_LEVEL=0 make static_lib -j8 V=1
# arm64 (cross-compile) command:
# ARCHFLAG="-arch arm64" EXTRA_LDFLAGS="-target arm64-apple-darwin" USE_RTTI=1 PORTABLE=1 DEBUG_LEVEL=0 make static_lib -j8 V=1
# Annoyingly, the produced .a file has debug symbols which we strip with:
# strip -S librocksdb.a
# For each of the platforms above, the produced `librocksdb.a` is saved and then `lipo` is used to create a
# "universal" fat binary:
# lipo -create librocksdb.a.x86 librocksdb.a.arm64 -output librocksdb.a
#
# Linux (x86_64):
# Built on Ubuntu 18.04.6 LTS, g++ (8.4.0-1ubuntu1~18.04) 8.4.0.
# command: USE_RTTI=1 PORTABLE=1 DEBUG_LEVEL=0 make static_lib -j8 V=1
# Annoyingly, the produced .a file has debug symbols which we strip with: strip -g.
#
# Linux:
# Built on Ubuntu 18.10, g++ (Ubuntu 8.2.0-7ubuntu1) 8.2.0.
# command: USE_RTTI=1 PORTABLE=1 DEBUG_LEVEL=0 make static_lib -j4 V=1
# Linux (aarch64):
# Built on Ubuntu 20.04.6 LTS, g++ (9.4.0-1ubuntu1~20.04.2) 9.4.0.
# command: USE_RTTI=1 PORTABLE=1 DEBUG_LEVEL=0 make static_lib -j8 V=1
# Annoyingly, the produced .a file has debug symbols which we strip with: strip -g.
#
# Windows:
# Built using the MinGW G++ 8.1.0 (compiler that ships with Qt 5.15+), from a cmd.exe prompt, via cmake.exe by
# Built using the MinGW G++ 14.1.0 from MSYS2 using a MINGW shell.
# following these steps:
# - Install a recent cmake into eg c:\cmake
# - Open up a Qt cmd.exe prompt that points to MinGW G++ 8.1.0 in the path (using the Start menu shortcut
# installed by Qt 5.15+ is easiest).
# - Put installed 'c:\cmake\bin' in the path so that 'cmake.exe' works from the cmd prompt, eg:
# set PATH=c:\cmake\bin;%PATH%
# - Checkout rocksdb (commit hash above), cd rocksdb
# - Now you will need to edit CMakeLists.txt:
# 1. Open CMakeLists.txt in a text editor
# 2. Search for '-fno-asynchronous-unwind-tables' and remove that compile option since it
# breaks building on MinGW against Qt, and replace it with -O3 for maximal speed.
# 3. In that same MINGW section where you removed the above, add: '-Wno-cast-function-type -Wno-error=cast-function-type'
# since MinGW 8.1 seems to not like the function pointer casts in port/win/env_win.cc.
# 4. Look for a section that contains 'if(NOT MINGW' and rename MINGW to XX_MINGW:
# if(NOT XX_MINGW)
# This ensures that port/win/win_thread.cc does get compiled and linked into the lib.
# - mkdir build, cd build
# - Run this command from within the rocksdb/build dir that you just created:
# cmake .. -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_SYSTEM_NAME=Windows -G"MinGW Makefiles" -DWITH_GFLAGS=0 -DWITH_JNI=0 -DCMAKE_BUILD_TYPE=Release -DUSE_RTTI=1 -DPORTABLE=1
# cmake .. -GNinja -DWITH_GFLAGS=0 -DWITH_JNI=0 -DCMAKE_BUILD_TYPE=Release -DUSE_RTTI=1 -DPORTABLE=1 -DROCKSDB_BUILD_SHARED=OFF -DWITH_LIBURING=OFF
# - Build with this command:
# mingw32-make -j4 V=1 rocksdb <-- will build static lib only
# ninja rocksdb <-- will build static lib only
# The generated librocksdb.a will be in the build/ directory you are currently in, ready to be put into the
# Fulcrum directory staticlibs/rocksdb/bin/win64.
macx {
Expand Down
4 changes: 3 additions & 1 deletion contrib/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ case "$plat" in
suffix="_ub20"
;;
"linux_ub16"|"oldlinux"|"oldlin"|"lin_ub16")
fail "${plat} is no longer supported after the upgrade to C++20. Please use one of the other options: windows, linux, linux_ub20, linux_ub22"
# Below is not reached
[ -z "$arch_arg" ] || fail "Cannot use platform \"$plat\" with \"$arch\""
plat=linux
docker_img_name="fulcrum-builder/qt:linux_ub16"
docker_cont_name="fulcrum_cont_qt_linux_ub16_$$"
suffix="_ub16"
;;
*)
fail "Unknown platform \"$plat\". Please specify one of: windows linux linux_ub22 linux_ub16"
fail "Unknown platform \"$plat\". Please specify one of: windows linux linux_ub22 linux_ub20 linux_ub16"
;;
esac

Expand Down
17 changes: 14 additions & 3 deletions contrib/build/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@ RUN \
apt -qy upgrade && \
apt -qy install build-essential cmake gdb git iputils-ping nano perl python valgrind wget autoconf && \
apt -qy install libbz2-dev zlib1g-dev libssl-dev libnss3-dev libxslt-dev libxml2-dev && \
apt -qy install gcc-8 g++-8 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 \
--slave /usr/bin/g++ g++ /usr/bin/g++-8 && \
apt -qy autoremove && \
apt -qy autoclean

RUN \
apt -qy install software-properties-common && \
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
apt -qy update && \
apt -qy install gcc-13 g++-13 cpp-13 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 131 \
--slave /usr/bin/g++ g++ /usr/bin/g++-13 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-13 && \
apt -qy autoremove && \
apt -qy autoclean

# Ensure we statically link libstdc++ otherwise produced binaries won't be compatible with stock systems
ENV LDFLAGS="-static-libstdc++"

RUN \
mkdir -p /opt/local/qt && \
cd /opt && \
Expand Down
14 changes: 14 additions & 0 deletions contrib/build/linux/Dockerfile_ub20
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ RUN \
apt -qy autoremove && \
apt -qy autoclean

RUN \
apt -qy install software-properties-common && \
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
apt -qy update && \
apt -qy install gcc-13 g++-13 cpp-13 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 131 \
--slave /usr/bin/g++ g++ /usr/bin/g++-13 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-13 && \
apt -qy autoremove && \
apt -qy autoclean

# Ensure we statically link libstdc++ otherwise produced binaries won't be compatible with stock systems
ENV LDFLAGS="-static-libstdc++"

RUN \
mkdir -p /opt/local/qt && \
cd /opt && \
Expand Down
14 changes: 14 additions & 0 deletions contrib/build/linux/Dockerfile_ub22
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ RUN \
apt -qy autoremove && \
apt -qy autoclean

RUN \
apt -qy install software-properties-common && \
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
apt -qy update && \
apt -qy install gcc-13 g++-13 cpp-13 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 131 \
--slave /usr/bin/g++ g++ /usr/bin/g++-13 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-13 && \
apt -qy autoremove && \
apt -qy autoclean

# Ensure we statically link libstdc++ otherwise produced binaries won't be compatible with stock systems
ENV LDFLAGS="-static-libstdc++"

RUN \
mkdir -p /opt/local/qt && \
cd /opt && \
Expand Down
9 changes: 8 additions & 1 deletion contrib/build/linux/_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cd "$top" || fail "Could not cd $top"

# libzmq
pushd /tmp
LIBZMQ_COMMIT=c89390f0f5a17370627d0e856f906e8e9c7984e4 # Note: match the commit used on Windows build
LIBZMQ_COMMIT=622fc6dde99ee172ebaa9c8628d85a7a1995a21d # v4.3.5 release
info "Cloning libzmq ..."
git clone https://github.com/zeromq/libzmq.git || fail "Could not clone libzmq"
cd libzmq && git checkout ${LIBZMQ_COMMIT} && cd .. || fail "Coult not checkout commit hash: ${LIBZMQ_COMMIT}"
Expand Down Expand Up @@ -83,8 +83,15 @@ fi

info "Building Fulcrum ..."
mkdir build && cd build || fail "Could not create/change-to build/"
if [ -n "${LDFLAGS}" ]; then
# For things like -static-libstdc++, etc
extra_libs="LIBS+=${LDFLAGS}"
else
extra_libs=""
fi
qmake ../Fulcrum.pro "CONFIG-=debug" \
"CONFIG+=release" \
"${extra_libs}" \
"LIBS+=-L${ROCKSDB_LIBDIR} -lrocksdb" \
"LIBS+=-lz -lbz2" \
"INCLUDEPATH+=${ROCKSDB_INCDIR}" \
Expand Down
2 changes: 1 addition & 1 deletion contrib/build/linux/jemalloc-commit-hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ea6b3e973b477b8061e0076bb257dbd7f3faa756
54eaed1d8b56b1aa528be3bdd1877e59c56fa90c
2 changes: 1 addition & 1 deletion contrib/build/linux/rocksdb-commit-hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ed4316166f67ec892603014634840d29f460f611
6f7cabeac80a3a6150be2c8a8369fcecb107bf43
37 changes: 0 additions & 37 deletions contrib/build/linux/rocksdb.patch

This file was deleted.

17 changes: 8 additions & 9 deletions contrib/build/win/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# Example usage:
# $ docker build --force-rm -t fulcrum-builder/qt:windows .
# $ docker run --rm -it -v $(pwd):/work fulcrum-builder/qt:windows
FROM ubuntu:bionic
FROM ubuntu:focal
LABEL maintainer="Calin Culianu <[email protected]>"
ENV DEBIAN_FRONTEND=noninteractive
ENTRYPOINT ["/bin/bash"]

RUN \
Expand All @@ -13,7 +14,7 @@ apt -y install build-essential iputils-ping nano \
autoconf automake autopoint bash bison bzip2 flex gettext \
git g++ gperf intltool libffi-dev libgdk-pixbuf2.0-dev \
libtool-bin libltdl-dev libssl-dev libxml-parser-perl lzip make \
openssl p7zip-full patch perl pkg-config python ruby scons \
openssl p7zip-full patch perl pkg-config python python3-mako python3-setuptools python3-packaging ruby scons \
sed unzip wget xz-utils \
g++-multilib libc6-dev-i386 && \
apt -y autoremove && \
Expand All @@ -23,10 +24,10 @@ apt -y clean
RUN \
cd /opt && \
echo "💬 \033[1;36mCloning MXE repository ...\033[0m" && \
git clone https://github.com/mxe/mxe.git && cd mxe && git checkout fc6f4f5fb134ed65b6a2ed87b40a24233bb742bd && cd .. && \
git clone https://github.com/mxe/mxe.git && cd mxe && git checkout 56145fe67338e5b5bb39dd84ec3f4155b3751d2b && cd .. && \
echo "💬 \033[1;36mBuilding dependencies for static linking ...\033[0m" && \
cd /opt/mxe && \
echo 'override MXE_PLUGIN_DIRS += plugins/gcc11' >> settings.mk && \
echo 'override MXE_PLUGIN_DIRS += plugins/gcc13' >> settings.mk && \
NPROC=$(($(nproc))) && \
make --jobs=$NPROC JOBS=$NPROC MXE_TARGETS='x86_64-w64-mingw32.static' qtbase && \
ln -s /opt/mxe/usr/bin/x86_64-w64-mingw32.static-qmake-qt5 /usr/bin/qmake
Expand All @@ -38,7 +39,7 @@ RUN \
make --jobs=$NPROC JOBS=$NPROC MXE_TARGETS='x86_64-w64-mingw32.static' libzmq

# This bit taken from Electron Cash's Windows build Dockerfile -- requires
# Ubuntu bionic (which is 18.04 LTS). If we decide to upgrade the base Ubuntu
# Ubuntu focal (which is 20.04 LTS). If we decide to upgrade the base Ubuntu
# tag at the top of this file, then this will just need slight modification.
RUN \
apt -y update && \
Expand All @@ -56,10 +57,8 @@ RUN \
dpkg --add-architecture i386 && \
apt-get update -q && \
apt-get install -qy \
wine-stable-amd64:amd64=4.0.3~bionic \
wine-stable-i386:i386=4.0.3~bionic \
wine-stable:amd64=4.0.3~bionic \
winehq-stable:amd64=4.0.3~bionic
wine-stable \
winehq-stable

# Just print versions of everything at the end
RUN \
Expand Down
2 changes: 1 addition & 1 deletion contrib/build/win/jemalloc-commit-hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ea6b3e973b477b8061e0076bb257dbd7f3faa756
54eaed1d8b56b1aa528be3bdd1877e59c56fa90c
2 changes: 1 addition & 1 deletion contrib/build/win/rocksdb-commit-hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ed4316166f67ec892603014634840d29f460f611
6f7cabeac80a3a6150be2c8a8369fcecb107bf43
55 changes: 0 additions & 55 deletions contrib/build/win/rocksdb.patch

This file was deleted.

2 changes: 1 addition & 1 deletion contrib/rpm/fulcrum.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: {{{ git_repo_name name="fulcrum" }}}
Version: 1.10.0
Version: 1.11.0
Release: {{{ git_repo_version }}}%{?dist}
Summary: A fast & nimble SPV server for Bitcoin Cash & Bitcoin BTC

Expand Down
4 changes: 2 additions & 2 deletions doc/unix-man-page.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% FULCRUM(1) Version 1.10.0 | Fulcrum Manual
% FULCRUM(1) Version 1.11.0 | Fulcrum Manual
% Fulcrum is written by Calin Culianu (cculianu)
% March 01, 2024
% May 23, 2024

# NAME

Expand Down
Loading

0 comments on commit 4db19aa

Please sign in to comment.