Standalone mode will require WASI if it does things like logging. Wasm by
itself doesn't have an API for that, so we need *something*, and we try to
use standard APIs as much as possible (see
https://v8.dev/blog/emscripten-standalone-wasm#let's-unify-as-much-as-possible
).

That is, if you see "fd_write" being required, that means logging is done
in the wasm module, so to run in wasm-interp we'd need an API to do that,
and WASI is the most standard API for that, so we use it.

If a program does *not* do any logging, then no fd_write will be imported.
So WASI is not a general requirement when in standalone mode.

There's nothing special about WASI here. Standalone mode tries not to use
external APIs as much as possible - it does what it can inside the wasm.
When it does need to use an API, it will import it. That can in theory be
any API emscripten supports, not just WASI, it depends on the APIs your
code needs - for example if you use a GL method like glBufferData it will
import that (and a custom runtime can then decide to add support for that
API, say in a game engine that wants GL-doing plugins).




On Fri, Jul 24, 2020 at 12:39 PM 'Steven Johnson' via emscripten-discuss <
emscripten-discuss@googlegroups.com> wrote:

> TL;DR: does STANDALONE_WASM=1 imply WASI-required?
>
> I've been building my wasm code with STANDALONE_WASM=1. This runs in d8
> just fine (though it still requires the .js wrapper to launch), and also in
> wasm-interp, but only if I build WASI support into wasm-interp (otherwise
> I'll fail with things like `invalid import
> "wasi_snapshot_preview1.fd_write"`).
>
> The comments in Emscripten's settings.js regarding STANDALONE_WASM don't
> seem entirely clear on this front. My assumption at the moment is
> that STANDALONE_WASM=0 means "You will almost certainly require JS and
> WASM" (which is fine), but STANDALONE_WASM=1 apparently means "You might
> require JS and/or WASI in addition to WASM".
>
> (The motivation here is that I'd like to use wabt's wasm-interp in a
> configuration without WASI, but it's not clear to me whether there is a set
> of flags for Emscripten that will reliably produce standalone wasm that
> requires neither WASI nor other JS-specific imports from "env".)
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/CAM%3DdnvfwXFpSG0N%2BfG-Us02bSFASTFeLS_9JewN8S4G5ijreYQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/emscripten-discuss/CAM%3DdnvfwXFpSG0N%2BfG-Us02bSFASTFeLS_9JewN8S4G5ijreYQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpRftpJOqhkVbZqvBJZCWM8yGT340kiukcchaeVu9m9Jtg%40mail.gmail.com.

Reply via email to