You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CPS transformation is not the default since the generated code is slower, larger and less readable. On the other hand, the JSPI extension is not yet enabled by default in Web browsers, and performing effects is slower when using this extension.
55
55
56
+
== WASI support ==
57
+
58
+
You can produce a WASI binary by running {{{wasm_of_ocaml}}} with the
59
+
{{{--enable wasi}}} flag. At the moment, {{wasm_of_ocaml}} supports
60
+
WASI 0.1. Features from the Sys and Unix modules are available
61
+
whenever they're supported by the WASI API.
62
+
63
+
The binaries produced by {{{wasm_of_ocaml}}} require the GC and
64
+
exception-handling proposals, which are supported by Node.js,
65
+
Wasmtime, and the Wizard engine. Wasmtime does not support the legacy
66
+
Wasm exception-handling instructions. To generate a binary that runs
67
+
with Wasmtime, add the {{{--enable exnref}}} flag.
68
+
69
+
For now, the output remains the same as without the {{{--enable
70
+
wasi}}} flag: a JavaScript file {{{foo.js}}} and a directory
71
+
{{{foo.assets}}} containing the Wasm code {{{code.wasm}}}. The
72
+
JavaScript file can be used to run the WASI binary with {{{node}}},
73
+
while the Wasm code can be run directly by other Wasm engines.
74
+
56
75
== Binding with Javascript libraries ==
57
76
58
77
Js_of_ocaml lets the user bind their code with Javascript libraries by linking in {{{.js}}} files. Similarly, wasm_of_ocaml allows to link in Wasm modules ({{{.wasm}}} or {{{.wat}}} files): see [[wasm_runtime|Writing Wasm primitives]]. If a js_of_ocaml projects uses some {{{external}}} primitives defined in companion {{{.js}}} files, it will need the same primitives to be implemented in Wasm module in order to be build with wasm_of_ocaml.
0 commit comments