diff --git a/README.md b/README.md index b1a7cbbbf..f2079a4f1 100644 --- a/README.md +++ b/README.md @@ -106,19 +106,32 @@ apt-get install -y gcc-7 g++-7 && \ # Build on Mac -``` -sudo port update -sudo port upgrade outdated -sudo port install qt5 +Install Xcode Command Line Tools and [Homebrew](https://brew.sh/), then install dependencies: + +```sh +xcode-select --install +brew install gcc autoconf automake pkgconf libtool cmake curl + +# Install Rust (needed for librustzcash on macOS Sequoia+) +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +source "$HOME/.cargo/env" # clone git repo git clone https://git.hush.is/hush/hush3 cd hush3 -# Build -# This uses 3 build processes, you need 2GB of RAM for each. +# Build (uses 3 build processes, you need 2GB of RAM for each) +# Make sure libtool gnubin and cargo are on PATH +export PATH="$HOME/.cargo/bin:/usr/local/opt/libtool/libexec/gnubin:$PATH" ./build.sh -j3 ``` +For a release build: + +```sh +export PATH="$HOME/.cargo/bin:/usr/local/opt/libtool/libexec/gnubin:$PATH" +./build.sh --mac-release -j$(sysctl -n hw.ncpu) +``` + # Installing Hush binaries 1. [Download the release](https://git.hush.is/hush/hush3/releases) with a .deb file extension. diff --git a/build.sh b/build.sh index 2ad3722e3..52fb7f4d3 100755 --- a/build.sh +++ b/build.sh @@ -175,21 +175,21 @@ if [ $BUILD_LINUX_COMPAT -eq 1 ] || [ $BUILD_LINUX_RELEASE -eq 1 ] || [ $BUILD_W if [ $BUILD_LINUX_RELEASE -eq 1 ]; then echo "=== Building Linux release ===" clean_for_platform linux - ./util/build.sh --disable-tests "${REMAINING_ARGS[@]}" + ./util/build.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"} package_release linux-amd64 fi if [ $BUILD_WIN_RELEASE -eq 1 ]; then echo "=== Building Windows release ===" clean_for_platform windows - ./util/build-win.sh --disable-tests "${REMAINING_ARGS[@]}" + ./util/build-win.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"} package_release win64 fi if [ $BUILD_MAC_RELEASE -eq 1 ]; then echo "=== Building macOS release ===" clean_for_platform macos - ./util/build-mac.sh --disable-tests "${REMAINING_ARGS[@]}" + ./util/build-mac.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"} package_release macos fi @@ -201,11 +201,11 @@ fi # Standard build (auto-detect OS) if [[ "$OSTYPE" == "linux-gnu"* ]]; then - ./util/build.sh --disable-tests "${REMAINING_ARGS[@]}" + ./util/build.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"} elif [[ "$OSTYPE" == "darwin"* ]]; then - ./util/build-mac.sh --disable-tests "${REMAINING_ARGS[@]}" + ./util/build-mac.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"} elif [[ "$OSTYPE" == "msys"* ]]; then - ./util/build-win.sh --disable-tests "${REMAINING_ARGS[@]}" + ./util/build-win.sh --disable-tests ${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"} else echo "Unable to detect your OS. What are you using?" fi diff --git a/depends/builders/darwin.mk b/depends/builders/darwin.mk index cbbc5a667..4c366d8de 100644 --- a/depends/builders/darwin.mk +++ b/depends/builders/darwin.mk @@ -1,5 +1,5 @@ -build_darwin_CC = gcc-8 -build_darwin_CXX = g++-8 +build_darwin_CC = gcc-15 +build_darwin_CXX = g++-15 build_darwin_AR: = $(shell xcrun -f ar) build_darwin_RANLIB: = $(shell xcrun -f ranlib) build_darwin_STRIP: = $(shell xcrun -f strip) @@ -10,8 +10,8 @@ build_darwin_SHA256SUM = shasum -a 256 build_darwin_DOWNLOAD = curl --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -L -f -o #darwin host on darwin builder. overrides darwin host preferences. -darwin_CC= gcc-8 -darwin_CXX= g++-8 +darwin_CC= gcc-15 +darwin_CXX= g++-15 darwin_AR:=$(shell xcrun -f ar) darwin_RANLIB:=$(shell xcrun -f ranlib) darwin_STRIP:=$(shell xcrun -f strip) diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index 7be744aeb..fb5e7323c 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -2,8 +2,8 @@ OSX_MIN_VERSION=10.12 OSX_SDK_VERSION=10.12 OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk LD64_VERSION=253.9 -darwin_CC=gcc-8 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -darwin_CXX=g++-8 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +darwin_CC=gcc-15 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +darwin_CXX=g++-15 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) darwin_CFLAGS=-pipe darwin_CXXFLAGS=$(darwin_CFLAGS) diff --git a/depends/packages/librustzcash.mk b/depends/packages/librustzcash.mk index fe6ef8a58..cc3e95077 100644 --- a/depends/packages/librustzcash.mk +++ b/depends/packages/librustzcash.mk @@ -41,7 +41,7 @@ define $(package)_preprocess_cmds endef define $(package)_build_cmds - $(host_prefix)/native/bin/cargo build --package librustzcash $($(package)_build_opts) + CARGO=$(HOME)/.cargo/bin/cargo RUSTC=$(HOME)/.cargo/bin/rustc $(HOME)/.cargo/bin/cargo build --package librustzcash $($(package)_build_opts) endef define $(package)_stage_cmds diff --git a/depends/strip-rlib-metadata.sh b/depends/strip-rlib-metadata.sh new file mode 100755 index 000000000..94c337185 --- /dev/null +++ b/depends/strip-rlib-metadata.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# Strip rust.metadata.bin from .rlib archives for macOS linker compatibility +RLIB_DIR="$1" +if [ -d "$RLIB_DIR" ]; then + for rlib in "$RLIB_DIR"/*.rlib; do + [ -f "$rlib" ] && ar d "$rlib" rust.metadata.bin 2>/dev/null || true + done +fi diff --git a/src/Makefile.am b/src/Makefile.am index 429f761cb..745921542 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -594,7 +594,7 @@ libzcash_a_CPPFLAGS = -DMULTICORE -fopenmp -fPIC -DBOOST_SPIRIT_THREADSAFE -DHAV #libzcash_a_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) #libzcash_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DMONTGOMERY_OUTPUT -libzcash_a_CXXFLAGS = $(SAN_CXXFLAGS) $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing -std=gnu17 +libzcash_a_CXXFLAGS = $(SAN_CXXFLAGS) $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing -std=gnu++17 libzcash_a_LDFLAGS = $(SAN_LDFLAGS) $(HARDENED_LDFLAGS) libzcash_a_CPPFLAGS += -DMONTGOMERY_OUTPUT @@ -636,7 +636,7 @@ libhush_a_SOURCES = \ libhush_a_CPPFLAGS = -DMULTICORE -fopenmp -fPIC -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS $(HARDENED_CPPFLAGS) -pipe -O1 -g -Wstack-protector -fstack-protector-all -fPIE -fvisibility=hidden -DSTATIC $(BITCOIN_INCLUDES) -libhush_a_CXXFLAGS = $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing -std=gnu17 +libhush_a_CXXFLAGS = $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing -std=gnu++17 libhush_a_LDFLAGS = $(HARDENED_LDFLAGS) diff --git a/src/cc/Makefile_custom b/src/cc/Makefile_custom index d3ecf9c25..ec27f6283 100644 --- a/src/cc/Makefile_custom +++ b/src/cc/Makefile_custom @@ -1,5 +1,5 @@ SHELL = /bin/sh -CC_DARWIN = g++-8 +CC_DARWIN = g++-15 CC_WIN = x86_64-w64-mingw32-gcc-posix CC_AARCH64 = aarch64-linux-gnu-g++ CFLAGS_DARWIN = -DBUILD_CUSTOMCC -std=c++11 -arch x86_64 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../leveldb/include -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib diff --git a/src/cc/customcc.dylib b/src/cc/customcc.dylib new file mode 100644 index 000000000..dc1730032 Binary files /dev/null and b/src/cc/customcc.dylib differ diff --git a/src/compat/glibcxx_sanity.cpp b/src/compat/glibcxx_sanity.cpp index cb335c090..29acc1f86 100644 --- a/src/compat/glibcxx_sanity.cpp +++ b/src/compat/glibcxx_sanity.cpp @@ -47,7 +47,7 @@ bool sanity_test_range_fmt() { std::string test; try { - test.at(1); + (void)test.at(1); } catch (const std::out_of_range&) { return true; } catch (...) { diff --git a/src/leveldb/port/atomic_pointer.h b/src/leveldb/port/atomic_pointer.h index 9bf091f75..fae82ea87 100644 --- a/src/leveldb/port/atomic_pointer.h +++ b/src/leveldb/port/atomic_pointer.h @@ -51,8 +51,9 @@ namespace port { // Mac OS #elif defined(OS_MACOSX) +#include inline void MemoryBarrier() { - OSMemoryBarrier(); + std::atomic_thread_fence(std::memory_order_seq_cst); } #define LEVELDB_HAVE_MEMORY_BARRIER diff --git a/src/libcc.dylib b/src/libcc.dylib new file mode 100644 index 000000000..dc1730032 Binary files /dev/null and b/src/libcc.dylib differ diff --git a/src/net.cpp b/src/net.cpp index efac15c12..c6ddb54a8 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -33,6 +33,8 @@ #include "crypto/common.h" #include "hush/utiltls.h" #include +#include +#include #ifdef _WIN32 #include #else @@ -2004,7 +2006,7 @@ void ThreadMessageHandler() // Randomize the order in which we process messages from/to our peers. // This prevents attacks in which an attacker exploits having multiple // consecutive connections in the vNodes list. - random_shuffle(vNodesCopy.begin(), vNodesCopy.end(), GetRandInt); + std::shuffle(vNodesCopy.begin(), vNodesCopy.end(), std::mt19937(GetRand(std::numeric_limits::max()))); BOOST_FOREACH(CNode* pnode, vNodesCopy) { @@ -2516,7 +2518,7 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss) // We always round down, except when we have only 1 connection auto newSize = (vNodes.size() / 2) == 0 ? 1 : (vNodes.size() / 2); - random_shuffle( vRelayNodes.begin(), vRelayNodes.end(), GetRandInt ); + std::shuffle( vRelayNodes.begin(), vRelayNodes.end(), std::mt19937(GetRand(std::numeric_limits::max())) ); vRelayNodes.resize(newSize); if (HUSH_TESTNODE==1 && vNodes.size() == 0) { diff --git a/src/transaction_builder.cpp b/src/transaction_builder.cpp index 10f2383e5..b3d8ac758 100644 --- a/src/transaction_builder.cpp +++ b/src/transaction_builder.cpp @@ -11,6 +11,8 @@ #include #include #include "zcash/Note.hpp" +#include +#include extern bool fZDebug; SpendDescriptionInfo::SpendDescriptionInfo( @@ -66,7 +68,7 @@ void TransactionBuilder::AddSaplingOutput( void TransactionBuilder::ShuffleOutputs() { LogPrintf("%s: Shuffling %d zouts\n", __func__, outputs.size() ); - random_shuffle( outputs.begin(), outputs.end(), GetRandInt ); + std::shuffle( outputs.begin(), outputs.end(), std::mt19937(GetRand(std::numeric_limits::max())) ); } void TransactionBuilder::AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value, uint32_t _nSequence) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 31a266533..7308d7007 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -39,6 +39,8 @@ #include "coins.h" #include "wallet/asyncrpcoperation_saplingconsolidation.h" #include "wallet/asyncrpcoperation_sweep.h" +#include +#include #include "zcash/zip32.h" #include "cc/CCinclude.h" #include @@ -3416,7 +3418,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int vector > > vValue; CAmount nTotalLower = 0; - random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); + std::shuffle(vCoins.begin(), vCoins.end(), std::mt19937(GetRand(std::numeric_limits::max()))); BOOST_FOREACH(const COutput &output, vCoins) { diff --git a/util/build-mac.sh b/util/build-mac.sh index 745a72238..7acd2337a 100755 --- a/util/build-mac.sh +++ b/util/build-mac.sh @@ -3,8 +3,8 @@ # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html -export CC=gcc-8 -export CXX=g++-8 +export CC=gcc-15 +export CXX=g++-15 export LIBTOOL=libtool export AR=ar export RANLIB=ranlib @@ -34,16 +34,24 @@ fi # If --enable-lcov is the first argument, enable lcov coverage support: LCOV_ARG='' HARDENING_ARG='--disable-hardening' +TEST_ARG='' if [ "x${1:-}" = 'x--enable-lcov' ] then LCOV_ARG='--enable-lcov' HARDENING_ARG='--disable-hardening' shift +elif [ "x${1:-}" = 'x--disable-tests' ] +then + TEST_ARG='--enable-tests=no' + shift fi TRIPLET=`./depends/config.guess` PREFIX="$(pwd)/depends/$TRIPLET" +# Ensure system Rust is in PATH for modern macOS compatibility +export PATH="$HOME/.cargo/bin:$PATH" + make "$@" -C ./depends/ V=1 NO_QT=1 #BUILD CCLIB @@ -68,7 +76,7 @@ cd $WD ./autogen.sh CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -Wl,-no_pie" \ -CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc\@8/8.3.0/include/c++/8.3.0/ -I$PREFIX/include -fwrapv -fno-strict-aliasing -Wno-builtin-declaration-mismatch -Werror -g -Wl,-undefined -Wl,dynamic_lookup' \ -./configure --prefix="${PREFIX}" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG" +CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc/15.2.0_1/include/c++/15/ -I$PREFIX/include -fwrapv -fno-strict-aliasing -Wno-builtin-declaration-mismatch -Werror -Wno-error=deprecated-declarations -g -Wl,-undefined -Wl,dynamic_lookup' \ +./configure --prefix="${PREFIX}" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG" $TEST_ARG make "$@" V=1 NO_GTEST=1 STATIC=1