From e7d00081aaa9f59e1d75e087e3eedb6ee4af4ec2 Mon Sep 17 00:00:00 2001 From: Spotandjake <spotandjake@hotmail.com> Date: Sat, 17 May 2025 13:36:03 -0400 Subject: [PATCH 1/2] chore!: Require jsoo >= 6.0 This supersedes #211 in switching to jsoo 6, the main difference is we need to be using a later version of node on our opam workflows, similar to the changes required here https://github.com/grain-lang/libbinaryen/pull/114 --- .github/workflows/opam.yml | 6 ++++++ binaryen.opam | 2 +- package.json | 2 +- src/expression.js | 3 ++- src/module.js | 9 ++++++--- test/dune | 3 +-- test/test.ml | 2 +- 7 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/opam.yml b/.github/workflows/opam.yml index 16c43336..2132cb71 100644 --- a/.github/workflows/opam.yml +++ b/.github/workflows/opam.yml @@ -24,6 +24,12 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: submodules: "recursive" + + - name: Setup node.js + uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0 + with: + node-version: "22" + check-latest: true - name: Setup OCaml ${{ matrix.ocaml-compiler }} uses: ocaml/setup-ocaml@c2e6bb92370612b89f302c3aaefa1da45ee2d702 # v3.2.15 diff --git a/binaryen.opam b/binaryen.opam index b97829e8..25033cba 100644 --- a/binaryen.opam +++ b/binaryen.opam @@ -15,6 +15,6 @@ depends: [ "ocaml" {>= "4.13.0"} "dune" {>= "3.0.0"} "dune-configurator" {>= "3.0.0"} - "js_of_ocaml-compiler" {>= "4.1.0" < "6.0.0"} + "js_of_ocaml-compiler" {>= "6.0.0" < "7.0.0"} "libbinaryen" {>= "116.0.0" < "117.0.0"} ] diff --git a/package.json b/package.json index 69a9bb85..a042d0e8 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "@opam/dune-configurator": ">= 3.0.0" }, "devDependencies": { - "@opam/js_of_ocaml-compiler": ">= 4.1.0 < 6.0.0", + "@opam/js_of_ocaml-compiler": ">= 6.0.0 < 7.0.0", "@opam/ocamlformat": "0.24.1", "@opam/ocaml-lsp-server": ">= 1.9.1 < 1.13.0" }, diff --git a/src/expression.js b/src/expression.js index 50dc0da1..fa8c8332 100644 --- a/src/expression.js +++ b/src/expression.js @@ -882,11 +882,12 @@ function caml_binaryen_expression_id_array_len() { //Provides: caml_binaryen_expression_print //Requires: Binaryen +//Requires: caml_sys_fds //Requires: caml_string_of_jsstring //Requires: caml_ml_output, caml_ml_string_length function caml_binaryen_expression_print(expr) { var text = Binaryen.emitText(expr); - var chanid = 1; // stdout + var chanid = caml_sys_fds[1].chanid; // stdout var s = caml_string_of_jsstring(text); caml_ml_output(chanid, s, 0, caml_ml_string_length(s)); } diff --git a/src/module.js b/src/module.js index 4c344679..dbe0492d 100644 --- a/src/module.js +++ b/src/module.js @@ -17,31 +17,34 @@ function caml_binaryen_module_parse(text) { } //Provides: caml_binaryen_module_print +//Requires: caml_sys_fds //Requires: caml_string_of_jsstring //Requires: caml_ml_output, caml_ml_string_length function caml_binaryen_module_print(wasm_mod) { var text = wasm_mod.emitText(); - var chanid = 1; // stdout + var chanid = caml_sys_fds[1].chanid; // stdout var s = caml_string_of_jsstring(text); caml_ml_output(chanid, s, 0, caml_ml_string_length(s)); } //Provides: caml_binaryen_module_print_asmjs +//Requires: caml_sys_fds //Requires: caml_string_of_jsstring //Requires: caml_ml_output, caml_ml_string_length function caml_binaryen_module_print_asmjs(wasm_mod) { var asm = wasm_mod.emitAsmjs(); - var chanid = 1; // stdout + var chanid = caml_sys_fds[1].chanid; // stdout var s = caml_string_of_jsstring(asm); caml_ml_output(chanid, s, 0, caml_ml_string_length(s)); } //Provides: caml_binaryen_module_print_stack_ir +//Requires: caml_sys_fds //Requires: caml_string_of_jsstring, caml_js_from_bool //Requires: caml_ml_output, caml_ml_string_length function caml_binaryen_module_print_stack_ir(wasm_mod, optimize) { var stackir = wasm_mod.emitStackIR(caml_js_from_bool(optimize)); - var chanid = 1; // stdout + var chanid = caml_sys_fds[1].chanid; // stdout var s = caml_string_of_jsstring(stackir); caml_ml_output(chanid, s, 0, caml_ml_string_length(s)); } diff --git a/test/dune b/test/dune index e9f7192b..e391294b 100644 --- a/test/dune +++ b/test/dune @@ -4,8 +4,7 @@ (modes exe js) (flags :standard - (:include ./config/ocamlopt_flags.sexp)) - (js_of_ocaml)) + (:include ./config/ocamlopt_flags.sexp))) (rule (alias runtest) diff --git a/test/test.ml b/test/test.ml index 55e949e9..e0339e08 100644 --- a/test/test.ml +++ b/test/test.ml @@ -82,7 +82,7 @@ let add = let _ = assert (Expression.Block.get_name add = Some "add") (* Create the add function *) -let adder = Function.add_function wasm_mod "adder" (params ()) results [||] add +let _adder = Function.add_function wasm_mod "adder" (params ()) results [||] add let call_adder = Expression.Call_indirect.make wasm_mod "table" From 85cad7e5810b717aa2a674df56967b381dfe2167 Mon Sep 17 00:00:00 2001 From: Spotandjake <spotandjake@hotmail.com> Date: Sat, 17 May 2025 16:00:34 -0400 Subject: [PATCH 2/2] chore: Remove jsoo changes --- binaryen.opam | 2 +- package.json | 2 +- src/expression.js | 3 +-- src/module.js | 9 +++------ test/dune | 3 ++- test/test.ml | 2 +- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/binaryen.opam b/binaryen.opam index 25033cba..b97829e8 100644 --- a/binaryen.opam +++ b/binaryen.opam @@ -15,6 +15,6 @@ depends: [ "ocaml" {>= "4.13.0"} "dune" {>= "3.0.0"} "dune-configurator" {>= "3.0.0"} - "js_of_ocaml-compiler" {>= "6.0.0" < "7.0.0"} + "js_of_ocaml-compiler" {>= "4.1.0" < "6.0.0"} "libbinaryen" {>= "116.0.0" < "117.0.0"} ] diff --git a/package.json b/package.json index a042d0e8..69a9bb85 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "@opam/dune-configurator": ">= 3.0.0" }, "devDependencies": { - "@opam/js_of_ocaml-compiler": ">= 6.0.0 < 7.0.0", + "@opam/js_of_ocaml-compiler": ">= 4.1.0 < 6.0.0", "@opam/ocamlformat": "0.24.1", "@opam/ocaml-lsp-server": ">= 1.9.1 < 1.13.0" }, diff --git a/src/expression.js b/src/expression.js index fa8c8332..50dc0da1 100644 --- a/src/expression.js +++ b/src/expression.js @@ -882,12 +882,11 @@ function caml_binaryen_expression_id_array_len() { //Provides: caml_binaryen_expression_print //Requires: Binaryen -//Requires: caml_sys_fds //Requires: caml_string_of_jsstring //Requires: caml_ml_output, caml_ml_string_length function caml_binaryen_expression_print(expr) { var text = Binaryen.emitText(expr); - var chanid = caml_sys_fds[1].chanid; // stdout + var chanid = 1; // stdout var s = caml_string_of_jsstring(text); caml_ml_output(chanid, s, 0, caml_ml_string_length(s)); } diff --git a/src/module.js b/src/module.js index dbe0492d..4c344679 100644 --- a/src/module.js +++ b/src/module.js @@ -17,34 +17,31 @@ function caml_binaryen_module_parse(text) { } //Provides: caml_binaryen_module_print -//Requires: caml_sys_fds //Requires: caml_string_of_jsstring //Requires: caml_ml_output, caml_ml_string_length function caml_binaryen_module_print(wasm_mod) { var text = wasm_mod.emitText(); - var chanid = caml_sys_fds[1].chanid; // stdout + var chanid = 1; // stdout var s = caml_string_of_jsstring(text); caml_ml_output(chanid, s, 0, caml_ml_string_length(s)); } //Provides: caml_binaryen_module_print_asmjs -//Requires: caml_sys_fds //Requires: caml_string_of_jsstring //Requires: caml_ml_output, caml_ml_string_length function caml_binaryen_module_print_asmjs(wasm_mod) { var asm = wasm_mod.emitAsmjs(); - var chanid = caml_sys_fds[1].chanid; // stdout + var chanid = 1; // stdout var s = caml_string_of_jsstring(asm); caml_ml_output(chanid, s, 0, caml_ml_string_length(s)); } //Provides: caml_binaryen_module_print_stack_ir -//Requires: caml_sys_fds //Requires: caml_string_of_jsstring, caml_js_from_bool //Requires: caml_ml_output, caml_ml_string_length function caml_binaryen_module_print_stack_ir(wasm_mod, optimize) { var stackir = wasm_mod.emitStackIR(caml_js_from_bool(optimize)); - var chanid = caml_sys_fds[1].chanid; // stdout + var chanid = 1; // stdout var s = caml_string_of_jsstring(stackir); caml_ml_output(chanid, s, 0, caml_ml_string_length(s)); } diff --git a/test/dune b/test/dune index e391294b..e9f7192b 100644 --- a/test/dune +++ b/test/dune @@ -4,7 +4,8 @@ (modes exe js) (flags :standard - (:include ./config/ocamlopt_flags.sexp))) + (:include ./config/ocamlopt_flags.sexp)) + (js_of_ocaml)) (rule (alias runtest) diff --git a/test/test.ml b/test/test.ml index e0339e08..55e949e9 100644 --- a/test/test.ml +++ b/test/test.ml @@ -82,7 +82,7 @@ let add = let _ = assert (Expression.Block.get_name add = Some "add") (* Create the add function *) -let _adder = Function.add_function wasm_mod "adder" (params ()) results [||] add +let adder = Function.add_function wasm_mod "adder" (params ()) results [||] add let call_adder = Expression.Call_indirect.make wasm_mod "table"