Interface validation when publishing a package compiled with `cargo wasix build`
Describe the bug
I just tried to publish a package (wasmerio/fork-bomb) that was compiled using cargo wasix build and ran into validation errors. It looks like our code for interfaces doesn't know about WASIX, or at least the wasix_32v1 interface.
$ wasmer --version --verbose
wasmer 4.1.1 (0bd4b48 2023-08-03)
binary: wasmer-cli
commit-hash: 0bd4b48691924127200ea206f72b813e85d11520
commit-date: 2023-08-03
host: aarch64-apple-darwin
compiler: singlepass,cranelift
$ rustc --version --verbose
rustc 1.73.0-nightly (1b198b3a1 2023-08-13)
binary: rustc
commit-hash: 1b198b3a196442e14fb06978166ab46a4618d131
commit-date: 2023-08-13
host: aarch64-apple-darwin
release: 1.73.0-nightly
LLVM version: 17.0.0
$ cargo wasix --version
cargo-wasix 0.1.21
Steps to reproduce
$ git clone https://github.com/wasmerio/fork-bomb
$ cd fork-bomb
$ cargo wasix build --release
$ wasmer publish --registry=wasmer.wtf
error: WASM file "/Users/work/Documents/wasmer/fork-bomb/target/wasm32-wasmer-wasi/release/fork-bomb.wasm" detected as invalid because InterfaceViolated { errors: ["Missing import \"wasix_32v1\" \"sock_open\"", "Missing import \"wasix_32v1\" \"epoll_wait\"", "Missing import \"wasix_32v1\" \"thread_exit\"", "Missing import \"wasi\" \"thread-spawn\"", "Missing import \"wasix_32v1\" \"fd_dup\"", "Missing import \"wasix_32v1\" \"epoll_create\"", "Missing import \"wasix_32v1\" \"callback_signal\"", "Missing import \"wasix_32v1\" \"futex_wake_all\"", "Missing import \"wasix_32v1\" \"futex_wait\"", "Missing import \"wasix_32v1\" \"sock_connect\"", "Missing import \"wasix_32v1\" \"sock_listen\"", "Missing import \"wasix_32v1\" \"sock_accept_v2\"", "Missing import \"wasix_32v1\" \"sock_set_opt_size\"", "Missing import \"wasix_32v1\" \"sock_set_opt_flag\"", "Missing import \"wasix_32v1\" \"resolve\"", "Missing import \"wasix_32v1\" \"getcwd\"", "Missing import \"wasix_32v1\" \"thread_signal\"", "Missing import \"wasix_32v1\" \"fd_event\"", "Missing import \"wasix_32v1\" \"sock_bind\"", "Missing import \"wasix_32v1\" \"epoll_ctl\"", "Missing import \"wasix_32v1\" \"futex_wake\""] }
The error complains about loads of missing imports from the wasix_32v1 namespace.
Additional context
Need to be able to handle abi = 'wasix' in wasmer.toml of packages.
I also encounter the similar issue when run php-8.2.6-wasmedge.wasm with the latest wasmer 4.2.3.
> wasmer php-8.2.6-wasmedge.wasm --dir . hello.php
error: Instantiation failed
╰─▶ 1: Error while importing "wasi_snapshot_preview1"."sock_open": unknown import. Expected Function(FunctionType { params: [I32, I32, I32], results: [I32] })
See also https://github.com/vmware-labs/webassembly-language-runtimes/issues/121.
@liudonghua123 this is a different problem. sock_open is not part of wasi preview1.
Not sure where this is coming from, but it's not official.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Feel free to reopen the issue if it has been closed by mistake.