From 333ac3d5b1cbc0b387ae542ad8fd487bcca3ba7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Fri, 13 Sep 2024 11:54:10 +0200 Subject: [PATCH] Marshal header size change in OCaml 5.1 --- runtime/wasm/dune | 14 ++++++++++++-- runtime/wasm/marshal.wat | 4 ++-- runtime/wasm/version-dependent/post-5.2.wat | 2 ++ .../version-dependent/{pre-5.2.wat => pre-5.1.wat} | 2 ++ 4 files changed, 18 insertions(+), 4 deletions(-) rename runtime/wasm/version-dependent/{pre-5.2.wat => pre-5.1.wat} (96%) diff --git a/runtime/wasm/dune b/runtime/wasm/dune index e9afd68df..4ec8e8693 100644 --- a/runtime/wasm/dune +++ b/runtime/wasm/dune @@ -13,9 +13,19 @@ (rule (target version-dependent.wat) - (deps version-dependent/pre-5.2.wat) + (deps version-dependent/post-5.2.wat) + (enabled_if + (and + (>= %{ocaml_version} 5.1.0) + (< %{ocaml_version} 5.2.0))) + (action + (copy %{deps} %{target}))) + +(rule + (target version-dependent.wat) + (deps version-dependent/pre-5.1.wat) (enabled_if - (< %{ocaml_version} 5.2.0)) + (< %{ocaml_version} 5.1.0)) (action (copy %{deps} %{target}))) diff --git a/runtime/wasm/marshal.wat b/runtime/wasm/marshal.wat index 491d84385..0bd5d2a48 100644 --- a/runtime/wasm/marshal.wat +++ b/runtime/wasm/marshal.wat @@ -48,8 +48,8 @@ (func $caml_find_custom_operations (param (ref $string)) (result (ref null $custom_operations)))) - (global $caml_marshal_header_size (export "caml_marshal_header_size") - (mut i32) (i32.const 20)) + (import "version-dependent" "caml_marshal_header_size" + (global $caml_marshal_header_size (mut i32))) (global $input_val_from_string (ref $string) (array.new_fixed $string 21 diff --git a/runtime/wasm/version-dependent/post-5.2.wat b/runtime/wasm/version-dependent/post-5.2.wat index cd99832f1..7ff553459 100644 --- a/runtime/wasm/version-dependent/post-5.2.wat +++ b/runtime/wasm/version-dependent/post-5.2.wat @@ -54,4 +54,6 @@ (ref.i31 (i32.const 0)) (array.new_fixed $block 2 (ref.i31 (i32.const 0)) (local.get $res)))) (ref.i31 (local.get $id))) + + (global (export "caml_marshal_header_size") (mut i32) (i32.const 16)) ) diff --git a/runtime/wasm/version-dependent/pre-5.2.wat b/runtime/wasm/version-dependent/pre-5.1.wat similarity index 96% rename from runtime/wasm/version-dependent/pre-5.2.wat rename to runtime/wasm/version-dependent/pre-5.1.wat index 27c671a24..33e68ccef 100644 --- a/runtime/wasm/version-dependent/pre-5.2.wat +++ b/runtime/wasm/version-dependent/pre-5.1.wat @@ -41,4 +41,6 @@ (global.set $caml_domain_id (local.get $old)) (drop (call $caml_ml_mutex_unlock (local.get $mutex))) (ref.i31 (local.get $id))) + + (global (export "caml_marshal_header_size") (mut i32) (i32.const 20)) )