Add wasm2c native compilation target and host runtime
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.
This commit is contained in:
1 parent
e04081daa0
commit
2ff249ff89
6 files changed
+1918
-3
No files matched your search
@@ -1,3 +1,5 @@
|
||||
set positional-arguments
|
||||
|
||||
default:
|
||||
@just --list
|
||||
|
||||
@@ -5,11 +7,27 @@ build:
|
||||
wasm-tools parse curl.wat -o curl.wasm
|
||||
wasm-tools validate curl.wasm --features component-model
|
||||
|
||||
native: build
|
||||
mkdir -p build
|
||||
python3 native/extract_core.py curl.wasm build
|
||||
wasm2c build/mem_mod.wasm -n mem_mod -o build/mem_mod.c
|
||||
wasm2c build/curl_core.wasm -n curl_core -o build/curl_core.c
|
||||
cc -O2 -w -Ibuild -c build/mem_mod.c -o build/mem_mod.o
|
||||
cc -O2 -w -Ibuild -c build/curl_core.c -o build/curl_core.o
|
||||
cc -O2 -Wall -Wextra -Werror -Wno-unused-parameter -Ibuild -c native/wasi_host.c -o build/wasi_host.o
|
||||
cc -O2 build/mem_mod.o build/curl_core.o build/wasi_host.o -lwasm-rt-impl -lssl -lcrypto -lm -o curl-native
|
||||
|
||||
test: build
|
||||
python3 tests/test_curl.py
|
||||
|
||||
test-native: native
|
||||
CURL_WASM_NATIVE=./curl-native python3 tests/test_curl.py
|
||||
|
||||
run *args: build
|
||||
wasmtime run -S http --dir=. -- ./curl.wasm {{args}}
|
||||
wasmtime run -S http --dir=. -- ./curl.wasm "$@"
|
||||
|
||||
run-native *args: native
|
||||
./curl-native "$@"
|
||||
|
||||
clean:
|
||||
rm -f curl.wasm
|
||||
rm -rf curl.wasm curl-native build
|
||||
Reference in new issue
Block a user