Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm_of_ocaml support #11093

Merged
merged 26 commits into from
Nov 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Wording changes
Signed-off-by: Jérôme Vouillon <jerome.vouillon@gmail.com>
vouillon committed Nov 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 5c1c3395283e9db3ef361e370cf096ba31a270b8
26 changes: 13 additions & 13 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -194,19 +194,19 @@ jobs:
name: Wasm_of_ocaml
runs-on: ubuntu-latest
steps:
- name: Install node
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: latest

- name: Restore cached binaryen
- name: Restore Cached Binaryen
id: cache-binaryen
uses: actions/cache/restore@v4
with:
path: binaryen
key: ${{ runner.os }}-binaryen-version_119

- name: Checkout binaryen
- name: Checkout Binaryen
if: steps.cache-binaryen.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
@@ -215,29 +215,29 @@ jobs:
submodules: true
ref: version_119

- name: Install ninja
- name: Install Ninja
if: steps.cache-binaryen.outputs.cache-hit != 'true'
run: sudo apt-get install ninja-build

- name: Build binaryen
- name: Build Binaryen
if: steps.cache-binaryen.outputs.cache-hit != 'true'
working-directory: ./binaryen
run: |
cmake -G Ninja .
ninja

- name: Cache binaryen
- name: Cache Binaryen
if: steps.cache-binaryen.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: binaryen
key: ${{ runner.os }}-binaryen-version_119

- name: Set binaryen's path
- name: Set Binaryen's Path
run: |
echo "$GITHUB_WORKSPACE/binaryen/bin" >> $GITHUB_PATH

- name: Checkout code
- name: Checkout Code
uses: actions/checkout@v4
with:
path: dune
@@ -250,28 +250,28 @@ jobs:
opam-depext: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opam depext is unused in setup-ocaml v3

dune-cache: true

- name: Update dune
- name: Update Dune
working-directory: ./dune
run: opam pin add -n dune . --with-version 3.17.0

- name: Checkout wasm_of_ocaml
- name: Checkout Wasm_of_ocaml
uses: actions/checkout@v4
with:
repository: ocaml-wasm/wasm_of_ocaml
ref: target-dir
path: wasm_of_ocaml

- name: Install wasm_of_ocaml
- name: Install Wasm_of_ocaml
working-directory: ./wasm_of_ocaml
run: |
opam pin add -n . --with-version `< VERSION`
opam install wasm_of_ocaml-compiler

- name: Set git user
- name: Set Git User
run: |
git config --global user.name github-actions[bot]
git config --global user.email github-actions[bot]@users.noreply.github.com
- name: Run tests
- name: Run Tests
working-directory: ./dune
run: opam exec -- make test-wasm
env:
4 changes: 2 additions & 2 deletions doc/wasmoo.rst
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ Compiling to Wasm is very similar to compiling to JavaScript. See
Compiling to Wasm
=================

Dune has full support building Wasm_of_ocaml libraries and executables transparently.
There's no need to customize or enable anything to compile OCaml
Dune has full support for building wasm_of_ocaml libraries and executables transparently.
There's no need to customise or enable anything to compile OCaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the documentation mention the external dependencies that are required for the build ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now explicitly point to the github repository above.

libraries/executables to Wasm.

To build a Wasm executable, just define an executable as you would normally.
6 changes: 3 additions & 3 deletions test/blackbox-tests/test-cases/wasmoo/github3622.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This test demonstrates a bug in dune's separation compilation of jsoo.
std_exit.cmo wasn't being linked in the end, which was causing at_exit hooks not
being ran and channels not being flushed.
This test demonstrates a bug in Dune's separation compilation of JSOO.
`std_exit.cmo` wasn't being linked in the end, so the `at_exit`
hooks didn't run and the channels weren't flushed.

Setup fixtures:

2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/wasmoo/inline-tests.t/run.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Run inline tests using node js
Run inline tests using Node.js

$ cat >dune-project <<EOF
> (lang dune 3.17)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Compilation using jsoo
Compilation using WasmOO

$ dune build --display short bin/technologic.bc.js @install 2>&1 | \
> sed s,^\ *$(ocamlc -config-var c_compiler),\ \ C_COMPILER,g
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/wasmoo/public-libs.t/run.t
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Compilation of libraries with public-names
Compilation of libraries with `public-names`

$ dune build
10 changes: 5 additions & 5 deletions test/blackbox-tests/test-cases/wasmoo/simple.t/run.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Compilation using wasmoo
Compilation using WasmOO
$ dune build bin/technologic.bc.wasm.js @install --profile dev
$ node ./_build/default/bin/technologic.bc.wasm.js
buy it
@@ -12,7 +12,7 @@ Compilation using wasmoo
break it
fix it

Compilation using wasmoo with disable_dynamically_linked_foreign_archives = true
Compilation using WasmOO with `disable_dynamically_linked_foreign_archives = true`

$ cat >dune-workspace <<EOF
> (lang dune 3.17)
@@ -22,11 +22,11 @@ Compilation using wasmoo with disable_dynamically_linked_foreign_archives = true
$ dune clean
$ dune build bin/technologic.bc.wasm.js @install --profile dev

Js_of_ocaml whole program compilation works with
disable_dynamically_linked_foreign_archives = true:
Wasm_of_ocaml whole program compilation works with
`disable_dynamically_linked_foreign_archives = true`:

$ dune build bin/technologic.bc.wasm.js @install --profile release

We expect a runtime error when running this bc-for-jsoo file.
We expect a runtime error when running this `bc-for-jsoo` file.

$ ! if dune exe bin/technologic.bc-for-jsoo ; then true ; else false ; fi 2> /dev/null
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/wasmoo/submodes.t/run.t
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ The default is to only compile to JavaScript
Error: Don't know how to build main.bc.wasm.js
[1]

Compiling to Wasm. One can still use the .bc.js binary but it runs
Compiling to Wasm. One can still use the `.bc.js` binary but it runs
the Wasm code.

$ dune build --profile wasm