#!/bin/sh # build-soul-darwin.sh — replicate `elb` on macOS/arm64 with clang. # Proven 2026-06-16: produces a Mach-O arm64 soul that boots and serves :7770. # The official builder `elb` ships Linux-only (CI); this lets us build + test the # darwin soul locally (e.g. to validate the atomic engram_save fix in isolation). # # Usage: scripts/build-soul-darwin.sh [output-binary] set -e DIST="${1:?usage: build-soul-darwin.sh [out]}" OUT="${2:-./neuron}" RT="$(cd "$(dirname "$0")/.." && pwd)/lang/el-compiler/runtime" B="$(mktemp -d)" # elc-generated dist modules use C89-style implicit cross-module declarations that # Apple clang rejects as errors by default; resolve at link, so downgrade them. CFLAGS="-Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-conversion -I$B -I$DIST -I$RT" cp "$RT/el_runtime.h" "$B/" clang -c $CFLAGS "$RT/el_runtime.c" -o "$B/el_runtime.o" for c in "$DIST"/*.c; do clang -c $CFLAGS "$c" -o "$B/$(basename "$c" .c).o"; done # NOTE: link *.o once — do not also list el_runtime.o separately (duplicate symbols). clang "$B"/*.o -o "$OUT" -lcurl -lm echo "built $OUT"