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

Implementation of effects based on the Stack Switching proposal #1832

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c4f9e34
JS runtime: implement more system primitives
vouillon Jan 29, 2025
ac4bfc7
Wasm runtime: clean-up
vouillon Jan 29, 2025
7ce1c04
Wasm runtime: implement more system primitives
vouillon Jan 29, 2025
9900af6
Don't add Unix.putenv
vouillon Feb 4, 2025
bd4f178
Add test from OCaml test suite
vouillon Feb 5, 2025
15daf96
Add tests
vouillon Feb 10, 2025
3b759c9
Changes
vouillon Feb 10, 2025
180cf56
Wasm runtime: implement ocaml_unix_findfirst / ocaml_unix_findnext
vouillon Feb 12, 2025
7086b43
More flexible API to call binaryen tools
vouillon Jan 30, 2025
a99e0cb
WAT file preprocessor
vouillon Dec 17, 2024
f1ef75f
Use preprocessor to manage runtime changes between OCaml versions
vouillon Jan 30, 2025
e837171
WAT preprocessor: add tests
vouillon Jan 30, 2025
d0110a0
Syntactic sugar for strings
vouillon Jan 31, 2025
6b93e99
Wasm runtime: use string syntactic sugar
vouillon Jan 31, 2025
b7cb34e
Preprocessor: use the export name to name functions without id
vouillon Jan 31, 2025
19b44c2
Preprocessor: add references to the Wasm standards
vouillon Feb 3, 2025
34e890e
Preprocessor: move tools as subcommands inside wasm_of_ocaml
vouillon Feb 4, 2025
5eddf4e
CHANGES.md
vouillon Feb 4, 2025
f83fb5c
Support for several Wasm runtimes (depending on flags)
vouillon Dec 17, 2024
72cc2ee
Runtimes: add primitive caml_throw_js_exception
vouillon Feb 19, 2025
f454362
WASI runtime
vouillon Dec 17, 2024
cf63988
Add flag trap-on-exception
vouillon Feb 14, 2025
18f11a1
Node wrapper: support for using alternative Wasm engines
vouillon Feb 14, 2025
6de0001
CI updates
vouillon Feb 14, 2025
5429b7e
Command line option to use the new exception handling instructions
vouillon Feb 14, 2025
cf93cdb
CI: use Wizard engine as well
vouillon Feb 6, 2025
c1fc50d
WASI: support for separate compilation
vouillon Feb 19, 2025
617722d
CI: install a version on Binaryen with stack-switching support
vouillon Feb 6, 2025
3f14732
Effects based on Stack Switching proposal
vouillon Mar 24, 2024
b3a2f0d
Update Wasm linker to support stack switching instructions
vouillon Feb 18, 2025
3f4555c
Use fork of Wizard engine
vouillon Feb 14, 2025
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
90 changes: 90 additions & 0 deletions .github/actions/install-binaryen/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Install Binaryen

inputs:
repository:
description: 'Repository name with owner. For example, actions/checkout'
default: WebAssembly/binaryen
ref:
description: >
The branch, tag or SHA to checkout. When checking out the repository that
triggered a workflow, this defaults to the reference or SHA for that
event. Otherwise, uses the default branch.
default: latest
build:
description: Whether we should build from source
default: false
runs:
using: composite
steps:
- name: Restore cached binaryen
if: ${{ inputs.build && inputs.build != 'false' }}
id: cache-binaryen
uses: actions/cache/restore@v4
with:
path: binaryen
key: ${{ runner.os }}-binaryen-${{ inputs.ref }}

- name: Checkout binaryen
if: ${{ inputs.build && inputs.build != 'false' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
path: binaryen
submodules: true
ref: ${{ inputs.ref == 'latest' && 'main' || inputs.ref }}

- name: Install ninja (Linux)
if: ${{ inputs.build && inputs.build != 'false' && runner.os == 'Linux' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
shell: bash
run: sudo apt-get install ninja-build

- name: Install ninja (MacOS)
if: ${{ inputs.build && inputs.build != 'false' && runner.os == 'macOS' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
shell: bash
run: brew install ninja

- name: Build binaryen
if: ${{ inputs.build && inputs.build != 'false' && runner.os != 'Windows' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
working-directory: ./binaryen
shell: bash
run: |
cmake -G Ninja .
ninja

- name: Install binaryen build dependencies (Windows)
if: ${{ inputs.build && inputs.build != 'false' && runner.os == 'Windows' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
working-directory: ./binaryen
shell: bash
run: opam install conf-cmake conf-c++

- name: Build binaryen (Windows)
if: ${{ inputs.build && inputs.build != 'false' && runner.os == 'Windows' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
working-directory: ./binaryen
shell: bash
run: |
opam exec -- cmake . -DBUILD_STATIC_LIB=ON -DBUILD_TESTS=off -DINSTALL_LIBS=off -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc
make -j 4

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

- name: Set binaryen's path
if: ${{ inputs.build && inputs.build != 'false' && runner.os != 'Windows' }}
shell: bash
run: echo "$GITHUB_WORKSPACE/binaryen/bin" >> $GITHUB_PATH

- name: Copy binaryen's tools (Windows)
if: ${{ inputs.build && inputs.build != 'false' && runner.os == 'Windows' }}
shell: bash
run: cp $GITHUB_WORKSPACE/binaryen/bin/wasm-{merge,opt}.exe _opam/bin

- name: Download Binaryen
if: ${{ ! inputs.build || inputs.build == 'false' }}
uses: Aandreba/[email protected]
with:
token: ${{ github.token }}
version: ${{ inputs.ref }}
108 changes: 103 additions & 5 deletions .github/workflows/build-wasm_of_ocaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
matrix:
os:
- ubuntu-latest
os-name:
- Ubuntu
ocaml-compiler:
- "4.14"
- "5.0"
Expand All @@ -27,30 +29,50 @@ jobs:
- false
all_jane_street_tests:
- false
wasi:
- false
include:
- os: macos-latest
os-name: MacOS
ocaml-compiler: "5.3"
separate_compilation: true
jane_street_tests: false
all_jane_street_tests: false
wasi: false
- os: windows-latest
os-name: Windows
ocaml-compiler: "5.2"
separate_compilation: true
jane_street_tests: true
all_jane_street_tests: true
wasi: false
- os: ubuntu-latest
os-name: Ubuntu
ocaml-compiler: "5.2"
separate_compilation: true
jane_street_tests: true
all_jane_street_tests: true
wasi: false
- os: ubuntu-latest
os-name: Ubuntu
ocaml-compiler: "5.2"
separate_compilation: false
jane_street_tests: true
all_jane_street_tests: false
wasi: false
- os: ubuntu-latest
os-name: Ubuntu
ocaml-compiler: "5.3"
separate_compilation: true
jane_street_tests: false
all_jane_street_tests: false
wasi: true

runs-on: ${{ matrix.os }}

name:
${{ matrix.wasi && 'WASI / ' || '' }}${{ (! matrix.separate_compilation) && 'Whole program / ' || ''}}${{ matrix.ocaml-compiler }} / ${{ matrix.os-name }}${{ matrix.all_jane_street_tests && ' / Jane Street tests' || ''}}

steps:
- name: Set git to use LF
if: ${{ matrix.os == 'windows-latest' && matrix.ocaml-compiler < 5.2 }}
Expand All @@ -77,15 +99,67 @@ jobs:
with:
node-version: latest

- name: Set-up Rust toolchain
if: matrix.wasi
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Checkout Wasmtime
if: matrix.wasi
uses: actions/checkout@v4
with:
repository: bytecodealliance/wasmtime
path: wasmtime
submodules: true

- name: Build Wasmtime
if: matrix.wasi
working-directory: ./wasmtime
run: |
cargo build
echo `pwd`/target/debug >> "$GITHUB_PATH"

- name: Checkout Virgil
if: matrix.wasi
uses: actions/checkout@v4
with:
repository: vouillon/virgil
ref: wasi
path: virgil

- name: Build Virgil
if: matrix.wasi
working-directory: ./virgil
run: |
export PATH=$PATH:`pwd`/bin
echo `pwd`/bin >> "$GITHUB_PATH"
make

- name: Checkout Wizard engine
if: matrix.wasi
uses: actions/checkout@v4
with:
repository: vouillon/wizard-engine
ref: wasi
path: wizard-engine

- name: Build Wizard engine
if: matrix.wasi
working-directory: ./wizard-engine
run: |
make -j 4
echo `pwd`/bin >> "$GITHUB_PATH"

- name: Set-up OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- name: Set-up Binaryen
uses: Aandreba/setup-binaryen@v1.0.0
- name: Install Binaryen
uses: ./wasm_of_ocaml/.github/actions/install-binaryen
with:
token: ${{ github.token }}
build: true
repository: vouillon/binaryen
ref: stack-switching-fixes

- name: Pin faked binaryen-bin package
# It's faster to use a cached version
Expand Down Expand Up @@ -127,7 +201,7 @@ jobs:
opam install num cohttp-lwt-unix ppx_expect cstruct uucp

- name: Run tests
if: ${{ matrix.separate_compilation }}
if: ${{ matrix.separate_compilation && ! matrix.wasi }}
working-directory: ./wasm_of_ocaml
run: opam exec -- dune build @runtest-wasm

Expand All @@ -136,11 +210,35 @@ jobs:
# See https://github.com/libuv/libuv/issues/3622

- name: Run tests with CPS effects
if: ${{ matrix.ocaml-compiler >= '5.' && matrix.separate_compilation }}
if: ${{ matrix.ocaml-compiler >= '5.' && matrix.separate_compilation && ! matrix.wasi }}
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./wasm_of_ocaml
run: opam exec -- dune build @runtest-wasm --profile with-effects

- name: Run tests (WASI runtime - node)
if: ${{ false }}
working-directory: ./wasm_of_ocaml
run: opam exec -- dune build @runtest-wasm --profile wasi

- name: Run tests (WASI runtime - Wizard engine)
if: ${{ matrix.wasi }}
working-directory: ./wasm_of_ocaml
env:
WASM_ENGINE: wizard-fast
WASI_FLAGS: --enable use-new-eh
# continue-on-error: true
run: opam exec -- dune build @runtest-wasm --profile wasi

- name: Run tests (WASI runtime - wasmtime)
if: ${{ false }}
working-directory: ./wasm_of_ocaml
env:
WASM_ENGINE: wasmtime
WASI_FLAGS: --enable trap-on-exception
RUST_BACKTRACE: 0
continue-on-error: true
run: opam exec -- dune build @runtest-wasm --profile wasi

- name: Run Base tests
if: matrix.all_jane_street_tests
continue-on-error: ${{ matrix.os == 'windows-latest' }}
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ jobs:
- run: opam install conf-pkg-config conf-mingw-w64-g++-i686 conf-mingw-w64-g++-x86_64
if: runner.os == 'Windows'

- name: Set-up Binaryen
uses: Aandreba/setup-binaryen@v1.0.0
- name: Install Binaryen
uses: ./.github/actions/install-binaryen
with:
token: ${{ github.token }}
build: true
repository: vouillon/binaryen
ref: stack-switching-fixes

- name: Install faked binaryen-bin package
# It's faster to use a cached version
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# dev

## Features/Changes
* Runtime: support more Unix functions (#1829)
* Compiler: use a Wasm text files preprocessor (#1822)

# 6.0.1 (2025-02-07) - Lille

## Features/Changes
Expand Down
Loading
Loading