FS#75269 - [rust-wasm] invalid import in wasm32-wasi binaries

Attached to Project: Arch Linux
Opened by Julius Michaelis (jcaesar) - Friday, 08 July 2022, 01:22 GMT
Last edited by Jan Alexander Steffens (heftig) - Tuesday, 31 January 2023, 05:40 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Jan Alexander Steffens (heftig)
Johannes Löthberg (demize)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
wasm32-wasi binaries compiled by the rust/rust-wasm packages import env.__main_argc_argv and thus don't follow the wasi spec and can't be run by wasmtime or wasmer. (Failing with: unknown import: `env::__main_argc_argv` has not been defined)

This does not happen when using rustup.

Additional info:
* package version(s): rust-wasm 1.62.0-1

Steps to reproduce:

(This is also reproducible on a normal install, but for a clean slate reproducer: docker.)
docker run --rm -ti archlinux
pacman -Syu rust-wasm wasmer
cargo new baa
cd baa
cargo build --target wasm32-wasi
wasmer inspect target/wasm32-wasi/debug/waa.wasm

Outputs something like
Imports:
Functions:
"env"."__main_argc_argv": [I32, I32] -> [I32]
...

The same does not happen with
pacman -Syu rustup
rustup default 1.62.0
rustup target add wasm32-wasi

This task depends upon

Closed by  Jan Alexander Steffens (heftig)
Tuesday, 31 January 2023, 05:40 GMT
Reason for closing:  Fixed
Additional comments about closing:  rust-wasm 1.67.0
Comment by Toolybird (Toolybird) - Wednesday, 03 August 2022, 07:53 GMT
Is this still reproducible with latest rust-wasm 1:1.62.1-1?
Comment by Julius Michaelis (jcaesar) - Thursday, 05 January 2023, 02:26 GMT
This still persists with rust-wasm 1:1.66.0-1.
(Apologies for the late reply.)
Comment by Julius Michaelis (jcaesar) - Thursday, 05 January 2023, 05:16 GMT
(After a bit of digging, I suspect that this commit https://github.com/WebAssembly/wasi-libc/commit/d8d00bc is at least related, but rust-wasm ships its own wasi libc.a at /usr/lib64/rustlib/wasm32-wasi/lib/self-contained/libc.a and I have no idea where that file comes from.)
Comment by Jan Alexander Steffens (heftig) - Thursday, 05 January 2023, 11:01 GMT
https://github.com/rust-lang/rust/pull/105468 should fix this but doesn't build after backporting to Rust 1.66.

Looks like Rust 1.67 (in three weeks) will fix it, then.
Comment by Julius Michaelis (jcaesar) - Friday, 06 January 2023, 05:54 GMT
Ah, nice. I'll wait for that to drop and report back whether this issue can be closed.
Comment by Julius Michaelis (jcaesar) - Tuesday, 31 January 2023, 01:01 GMT
Issue can be closed, has been fixed with rust-wasm 1.67.0.

Loading...