C++ and applicability of the wasi-sdk

Thanks for pointing that out. From reading the description of that flag (https://docs.wasmtime.dev/wasm-rust.html), it appears that you are not able to use the rust standard library:

wasm32-unknown-unknown - this target, like the WASI one, is focused on producing single *.wasm binaries. The standard library, however, is largely stubbed out since the “unknown” part of the target means libstd can’t assume anything. This means that while binaries will likely work in wasmtime , common conveniences like println! or panic! won’t work.

Is that correct?

I ended up trying out the wasi-sdk for C++, because it is linked to from this page, https://docs.wasmtime.dev/wasm-c.html. The wasi-sdk provides an implementation of the standard library that works well, except that it sometimes creates these imports for file io that are not supported by the canister runtime. The spurious file io always seems to be caused by asserts & writing to stderr if things fail. These can be largely avoided with the proper compile flags that optimize away these calls, but not always…

As far as I understand, the IC canisters do run the wasmtime environment. (I am not sure though…)

1 Like