mac build changes

This commit is contained in:
dan_s
2026-02-25 13:33:52 -06:00
parent 4d001ed7de
commit f5c8e02f24
3 changed files with 56 additions and 12 deletions

View File

@@ -52,6 +52,21 @@ if [[ "${1:-}" == "--linux-release" ]]; then
exit $?
fi
# Check for --mac-release flag for macOS release build (must be run on macOS)
if [[ "${1:-}" == "--mac-release" ]]; then
check_and_clean_target "macos-release"
shift
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "ERROR: --mac-release must be run on a native macOS system."
echo " Copy this repo to a Mac and run: ./build.sh --mac-release $*"
exit 1
fi
echo "Building macOS release natively..."
./util/build-mac.sh "$@"
echo "macOS release build complete."
exit $?
fi
# run correct build script for detected OS
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
check_and_clean_target "linux"

View File

@@ -51,8 +51,12 @@ LIBHUSH=libhush.a
if TARGET_WINDOWS
LIBRANDOMX=RandomX/build-win64/librandomx.a
else
if TARGET_DARWIN
LIBRANDOMX=RandomX/build-darwin/librandomx.a
else
LIBRANDOMX=RandomX/build-linux/librandomx.a
endif
endif
if BUILD_BITCOIN_LIBS
LIBZCASH_CONSENSUS=libzcashconsensus.la

View File

@@ -1,10 +1,37 @@
#!/usr/bin/env bash
# Copyright (c) 2016-2024 The Hush developers
# Copyright (c) 2016-2026 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#
# Native macOS build script.
# Requires: Xcode Command Line Tools, cmake, autoconf, automake, libtool, pkgconfig
# Optional: Homebrew GCC (brew install gcc) for better C++ compatibility
set -eu -o pipefail
# --- Detect architecture ---
ARCH=$(uname -m) # arm64 or x86_64
# --- Detect compiler ---
# Prefer Homebrew GCC if available, otherwise use system clang
if command -v brew &>/dev/null; then
# Find newest Homebrew GCC version
GCC_PATH=$(ls -d /opt/homebrew/bin/gcc-[0-9]* /usr/local/bin/gcc-[0-9]* 2>/dev/null | sort -t- -k2 -n | tail -1 || true)
GXX_PATH=$(echo "$GCC_PATH" | sed 's/gcc-/g++-/')
fi
if [ -n "${GCC_PATH:-}" ] && [ -x "$GCC_PATH" ]; then
export CC="$GCC_PATH"
export CXX="$GXX_PATH"
echo "Using Homebrew GCC: $CC / $CXX"
EXTRA_CXXFLAGS="-fwrapv -fno-strict-aliasing -Wno-builtin-declaration-mismatch -Werror -g"
else
export CC=clang
export CXX=clang++
echo "Using system clang: $CC / $CXX"
EXTRA_CXXFLAGS="-fwrapv -fno-strict-aliasing -Werror -g"
fi
export CC=gcc-8
export CXX=g++-8
export LIBTOOL=libtool
export AR=ar
export RANLIB=ranlib
@@ -12,8 +39,6 @@ export STRIP=strip
export OTOOL=otool
export NM=nm
set -eu -o pipefail
if [ "x$*" = 'x--help' ]
then
cat <<EOF
@@ -53,22 +78,22 @@ echo $PWD
./makecustom
cd $WD
# Build RandomX
# Build RandomX for macOS
cd src/RandomX
if [ -d "build" ]
if [ -f "build-darwin/librandomx.a" ]
then
ls -la build/librandomx*
ls -la build-darwin/librandomx*
else
mkdir build && cd build
CC="${CC} -g " CXX="${CXX} -g " cmake ..
mkdir -p build-darwin && cd build-darwin
CC="${CC} -g " CXX="${CXX} -g " cmake -DARCH=native ..
make
fi
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' \
CPPFLAGS="-I$PREFIX/include" LDFLAGS="-L$PREFIX/lib -Wl,-undefined -Wl,dynamic_lookup" \
CXXFLAGS="${EXTRA_CXXFLAGS} -I$PREFIX/include" \
./configure --prefix="${PREFIX}" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG"
make "$@" V=1 NO_GTEST=1 STATIC=1