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
@@ -77,3 +77,16 @@ If WABT's `wasm2c` runtime sources (`wasm-rt.h` and `wasm-rt-impl.c`) are not fo
|
||||
### `--write-out` Variables
|
||||
|
||||
`%{http_code}`, `%{response_code}`, `%{size_download}`, `%{size_upload}`, `%{time_total}`, `%{url_effective}`, `%{content_type}`, `%{redirect_url}`, `%{num_redirects}`, `%{scheme}`, `%{method}`, `\n`, `\r`, `\t`, `\\`, `%%`.
|
||||
|
||||
## Compile to a static ELF (`wasm2elf`, spike)
|
||||
|
||||
`just elf` builds `./curl-elf`, a ~1 MB static x86-64 Linux executable with no libc, no
|
||||
runtime and no OpenSSL, using [wasm2elf-mb](https://git.site.latha.org/nandi/wasm2elf-mb).
|
||||
`elf/flatten.py` merges the component's allocator module and core module into one core
|
||||
module; `elf/shim.wat` replaces the canon-lowered `wasi:*` imports with hand-written WAT
|
||||
that calls Linux syscalls through a few `sys::*` intrinsics (`elf/wasm2elf.patch` adds
|
||||
those plus bulk-memory `memory.copy`/`memory.fill` to wasm2elf, pinned in `elf/wasm2elf.rev`).
|
||||
|
||||
The shim speaks HTTP/1.0 over IPv4 TCP with a minimal UDP DNS resolver (nameserver from
|
||||
`/etc/resolv.conf`). `just test-elf` passes 26 of 27 tests; the failure is
|
||||
`live_https_example_com`: **`https://` is not supported** (no TLS stack).
|
||||
Reference in new issue
Block a user