Spike: build a static ELF via wasm2elf with WAT syscall shims
Add elf/ (flatten.py, shim.wat, wasm2elf.patch pinned to wasm2elf-mb rev) and just elf / test-elf recipes. The ELF handles plain HTTP, DNS, files and stdin; 26/27 repo tests pass, https:// is unsupported (no TLS). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ed06fa994a
commit
27ce306c7c
7 files changed
+770
-1
No files matched your search
@@ -16,6 +16,25 @@ test: build
|
||||
test-native: native
|
||||
CURL_WASM_NATIVE=./curl-native python3 tests/test_curl.py
|
||||
|
||||
# Spike: static x86-64 ELF via wasm2elf (no libc/runtime; plain HTTP only, no TLS yet)
|
||||
elf:
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
W=build/wasm2elf
|
||||
if [ ! -d $W ]; then
|
||||
git clone https://git.site.latha.org/nandi/wasm2elf-mb $W
|
||||
git -C $W checkout "$(cat elf/wasm2elf.rev)"
|
||||
git -C $W apply ../../elf/wasm2elf.patch
|
||||
fi
|
||||
(cd $W && moon build --target native)
|
||||
python3 elf/flatten.py curl.wat elf/shim.wat build/curl-flat.wat
|
||||
wasm-tools parse build/curl-flat.wat -o build/curl-flat.wasm
|
||||
wasm-tools validate build/curl-flat.wasm
|
||||
$W/_build/native/debug/build/cmd/main/main.exe build/curl-flat.wasm curl-elf run
|
||||
|
||||
test-elf: elf
|
||||
CURL_WASM_NATIVE=./curl-elf python3 tests/test_curl.py
|
||||
|
||||
run *args: build
|
||||
wasmtime run -S http --dir=. -- ./curl.wasm "$@"
|
||||
|
||||
@@ -23,4 +42,4 @@ run-native *args: native
|
||||
./curl-native "$@"
|
||||
|
||||
clean:
|
||||
rm -rf curl.wasm curl-native build
|
||||
rm -rf curl.wasm curl-native curl-elf build
|
||||
Reference in new issue
Block a user