Stream: git-wasmtime

Topic: wasmtime / issue #10114 Questions about c-api


view this post on Zulip Wasmtime GitHub notifications bot (Jan 25 2025 at 21:38):

mihaly-sisak opened issue #10114:

Hello all!
This is my first time touching Rust code and I feel a little bit lost.
I am more familiar with C so I wanted to give the c-api a try.
I found these tutorials: https://docs.wasmtime.dev/examples-c-gcd.html

However, I ran into an error. I did not have wasmtime_wat2wasm defined.
I stumbled upon WASMTIME_FEATURE_LIST.
I managed to fix this by adding wat = ["dep:wat", "wasmtime/wat"] to crates/c-api/Cargo.toml, adding "WAT", to crates/c-api/build.rs, and compiling with cargo build --release --package wasmtime-c-api --features wasmtime-c-api/wat.

What is the expected action if I want to enable/disable features? Do I need to modify build.rs, Cargo.toml and features.cmake to match? Or is it supposed to be matching automatically and I am just so new to cargo that I cant figure it out?

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2025 at 18:02):

alexcrichton commented on issue #10114:

Thanks for the report! I think you've found a bug in our configuration and the changes you made were correct. I've pushed those up as https://github.com/bytecodealliance/wasmtime/pull/10124, although if you'd like to send a PR as well I'm happy to close that too in favor of yours!

In terms of expectations: no, you shouldn't have to do this. Features should be toggle-able with cargo build or the cmake-based build, whichever you're using. The example you linked to just needs to ensure that the "wat" feature was enabled when building the C library.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2025 at 20:14):

mihaly-sisak closed issue #10114:

Hello all!
This is my first time touching Rust code and I feel a little bit lost.
I am more familiar with C so I wanted to give the c-api a try.
I found these tutorials: https://docs.wasmtime.dev/examples-c-gcd.html

However, I ran into an error. I did not have wasmtime_wat2wasm defined.
I stumbled upon WASMTIME_FEATURE_LIST.
I managed to fix this by adding wat = ["dep:wat", "wasmtime/wat"] to crates/c-api/Cargo.toml, adding "WAT", to crates/c-api/build.rs, and compiling with cargo build --release --package wasmtime-c-api --features wasmtime-c-api/wat.

What is the expected action if I want to enable/disable features? Do I need to modify build.rs, Cargo.toml and features.cmake to match? Or is it supposed to be matching automatically and I am just so new to cargo that I cant figure it out?

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2025 at 20:14):

mihaly-sisak commented on issue #10114:

Oh, so the cargo and cmake builds are 2 separate ways to achieve the same thing. Thank you for clearing up my confusion!


Last updated: Feb 28 2025 at 03:10 UTC