feat: sirmem v0.1.0 knowledge-graph memory CLI
This commit is contained in:
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# usage: scripts/build.sh <nim-os> <nim-cpu> <zig-target> <output>
|
||||
# e.g. scripts/build.sh windows amd64 x86_64-windows-gnu dist/sirmem-windows-x86_64.exe
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
os=$1 cpu=$2 target=$3 out=$4
|
||||
mkdir -p "$(dirname "$out")"
|
||||
export ZIG_TARGET=$target
|
||||
# Notes from trial and error with zig 0.16: --opt:size breaks linking (empty undefined
|
||||
# symbols); -d:useMalloc is needed on linux-musl; aarch64-linux needs --tlsEmulation:on
|
||||
# (TLS relocs fail to link otherwise) but x86_64-linux fails *with* it.
|
||||
extra=()
|
||||
if [ "$os" = linux ] && [ "$cpu" = arm64 ]; then extra+=(--tlsEmulation:on); fi
|
||||
# zig cc 0.16 sporadically fails to link aarch64-linux ("undefined symbol:" with an empty
|
||||
# name, also seen as CacheCheckFailed); a retry succeeds, so retry up to 5 times.
|
||||
for attempt in 1 2 3 4 5; do
|
||||
rm -rf "nimcache/$target"
|
||||
if nim c -d:release -d:strip -d:useMalloc --parallelBuild:1 --hints:off \
|
||||
"${extra[@]}" --os:"$os" --cpu:"$cpu" \
|
||||
--cc:clang --clang.exe:"$PWD/scripts/zigcc" --clang.linkerexe:"$PWD/scripts/zigcc" \
|
||||
--nimcache:"nimcache/$target" -o:"$out" src/sirmem.nim ; then exit 0; fi
|
||||
echo "build attempt $attempt failed, retrying" >&2
|
||||
done
|
||||
exit 1
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# C compiler/linker wrapper so Nim can use `zig cc` for cross-compiling.
|
||||
# Needs ZIG_TARGET (e.g. aarch64-linux-musl). Filters flags zig cc rejects.
|
||||
args=()
|
||||
for a in "$@"; do
|
||||
case "$a" in
|
||||
-Wl,--no-gc-sections|-Wl,-rpath*|-fpie|-pie) ;;
|
||||
-ldl) case "$ZIG_TARGET" in *windows*) ;; *) args+=("$a") ;; esac ;;
|
||||
*) args+=("$a") ;;
|
||||
esac
|
||||
done
|
||||
exec zig cc -target "${ZIG_TARGET:?ZIG_TARGET not set}" "${args[@]}"
|
||||
Reference in New Issue
Block a user