Stream: wasi

Topic: Linking with clang fails when compiling to wasm32-wasip2


view this post on Zulip Lukas (Apr 11 2025 at 10:00):

I'm currently trying to build a rather large project for the wasm32-wasip2 target in Rust - it is not written as a WebAssembly specific target and therefore does not depend on either wasmtime or any other wasm-related crate. Everything compiles, however, linking fails. I use the wasi-sdk toolchain with clang & wasm-component-ld, which results in the following error:

  = note: error: failed to parse core wasm for componentization

          Caused by:
              0: updating metadata for section component-type:wit-bindgen:0.33.0:rust:wasi:bindings:encoded worldrust-wasi-from-crates-io
              1: failed to merge WIT package sets together
              2: failed to merge package `rust:wasi` into existing copy
              3: failed to merge world `bindings`
              4: import `wasi:io/poll@0.2.2` not found in target world
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm not sure what this error means, who should provide this world?

view this post on Zulip Ramon Klass (Apr 11 2025 at 11:54):

as far as I'm aware, wasi-sdk still produces wasip1 modules which wasm-tools can adapt into wasip2 components, ie. tell your rust to compile as wasip1 and then use wasm-tools component adapt

view this post on Zulip Lukas (Apr 11 2025 at 11:56):

Thank you very much! That's what I thought, but some dependencies need socket support, so I depend on wasip2 - have you any idea how I could get around that?

view this post on Zulip bjorn3 (Apr 11 2025 at 13:27):

If you tell rustc to compile for wasip2 it will already use the wasip1->wasip2 adapter.

view this post on Zulip Lukas (Apr 11 2025 at 13:29):

Meaning that the wasi-sdk should not be the issue here?


Last updated: Dec 06 2025 at 06:05 UTC