Implements a curl clone directly in plain WebAssembly Text format (curl.wat) targeting the WASI 0.2 Component Model, together with build/test tooling and a portable wasm2c native compilation target.
Why & What Changed
Plain WAT WASI 0.2 curl clone (curl.wat, curl-wasm, Makefile):
Hand-written pure WebAssembly Text component targeting wasi:cli/*@0.2.0, wasi:io/*@0.2.0, wasi:clocks/monotonic-clock@0.2.0, wasi:filesystem/*@0.2.0, and wasi:http/*@0.2.0 (assembles with wasm-tools parse and runs on wasmtime with real HTTP/HTTPS).
Added justfile with build, test, run, clean, plus native, test-native, and run-native recipes (set positional-arguments).
native/extract_core.py extracts the embedded core modules from curl.wasm, and native/build_native.py discovers WABT's wasm2c runtime across system/Homebrew/Pixi/Conda installations (including Pixi trampoline_configuration/wasm2c.json) and automatically fetches version-matched runtime files from WebAssembly/wabt into build/wasm2c-rt-<ver>/ if a binary-only package omitted them (or honors WASM2C_RUNTIME_DIR).
Links cleanly with native/wasi_host.c (POSIX + OpenSSL, with _DARWIN_C_SOURCE/_POSIX_C_SOURCE guards and Conda/Pixi OpenSSL/rpath discovery) into ./curl-native without modifying curl.wat.
27 integration tests (local HTTP servers + live HTTPS smoke test against https://example.com), runnable against both wasmtime (just test) and ./curl-native (just test-native).
Verification
just clean && just native (auto-discovered /usr/src/wasm2c) and explicit WASM2C_RUNTIME_DIR with fetched WABT 1.0.36 runtime files: built native ELF x86-64 ./curl-native cleanly.
Implement a curl clone directly in plain WebAssembly Text format (curl.wat) targeting WASI 0.2 (wasi:cli, wasi:io, wasi:clocks, wasi:filesystem, wasi:http). Includes the executable curl-wasm wrapper script, Makefile, integration test suite (tests/test_curl.py), README.md, and .gitignore.
Add native/extract_core.py to extract embedded core Wasm modules from curl.wasm and native/wasi_host.c providing a POSIX/OpenSSL WASI 0.2 host shim for wasm2c. Add native, test-native, and run-native recipes to justfile (with positional-arguments enabled), support CURL_WASM_NATIVE in tests/test_curl.py, ignore build artifacts in .gitignore, and document native compilation in README.md.
Add native/build_native.py to auto-discover WABT's wasm2c runtime headers and sources (wasm-rt.h, wasm-rt-*.c, and .inc files, with WASM2C_RUNTIME_DIR override) and OpenSSL flags across Linux distros and macOS, instead of assuming /usr/include/wasm-rt.h and -lwasm-rt-impl. Guard _DARWIN_C_SOURCE vs _POSIX_C_SOURCE in native/wasi_host.c, delegate just native to native/build_native.py, and document WASM2C_RUNTIME_DIR in README.md.
nandi
changed title from Add plain WAT Wasm curl clone with WASI 0.2 and wasm2c native target to Add plain WAT Wasm curl clone with WASI 0.2 and portable wasm2c native target2026-11-20 00:22:45 +00:00
Resolve Pixi trampoline_configuration/wasm2c.json and Conda/Pixi env prefixes in native/build_native.py, add automatic version-matched runtime download from WebAssembly/wabt into build/wasm2c-rt-<ver>/ when binary-only packages (such as conda-forge wabt) omit wasm-rt.h/wasm-rt-impl.c, search Conda/Pixi prefixes for OpenSSL with rpath, and update README.md.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Implements a
curlclone directly in plain WebAssembly Text format (curl.wat) targeting the WASI 0.2 Component Model, together with build/test tooling and a portablewasm2cnative compilation target.Why & What Changed
curlclone (curl.wat,curl-wasm,Makefile):wasi:cli/*@0.2.0,wasi:io/*@0.2.0,wasi:clocks/monotonic-clock@0.2.0,wasi:filesystem/*@0.2.0, andwasi:http/*@0.2.0(assembles withwasm-tools parseand runs onwasmtimewith real HTTP/HTTPS).-X,-H(add/override/suppressName:/emptyName;),-d/--data-*(@file,@-,--data-raw,--data-binary,--data-urlencode),-G,-T(PUTfile/stdin),-i,-I,-L/--max-redirs(RFC 9110 method/body handling, relative/dot-segment resolution, cross-origin auth/cookie stripping),-o/-O/-D,-s/-S/-v/-f,-u/userinfo Basic Auth,-A/-e/-b/-r,--connect-timeout/-m, and-wformat variables.wasm2cTarget (justfile,native/extract_core.py,native/build_native.py,native/wasi_host.c):justfilewithbuild,test,run,clean, plusnative,test-native, andrun-nativerecipes (set positional-arguments).native/extract_core.pyextracts the embedded core modules fromcurl.wasm, andnative/build_native.pydiscovers WABT'swasm2cruntime across system/Homebrew/Pixi/Conda installations (including Pixitrampoline_configuration/wasm2c.json) and automatically fetches version-matched runtime files fromWebAssembly/wabtintobuild/wasm2c-rt-<ver>/if a binary-only package omitted them (or honorsWASM2C_RUNTIME_DIR).native/wasi_host.c(POSIX + OpenSSL, with_DARWIN_C_SOURCE/_POSIX_C_SOURCEguards and Conda/Pixi OpenSSL/rpath discovery) into./curl-nativewithout modifyingcurl.wat.tests/test_curl.py,README.md,.gitignore):https://example.com), runnable against bothwasmtime(just test) and./curl-native(just test-native).Verification
just clean && just native(auto-discovered/usr/src/wasm2c) and explicitWASM2C_RUNTIME_DIRwith fetched WABT 1.0.36 runtime files: built native ELF x86-64./curl-nativecleanly.trampoline_configuration/wasm2c.jsonprefix resolution verified.just test-native:27 passed, 0 failed.just test:27 passed, 0 failed.Add plain WAT Wasm curl clone with WASI 0.2 and wasm2c native targetto Add plain WAT Wasm curl clone with WASI 0.2 and portable wasm2c native targetPull request closed