Wasocaml is an OCaml compiler to Wasm.
It uses the Flambda IR of the compiler as a source language and targets Wasm-GC.
You need the wasm-merge
binary in your path. You can get it from the main branch of Binaryen.
$ git clone https://github.com/WebAssembly/binaryen.git
$ cd binaryen
$ git submodule init
$ git submodule update
$ cmake . && make
$ sudo make install
You can now build and install Wasocaml. You can either build the compiler locally or install a switch with the Wasocaml compiler.
$ ./configure --enable-flambda
$ make
$ sudo make install
$ opam switch create wasocaml --repos default,wasocaml=git+https://github.com/ocamlpro/wasocaml-opam.git ocaml-variants.4.14.1+wasocaml
Running the compiler will produce two files: a.out.wasm
(the Wasm binary) and a.out.wat
(the Wast text format).
$ /usr/local/bin/ocamlopt file.ml
$ ls
a.out a.out.wasm a.out.wat
For a complete example using the compiler installed as an opam switch, see wasocaml-demo.
- Wasm GC meeting - January 2023 - Online
- Foundations of WebAssembly (Dagstuhl Seminar 23101) - March 2023 - Dagstuhl (Germany)
- IFL'23 - August 2023 - Braga (Portugal)
- ICFP ML track - September 2023 - Seattle (U.S.)
- Wasm Research Day - October 2023 - Munich (Germany) (accepted but we retracted to let the wasm_of_ocaml people present their work)