I'm trying to call an imported function in my component; the wit file is here. cargo component bindings generates a bindings file successfully and it produces a getrandom() function. I bind an implementation to the linker in my host code and that gets invoked as well. However, when the host implementation returns back to the component, it panics in the component's bindings code, when it unpacks the result/vector by unmarshalling the ptr/size due to unaligned access. Anyone have any pointers to what can be happening? (cc @Alex Crichton )
looks like everything works if getrandom() returns list<u8> instead of result<list<u8>>
I don't know what the exact issue is but if you're using cargo component you may have better luck building with cargo component build.
If you're working with WASIp3, which is guest-level async, you'll need to make sure you're using up-to-date tools and everything is still a work-in-progress meaning that it's not a smooth experience at this time.
What you're running into here is that if you build for wasm32-wasip1 that doesn't build a component, it just builds a core module. With wasm32-wasip2 the linker being used by rustc doesn't have async support, so it's failing to recognize the intrinsic.
To build for wasm32-wasip3 right now (which is a target that doesn't exist in rust) you typically need to build for wasm32-wasip1 and manually run wasm-tools component new yourself.
@Alex Crichton i have been using wasm32-unknown-unknown; it works with my imported function returning list<u8> but not with it wrapped in a result; i wonder if it's a bindgen issue?
Can you confirm you've got the most up-to-date wasm-tools and wit-bindgen deps?
had an older install of cargo-component; bumped to wit-bindgen 0.41; it works now, thanks
Last updated: Dec 06 2025 at 06:05 UTC