Skip to content

Instantly share code, notes, and snippets.

@willcl-ark
Last active October 7, 2025 12:48
Show Gist options
  • Select an option

  • Save willcl-ark/dae846d53d1ef120ba91d26a8c7182b4 to your computer and use it in GitHub Desktop.

Select an option

Save willcl-ark/dae846d53d1ef120ba91d26a8c7182b4 to your computer and use it in GitHub Desktop.

Revisions

  1. willcl-ark revised this gist Oct 7, 2025. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions build-freebsd.sh
    Original file line number Diff line number Diff line change
    @@ -33,8 +33,8 @@ make -C depends -j14 HOST=$HOST NO_QT=1
    # Generate build system
    cmake -B build \
    --toolchain "depends/$HOST/toolchain.cmake" \
    -DCMAKE_SYSROOT=/opt/cross-freebsd-14 \
    -DCMAKE_CXX_FLAGS="-isystem/opt/cross-freebsd-14/usr/lib/clang/18/include"
    -DCMAKE_SYSROOT="$FREEBSD_SYSROOT" \
    -DCMAKE_CXX_FLAGS="-isystem$FREEBSD_SYSROOT/usr/lib/clang/18/include"

    # Build bitcoind
    cmake --build build --parallel --target bitcoind
    cmake --build build --parallel --target bitcoind --target bitcoin-cli
  2. willcl-ark created this gist Oct 7, 2025.
    40 changes: 40 additions & 0 deletions build-freebsd.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    #!/usr/bin/env bash
    set -e

    export HOST=x86_64-unknown-freebsd
    export FREEBSD_SYSROOT=/opt/cross-freebsd-14
    export FREEBSD_VERSION="14.2"
    CLANG_REQUIRED="18"

    export CFLAGS="--sysroot=$FREEBSD_SYSROOT"
    export CXXFLAGS="--sysroot=$FREEBSD_SYSROOT"
    export LDFLAGS="--sysroot=$FREEBSD_SYSROOT"

    # Check Clang version - must match FreeBSD sysroot clang version which is clang18 for FreeBSD 14.2
    CLANG_VERSION=$(clang --version | head -n1 | sed 's/.*clang version \([0-9]\+\).*/\1/')
    if [ "$CLANG_VERSION" != "$CLANG_REQUIRED" ]; then
    echo "ERROR: Clang version $CLANG_VERSION detected, but version $CLANG_REQUIRED is required"
    echo "The FreeBSD sysroot contains Clang $CLANG_REQUIRED intrinsics headers that must match the compiler version"
    exit 1
    fi
    echo "Using Clang $CLANG_VERSION (compatible with FreeBSD sysroot)"

    # Get sysroot
    if [ ! -f "$FREEBSD_SYSROOT/base.txz" ]; then
    mkdir -p "$FREEBSD_SYSROOT"
    cd "$FREEBSD_SYSROOT"
    wget "http://ftp.plusline.de/FreeBSD/releases/amd64/$FREEBSD_VERSION-RELEASE/base.txz"
    tar -xf base.txz
    fi

    # Build depends
    make -C depends -j14 HOST=$HOST NO_QT=1

    # Generate build system
    cmake -B build \
    --toolchain "depends/$HOST/toolchain.cmake" \
    -DCMAKE_SYSROOT=/opt/cross-freebsd-14 \
    -DCMAKE_CXX_FLAGS="-isystem/opt/cross-freebsd-14/usr/lib/clang/18/include"

    # Build bitcoind
    cmake --build build --parallel --target bitcoind