32159c5a3fbf
retain garbage collection in native release builds (3.7.2)
- time
- 2026-10-06 01:24 UTC · 1 week ago
- machine
- Junes-MacBook-Pro.local
- agent
- gpt-6
- session
- retain release garbage collection
- parent
- 8649861afa07
↓ koh-32159c5a.tar.gzatlas at this save
files changed5 files
VERSION+1 −1build.sh+15 −10src/koh.v+4 −0tests/library_check_test.v+8 −0v.mod+1 −1build.sh+15 −10
@@ -7,9 +7,9 @@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 cross-compiled11-# with `zig cc`, so they build the same from either host, and NixOS's gcc12-# wrapper and missing tcc never come into it.10+# signed with codesign. Linux targets are static musl binaries built with11+# `zig cc`. Every target needs its own OS and CPU: the pinned V disables12+# garbage collection when cross-compiling. Linux VMs work from a Mac.1313 set -eu1414 1515 die() {@@ -38,7 +38,13 @@3838 echo "$os-$cpu"3939 }4040 41-target=${KOH_TARGET:-$(host_target)}41+native=$(host_target)42+target=${KOH_TARGET:-$native}43+case "$target" in44+ macos-aarch64|macos-x86_64|linux-aarch64|linux-x86_64) ;;45+ *) die "unsupported release target: $target (want macos-aarch64, macos-x86_64, linux-x86_64 or linux-aarch64)" ;;46+esac47+[ "$target" = "$native" ] || die "$target requires a native $target host or VM to retain garbage collection (this host is $native)"4248 out="build/releases/koh-$target"4349 mkdir -p build/releases4450 @@ -49,7 +55,7 @@4955 macos-aarch64) arch=arm64; cpu=arm64 ;;5056 *) arch=x64; cpu=x86_64 ;;5157 esac52- v -prod -d use_bundled_libgc -arch "$arch" \58+ v -prod -gc boehm -d use_bundled_libgc -arch "$arch" \5359 -cflags "-arch $cpu -mmacosx-version-min=11.0" -o "$out" src/koh.v5460 # Apple Silicon refuses to run an unsigned binary.5561 codesign -f -s - "$out"@@ -61,16 +67,15 @@6167 *) arch=x64; triple=x86_64-linux-musl ;;6268 esac6369 # V's -cc takes a single program, not `zig cc -target …`, so wrap it.64- # V drops the GC for any cross target, which is how every Linux release65- # has shipped; -gc none pins that on a Linux host too, where V would66- # otherwise link libgc against musl and fail on glibc's getcontext.70+ # musl has neither getcontext nor ARM64's expected __data_start symbol.71+ # libgc can scan the stack and discover the data segment without them.6772 compiler="$PWD/build/cc-$target"6873 printf '#!/bin/sh\nexec zig cc -target %s "$@"\n' "$triple" > "$compiler"6974 chmod 755 "$compiler"70- v -prod -gc none -os linux -arch "$arch" -musl -cc "$compiler" \75+ v -prod -gc boehm -d use_bundled_libgc -os linux -arch "$arch" \76+ -musl -cc "$compiler" -cflags "-DNO_GETCONTEXT -DSEARCH_FOR_DATA_START" \7177 -ldflags "-s" -o "$out" src/koh.v7278 ;;73- *) die "unsupported release target: $target (want macos-aarch64, macos-x86_64, linux-x86_64 or linux-aarch64)" ;;7479 esac7580 7681 echo "built $out"src/koh.v+4 −0
@@ -4,6 +4,10 @@44 import os55 import src.cli66 7+$if !gcboehm ? {8+ $compile_error('Koh requires garbage collection; build natively with -gc boehm')9+}10+711 fn main() {812 exit(cli.run(os.args))913 }tests/library_check_test.v+8 −0
@@ -14,6 +14,7 @@1414 import crypto.sha2561515 import net1616 import net.http17+import os1718 import time1819 1920 // Koh 3 is built and tested on V master at b9a2d87, and that revision is the pin:@@ -21,6 +22,13 @@2122 // other compiler fails here rather than somewhere stranger.2223 fn test_built_with_the_pinned_v() {2324 assert @VCURRENTHASH == 'b9a2d87'25+}26+27+fn test_koh_refuses_a_build_without_garbage_collection() {28+ output := os.join_path(os.temp_dir(), 'koh-no-gc-${os.getpid()}')29+ result := os.execute('v -gc none -o "${output}" "${@VMODROOT}/src/koh.v"')30+ assert result.exit_code != 031+ assert result.output.contains('Koh requires garbage collection')2432 }2533 2634 // Vectors from the official blake3 bindings, cross-checked against thev.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 name: 'koh3'3- version: '3.7.1'3+ version: '3.7.2'44 description: 'One SQLite file per repo, one line of history.'55 license: 'MIT'66 }