Files
sausage/spikes/s3-git/README.md
T
surma 9e9cde5241 spikes: six v3 spikes (V8 harness, WASI shell, git, builder, http hook, esbuild)
Throwaway prototypes for Sausage v3. Plan and decisions:
~/research/sausage-v3/PLAN.md. Results and evidence: the spike READMEs.
2026-11-06 14:03:20 +00:00

86 lines
3.8 KiB
Markdown

# Upstream Git WASI spike
Status: the agentOS baseline builds Git 2.55.0 for WASI. Diagnostic preload tests fail during startup.
The binary is `/tmp/s3-git/agentos/toolchain/c/build/git` (3,987,814 bytes).
See `.board/T3.report.md` for all 87 imports and the measured operation results.
## Rework 1: unchanged agentOS baseline
`baseline.nu` invokes the pinned agentOS sysroot script through `bash`, then invokes its Git Makefile target.
The clone lives at `/tmp/s3-git/agentos`, commit `605f76de28366118c84e92ca6fd4938c1c501025`.
The launcher expects `/tmp/s3-git/tools/nproc` to print `2` to limit compiler jobs.
Rework 2 added Python3 as an upstream build dependency. The unchanged build then succeeded.
```sh
nix shell nixpkgs#gnumake nixpkgs#cmake nixpkgs#ninja nixpkgs#gcc nixpkgs#patch nixpkgs#perl nixpkgs#python3 -c nu spikes/s3-git/baseline.nu
nix develop -c nu spikes/s3-git/stubs.nu /tmp/s3-git/agentos/toolchain/c/build/git /tmp/s3-git/stubs
mkdir -p /tmp/s3-git/dev
touch /tmp/s3-git/dev/null
nix develop -c nu spikes/s3-git/test.nu /tmp/s3-git/agentos/toolchain/c/build/git --stubs /tmp/s3-git/stubs
nix develop -c nu spikes/s3-git/probe.nu /tmp/s3-git/agentos/toolchain/c/build/git /tmp/s3-git/stubs
```
`stubs.nu` extracts imports and generates the five WAT preload modules.
The repository also contains those concrete WAT files.
`test.nu` fails at the first unsuccessful operation.
`probe.nu` records every operation independently. Native Git creates its fixtures.
All WASI probes fail at Git's startup open of `/dev/null` with the diagnostic stubs.
An exit code of zero from `probe.nu` means that it recorded results, not that Git passed.
## Original stock-SDK attempt
The brief defines the intended local operations. `test.nu` exercises those operations through Wasmtime.
The script needs a successful build before it can verify behavior.
## Reproduce the build failure
The experiment uses Git 2.49.0, zlib 1.3.1, and WASI SDK 34.0 for Linux ARM64.
Run these commands from the repository root. Keep the extracted sources under `/tmp/s3-git`.
```sh
mkdir -p /tmp/s3-git
curl -fL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-34/wasi-sdk-34.0-arm64-linux.tar.gz -o /tmp/s3-git/sdk.tar.gz
tar -xf /tmp/s3-git/sdk.tar.gz -C /tmp/s3-git
curl -fL https://www.kernel.org/pub/software/scm/git/git-2.49.0.tar.xz -o /tmp/s3-git/git.tar.xz
tar -xf /tmp/s3-git/git.tar.xz -C /tmp/s3-git
curl -fL https://zlib.net/fossils/zlib-1.3.1.tar.gz -o /tmp/s3-git/zlib.tar.gz
tar -xf /tmp/s3-git/zlib.tar.gz -C /tmp/s3-git
nix build nixpkgs#ncurses --no-link
```
Set `LD_LIBRARY_PATH` to the SDK's `lib` directory and `$(nix eval --raw nixpkgs#ncurses.outPath)/lib`.
In `/tmp/s3-git/zlib-1.3.1`, run:
```sh
CC=/tmp/s3-git/wasi-sdk-34.0-arm64-linux/bin/clang AR=/tmp/s3-git/wasi-sdk-34.0-arm64-linux/bin/llvm-ar RANLIB=/tmp/s3-git/wasi-sdk-34.0-arm64-linux/bin/llvm-ranlib ./configure --static
nix shell nixpkgs#gnumake -c make -j2 libz.a
```
Apply `0001-wasi-no-syslog-header.patch` with `patch -p1` in the Git source directory.
From the repository root, run:
```sh
nix shell nixpkgs#gnumake -c nu spikes/s3-git/build.nu
```
This fails because the stock sysroot lacks `sys/wait.h`.
The patch only suppresses an unavailable header. It does not implement syslog or process support.
## Required verification after a successful build
```sh
nix develop -c nu spikes/s3-git/test.nu /tmp/s3-git/git-2.49.0/git
```
Run the same script with the adapted component path after `wasm-tools component new --adapt`.
Neither execution passed in this spike.
## Source checksums
```text
f7e243dff54d60bcc576e94d6166b69f410f2500ae4a9ceef34315be10e77971 sdk.tar.gz
618190cf590b7e9f6c11f91f23b1d267cd98c3ab33b850416d8758f8b5a85628 git.tar.xz
9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 zlib.tar.gz
```