7bf5898b8b07
remove Zig from static native Linux release builds (3.7.4)
- time
- 2026-10-06 19:52 UTC · 6 days ago
- machine
- Junes-MacBook-Pro.local
- agent
- gpt-6
- session
- remove zig build dependency
- parent
- a256b6c86276
↓ koh-7bf5898b.tar.gzatlas at this save
files changed5 files
README.md+4 −2VERSION+1 −1build.sh+5 −16tests/library_check_test.v+33 −0v.mod+1 −1README.md+4 −2
@@ -227,8 +227,10 @@227227 The flag builds the GC library from V's bundled source. SQLite 3.49.1 is228228 vendored and compiled into the executable. Every Koh build requires Boehm229229 garbage collection. Release builds use `sh build.sh` or230-`koh build` on the target OS and CPU; Linux releases also need Zig on `PATH`231-for the static musl toolchain. Cross-compiling Koh with the pinned V disables230+`koh build` on the target OS and CPU. Linux releases use the host C compiler231+(`cc`) and static C runtime libraries. Install the toolchain's static runtime232+development package if needed. Zig is not required.233+Cross-compiling Koh with the pinned V disables232234 garbage collection, so the release script refuses it.233235 234236 ## Manual and shell integrationbuild.sh+5 −16
@@ -7,8 +7,8 @@77 # target defaults to the machine running the script. Runs on macOS and Linux.88 #99 # macOS targets need macOS: they link against the Apple SDK and are ad-hoc10-# signed with codesign. Linux targets are static musl binaries built with11-# `zig cc`. Every target needs its own OS and CPU: the pinned V disables10+# signed with codesign. Linux targets use the host C compiler and static C runtime libraries.11+# Every target needs its own OS and CPU: the pinned V disables1212 # garbage collection when cross-compiling. Linux VMs work from a Mac.1313 set -eu1414 @@ -56,20 +56,9 @@5656 codesign -f -s - "$out"5757 ;;5858 linux-aarch64|linux-x86_64)59- command -v zig >/dev/null 2>&1 || die 'Linux builds need Zig on PATH (zig cc provides the musl toolchain)'60- case "$target" in61- linux-aarch64) arch=arm64; triple=aarch64-linux-musl ;;62- *) arch=x64; triple=x86_64-linux-musl ;;63- esac64- # V's -cc takes a single program, not `zig cc -target …`, so wrap it.65- # musl has neither getcontext nor ARM64's expected __data_start symbol.66- # libgc can scan the stack and discover the data segment without them.67- compiler="$PWD/build/cc-$target"68- printf '#!/bin/sh\nexec zig cc -target %s "$@"\n' "$triple" > "$compiler"69- chmod 755 "$compiler"70- v -prod -gc boehm -d use_bundled_libgc -os linux -arch "$arch" \71- -musl -cc "$compiler" -cflags "-DNO_GETCONTEXT -DSEARCH_FOR_DATA_START" \72- -ldflags "-s" -o "$out" src/koh.v59+ command -v cc >/dev/null 2>&1 || die 'Linux builds need a C compiler on PATH (cc)'60+ v -prod -gc boehm -d use_bundled_libgc -cc cc \61+ -ldflags '-static -s' -o "$out" src/koh.v7362 ;;7463 esac7564 tests/library_check_test.v+33 −0
@@ -31,6 +31,39 @@3131 assert result.output.contains('Koh requires garbage collection')3232 }3333 34+fn test_linux_release_script_builds_without_zig() {35+ dir := os.join_path(os.temp_dir(), 'koh-release-script-${time.now().unix_nano()}')36+ tools := os.join_path(dir, 'tools')37+ os.mkdir_all(tools)!38+ for name in ['dirname', 'mkdir', 'cc'] {39+ os.symlink(os.find_abs_path_of_executable(name)!, os.join_path(tools, name))!40+ }41+ os.cp('${@VMODROOT}/build.sh', os.join_path(dir, 'build.sh'))!42+ v := os.join_path(tools, 'v')43+ os.write_file(v, '#!/bin/sh44+if [ "$1" = version ]; then echo "V 0.5.2 b9a2d87"; exit 0; fi45+printf "%s\\n" "$@" > args46+while [ "$#" -gt 0 ]; do47+ if [ "$1" = -o ]; then : > "$2"; exit 0; fi48+ shift49+done50+exit 151+')!52+ os.chmod(v, 0o755)!53+ for cpu in ['aarch64', 'x86_64'] {54+ uname := os.join_path(tools, 'uname')55+ os.write_file(uname, '#!/bin/sh\ncase "$1" in -s) echo Linux ;; -m) echo ${cpu} ;; esac\n')!56+ os.chmod(uname, 0o755)!57+ result := os.execute('PATH="${tools}" KOH_TARGET=linux-${cpu} /bin/sh "${dir}/build.sh"')58+ assert result.exit_code == 0, result.output59+ assert os.is_file(os.join_path(dir, 'build/releases/koh-linux-${cpu}'))60+ args := os.read_file(os.join_path(dir, 'args'))!61+ assert args.contains('-gc\nboehm\n')62+ assert args.contains('-d\nuse_bundled_libgc\n')63+ assert args.contains('-ldflags\n-static -s\n')64+ }65+}66+3467 // Vectors from the official blake3 bindings, cross-checked against the3568 // naming of real Koh 2 objects: `.koh/objects/<hash[0..2]>/<hash[2..]>` is3669 // blake3(uncompressed bytes) of a zlib stream.v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 name: 'koh3'3- version: '3.7.3'3+ version: '3.7.4'44 description: 'One SQLite file per repo, one line of history.'55 license: 'MIT'66 }