Skip to content

replacing u32 -> string in adder tutorial example #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmk978 opened this issue Sep 5, 2024 · 3 comments
Closed

replacing u32 -> string in adder tutorial example #151

dmk978 opened this issue Sep 5, 2024 · 3 comments

Comments

@dmk978
Copy link

dmk978 commented Sep 5, 2024

Let's try mentioned example for use with string, that's absolute straightforward. Component compiles well, but issuing

wasm-tools component wit target/wasm32-wasip1/release/adder.wasm

command produce really big file filled with a lot of imports and references to standard WASI worlds:

package root:component;

world root {
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:io/[email protected];
  import wasi:io/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:clocks/[email protected];
  import wasi:filesystem/[email protected];
  import wasi:filesystem/[email protected];

  export docs:adder/[email protected];
}

and that continues for several screens. Why?

@vados-cosmonic
Copy link
Collaborator

Hey @dmk978 these dependencies are included because of Rust unwind/panic/stack unwind capability. If you'd like to avoid them, you can do one of at least two things:

  • use wasm32-unknown-unknown as your target (i.e. cargo component build --target wasm32-unknown-unknown)
  • Use nightly rust and a custom build command to remove the panic machinery

IIRC wasm32-wasip2 (which is available now) will also have this same issue, because by default the panic/debug/stack unwinding logic is included.

@kate-goldenring I think this should be closable!

@vados-cosmonic
Copy link
Collaborator

vados-cosmonic commented Apr 14, 2025

Ah, see also this discussion on Zulip which has come up a bit: #wit-bindgen > How to identify source of WASI imports? @ 💬

@vados-cosmonic
Copy link
Collaborator

Hey @kate-goldenring can we close this in favor of #120 ? My thought here is that this individual issue is solved, but we should definitely include it in the FAQ (it's quite Rust specific, but the question of "where did all these extra imports come from" is valid across languages).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants