dune icon indicating copy to clipboard operation
dune copied to clipboard

Wasm of ocaml support

Open vouillon opened this issue 1 year ago • 4 comments

This add the following:

  • a (js_of_ocaml (wasm_files (<files-list>)) option in library and executable stanzas to specify wasm_of_ocaml JavaScript and Wasm runtime files.
  • a (js_of_ocaml (submodes <submodes>)) option where each submode is either js or wasm in the environment and in library and executable stanzas to specify whether to generate JavaScript or Wasm code.

When compiling with wasm_of_ocaml, the output is a launcher file name.bc.wasm.js as well as a directory name.bc.wasm.asset containing the Wasm code and possibly some source maps.

When compiling to Wasm but not to JavaScript, a .bc.js file can also be produced for compatibility. It is just a copy of the bc.wasm.js file.

vouillon avatar Jul 04 '24 13:07 vouillon

I'm not sure how to add tests since they would require wasm_of_ocaml, which is a bit complicated to install at the moment...

vouillon avatar Jul 04 '24 13:07 vouillon

I'm not sure how to add tests since they would require wasm_of_ocaml, which is a bit complicated to install at the moment...

Nix would be a good option

rgrinberg avatar Jul 05 '24 22:07 rgrinberg

I'm not sure how to add tests since they would require wasm_of_ocaml, which is a bit complicated to install at the moment...

Oh, I can just use a new alias runtest-wasm and not run them on the CI for now.

vouillon avatar Jul 06 '24 12:07 vouillon

@hhugo Can you have a look?

vouillon avatar Aug 01 '24 10:08 vouillon

gentle ping @hhugo

rgrinberg avatar Sep 15 '24 10:09 rgrinberg

Continued the PR here https://github.com/ocaml/dune/pull/11029 since I'm unable to push here

rgrinberg avatar Oct 20 '24 15:10 rgrinberg

CI is failing @vouillon

--- a/_build/.sandbox/6975479b7ea39eedbfcff9056c4b3b15/default/test/blackbox-tests/test-cases/wasmoo/inline-tests.t/run.t
+++ b/_build/.sandbox/6975479b7ea39eedbfcff9056c4b3b15/default/test/blackbox-tests/test-cases/wasmoo/inline-tests.t/run.t.corrected
@@ -15,8 +15,17 @@ Run inline tests using Node.js
   $ dune runtest --profile release
   inline tests (Native)
   inline tests (Native)
-  inline tests (Wasm)
-  inline tests (Wasm)
+  File "wasm/dune", lines 1-6, characters 0-142:
+  1 | (library
+  2 |  (name inline_tests_wasm)
+  3 |  (js_of_ocaml (wasm_files wasm.wat) (submodes wasm))
+  4 |  (inline_tests
+  5 |   (modes js)
+  6 |   (backend fake_backend)))
+  wasm_of_ocaml: unknown option '--linkall'.
m  Usage: wasm_of_ocaml [COMMAND] …
+  Try 'wasm_of_ocaml --help' for more information.
+  [1]

rgrinberg avatar Oct 20 '24 15:10 rgrinberg