infra/cross/build-linux.sh builds igneumd and igneum-miner for x86_64-unknown-linux-gnu.2.36 (Debian 12) with cargo-zigbuild 0.23.4 and zig 0.17.0 into vendor/igneum-node/target-linux: rocksdb, lz4, blst, secp256k1 and the execution layer all link through zig, no crate failed (Docker is absent here, so cross was not needed). Cold build 1,856 s at 4 jobs, nice 19, on a loaded Mac; the seed's own build took 55 min and the builder VM 10 to 25. Verified on igneum-seed-1 in /root/xbuild-test: igneumd --version, igneum-miner --help, and a 60-s private network with real proof of work where the cross-compiled miner found 7 blocks that the cross-compiled node accepted (0 rejected). /opt/igneum/v4/bin untouched. BIN_SOURCE=mac: provision.sh skips the builder VM and takes build/bin from the cross-compile; stage-v4.sh cross-compiles, uploads to /root/v4/out and installs exactly as a VM build would. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
50 lines
3.1 KiB
Bash
Executable file
50 lines
3.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Cross-compile igneumd and igneum-miner for x86_64 Linux (Debian 12, glibc 2.36) on the Mac, so a server never
|
|
# builds. Uses cargo-zigbuild (zig as the C/C++ cross toolchain and linker); rocksdb (librocksdb-sys, C++), blst,
|
|
# secp256k1 and the execution layer's crates all link through it.
|
|
#
|
|
# infra/cross/build-linux.sh build from NODE_SRC (default vendor/igneum-node-v4) into TARGET_DIR
|
|
# NODE_SRC=... TARGET_DIR=... JOBS=4 infra/cross/build-linux.sh
|
|
#
|
|
# Output: $TARGET_DIR/x86_64-unknown-linux-gnu/release/{igneumd,igneum-miner} and $OUT_DIR/{igneumd,igneum-miner,version.txt}
|
|
# (OUT_DIR default infra/cross/out). First build: about 500 crates; later builds are incremental.
|
|
#
|
|
# One-off setup (4 Oct 2026, done on this Mac): brew install zig (0.17.0); cargo install cargo-zigbuild (0.23.4);
|
|
# rustup target add x86_64-unknown-linux-gnu. Docker is not installed here, so `cross` is not an option.
|
|
set -euo pipefail
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO="$(cd "$HERE/../.." && pwd)"
|
|
NODE_SRC="${NODE_SRC:-$REPO/vendor/igneum-node-v4}"
|
|
TARGET_DIR="${TARGET_DIR:-$REPO/vendor/igneum-node/target-linux}"
|
|
OUT_DIR="${OUT_DIR:-$HERE/out}"
|
|
TARGET="${TARGET:-x86_64-unknown-linux-gnu}"
|
|
GLIBC="${GLIBC:-2.36}"
|
|
JOBS="${JOBS:-4}"
|
|
CARGO="${CARGO:-$HOME/.cargo/bin/cargo}"
|
|
log() { printf '%s %s\n' "$(date -u +%H:%M:%S)" "$*"; }
|
|
die() { log "ERROR: $*" >&2; exit 1; }
|
|
|
|
command -v zig >/dev/null 2>&1 || die "zig is not installed (brew install zig)"
|
|
[ -x "$HOME/.cargo/bin/cargo-zigbuild" ] || command -v cargo-zigbuild >/dev/null 2>&1 || die "cargo-zigbuild is not installed (cargo install cargo-zigbuild)"
|
|
"$HOME/.cargo/bin/rustup" target list --installed | grep -q "^$TARGET\$" || { log "adding rust target $TARGET"; "$HOME/.cargo/bin/rustup" target add "$TARGET"; }
|
|
[ -f "$NODE_SRC/Cargo.toml" ] || die "no node source at $NODE_SRC"
|
|
|
|
log "cross-compiling igneumd and igneum-miner for $TARGET.$GLIBC from $NODE_SRC ($(git -C "$NODE_SRC" rev-parse --short HEAD), $(git -C "$NODE_SRC" rev-parse --abbrev-ref HEAD)); target dir $TARGET_DIR; zig $(zig version); $JOBS jobs at nice 19"
|
|
start=$(date +%s)
|
|
( cd "$NODE_SRC" && CARGO_TARGET_DIR="$TARGET_DIR" nice -n 19 "$CARGO" zigbuild --release -j "$JOBS" \
|
|
--target "$TARGET.$GLIBC" -p kaspad -p igneum-miner --features kaspad/igneum-pow )
|
|
secs=$(( $(date +%s) - start ))
|
|
log "cross-compile finished in $secs s ($(( secs / 60 )) min)"
|
|
|
|
mkdir -p "$OUT_DIR"
|
|
cp "$TARGET_DIR/$TARGET/release/igneumd" "$TARGET_DIR/$TARGET/release/igneum-miner" "$OUT_DIR/"
|
|
chmod +x "$OUT_DIR/igneumd" "$OUT_DIR/igneum-miner"
|
|
ver=$(grep -m1 '^version' "$NODE_SRC/Cargo.toml" | sed 's/.*"\(.*\)".*/\1/')
|
|
{
|
|
printf 'igneumd %s\n' "$ver"
|
|
printf 'cross-compiled on %s from %s (%s) with cargo-zigbuild, target %s.%s, %s s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$(git -C "$NODE_SRC" rev-parse --short HEAD)" "$(git -C "$NODE_SRC" rev-parse --abbrev-ref HEAD)" "$TARGET" "$GLIBC" "$secs"
|
|
git -C "$NODE_SRC" rev-parse --short HEAD
|
|
} > "$OUT_DIR/version.txt"
|
|
file "$OUT_DIR/igneumd" "$OUT_DIR/igneum-miner" | sed 's/^/ /'
|
|
ls -la "$OUT_DIR" | sed 's/^/ /'
|
|
log "binaries in $OUT_DIR"
|