diff --git a/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch b/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch deleted file mode 100644 index d82b9d1fb8..0000000000 --- a/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/toplevel/lib/jsooTop.ml -+++ b/toplevel/lib/jsooTop.ml -@@ -65,6 +65,7 @@ - p := !p + len''; - len'' - -+[%%if ocaml_version < (4, 14, 0)] - let use ffp content = - let fname, oc = - Filename.open_temp_file ~mode:[ Open_binary ] "jsoo_toplevel" "fake_stdin" -@@ -78,10 +79,11 @@ - with e -> - Sys.remove fname; - raise e --[@@if ocaml_version < (4, 14, 0)] -+[%%endif] - -+[%%if ocaml_version >= (4, 14, 0)] - let use ffp content = Toploop.use_silently ffp (String content) --[@@if ocaml_version >= (4, 14, 0)] -+[%%endif] - - let execute printval ?pp_code ?highlight_location pp_answer s = - let lb = Lexing.from_function (refill_lexbuf s (ref 0) pp_code) in diff --git a/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/js_of_ocaml-top-effects.patch b/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/js_of_ocaml-top-effects.patch new file mode 100644 index 0000000000..d2f36b6d7b --- /dev/null +++ b/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/js_of_ocaml-top-effects.patch @@ -0,0 +1,16 @@ +diff --git a/runtime/js/jslib.js b/runtime/js/jslib.js +index 6a711bbb1d..081361a841 100644 +--- a/runtime/js/jslib.js ++++ b/runtime/js/jslib.js +@@ -134,8 +134,9 @@ function caml_jsoo_flags_use_js_string(unit) { + } + + //Provides: caml_jsoo_flags_effects ++//Requires: caml_string_of_jsstring + function caml_jsoo_flags_effects(unit) { +- return CONFIG("effects"); ++ return caml_string_of_jsstring(CONFIG("effects")); + } + + //Provides: caml_wrap_exception const (mutable) + diff --git a/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/js_of_ocaml-toplevel.patch b/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/js_of_ocaml-toplevel.patch new file mode 100644 index 0000000000..c291dee46c --- /dev/null +++ b/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/js_of_ocaml-toplevel.patch @@ -0,0 +1,208 @@ +diff --git a/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml b/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml +index 140a53b..d857289 100644 +--- a/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml ++++ b/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml +@@ -4,7 +4,7 @@ module J = Jsoo_runtime.Js + + type bytecode_sections = + { symb : Ocaml_compiler.Symtable.GlobalMap.t +- ; crcs : (string * Digest.t option) list ++ ; crcs : Import_info.t array + ; prim : string list + ; dlpt : string list + } +diff --git a/compiler/lib/link_js.ml b/compiler/lib/link_js.ml +index 68f0c32..3ec9ddc 100644 +--- a/compiler/lib/link_js.ml ++++ b/compiler/lib/link_js.ml +@@ -426,7 +426,7 @@ let link ~output ~linkall ~mklib ~toplevel ~files ~resolve_sourcemap_url ~(sourc + List.fold_left units ~init:StringSet.empty ~f:(fun acc (u : Unit_info.t) -> + StringSet.union acc (StringSet.of_list u.primitives)) + in +- let code = Parse_bytecode.link_info ~symbols:!sym ~primitives ~crcs:[] in ++ let code = Parse_bytecode.link_info ~symbols:!sym ~primitives ~crcs:[||] in + let b = Buffer.create 100 in + let fmt = Pretty_print.to_buffer b in + Driver.configure fmt; +diff --git a/compiler/lib/parse_bytecode.ml b/compiler/lib/parse_bytecode.ml +index 79e0c8f..bf8751a 100644 +--- a/compiler/lib/parse_bytecode.ml ++++ b/compiler/lib/parse_bytecode.ml +@@ -35,6 +35,9 @@ let predefined_exceptions = + + let new_closure_repr = Ocaml_version.compare Ocaml_version.current [ 4; 12 ] >= 0 + ++let crc_name v = Import_info.name v |> Compilation_unit.Name.to_string ++let crc_crc v = Import_info.crc v ++ + (* Read and manipulate debug section *) + module Debug : sig + type t +@@ -76,11 +79,11 @@ module Debug : sig + -> unit + + val read : +- t -> crcs:(string * string option) list -> includes:string list -> in_channel -> unit ++ t -> crcs:Import_info.t list -> includes:string list -> in_channel -> unit + + val read_event_list : + t +- -> crcs:(string * string option) list ++ -> crcs:Import_info.t list + -> includes:string list + -> orig:int + -> in_channel +@@ -146,6 +149,7 @@ end = struct + | Some _ as x -> x + | None -> Fs.find_in_path paths (name ^ ".ml") + ++ + let read_event + ~paths + ~crcs +@@ -216,7 +220,7 @@ end = struct + fun debug ~crcs ~includes ~orig ic -> + let crcs = + let t = Hashtbl.create 17 in +- List.iter crcs ~f:(fun (m, crc) -> Hashtbl.add t m crc); ++ List.iter crcs ~f:(fun i -> Hashtbl.add t (crc_name i) (crc_crc i)); + t + in + let evl : debug_event list = input_value ic in +@@ -2520,7 +2524,7 @@ module Toc : sig + + val read_data : t -> in_channel -> Obj.t array + +- val read_crcs : t -> in_channel -> (string * Digest.t option) list ++ val read_crcs : t -> in_channel -> Import_info.t array + + val read_prim : t -> in_channel -> string + +@@ -2570,9 +2574,10 @@ end = struct + let read_crcs toc ic = + ignore (seek_section toc ic "CRCS"); + let orig_crcs : Import_info.t array = input_value ic in +- List.map (Array.to_list orig_crcs) ~f:(fun import -> +- Import_info.name import |> Compilation_unit.Name.to_string, +- Import_info.crc import) ++ orig_crcs ++ (* List.map (Array.to_list orig_crcs) ~f:(fun import -> *) ++ (* Import_info.name import |> Compilation_unit.Name.to_string, *) ++ (* Import_info.crc import) *) + + let read_prim toc ic = + let prim_size = seek_section toc ic "PRIM" in +@@ -2587,12 +2592,13 @@ let read_primitives toc ic = + + type bytesections = + { symb : Ocaml_compiler.Symtable.GlobalMap.t +- ; crcs : (string * Digest.t option) list ++ ; crcs : Import_info.t array + ; prim : string list + ; dlpt : string list + } + [@@ocaml.warning "-unused-field"] + ++ + let from_exe + ?(includes = []) + ~linkall +@@ -2625,7 +2631,7 @@ let from_exe + | Some l -> List.mem s ~set:l + | None -> true) + in +- let crcs = List.filter ~f:(fun (unit, _crc) -> keep unit) orig_crcs in ++ let crcs = List.filter ~f:(fun info -> keep (crc_name info)) (Array.to_list orig_crcs) in + let symbols = + Ocaml_compiler.Symtable.GlobalMap.filter + (function +@@ -2690,7 +2696,7 @@ let from_exe + |> Array.of_list + in + (* Include linking information *) +- let sections = { symb = symbols; crcs; prim = primitives; dlpt = [] } in ++ let sections = { symb = symbols; crcs = Array.of_list crcs; prim = primitives; dlpt = [] } in + let gdata = Var.fresh () in + let need_gdata = ref false in + let infos = +diff --git a/compiler/lib/parse_bytecode.mli b/compiler/lib/parse_bytecode.mli +index 7bcc822..b34113b 100644 +--- a/compiler/lib/parse_bytecode.mli ++++ b/compiler/lib/parse_bytecode.mli +@@ -91,5 +91,5 @@ val predefined_exceptions : unit -> Code.program * Unit_info.t + val link_info : + symbols:Ocaml_compiler.Symtable.GlobalMap.t + -> primitives:StringSet.t +- -> crcs:(string * Digest.t option) list ++ -> crcs:Import_info.t array + -> Code.program +diff --git a/runtime/js/capsule.js b/runtime/js/capsule.js +new file mode 100644 +index 0000000..0c02acc +--- /dev/null ++++ b/runtime/js/capsule.js +@@ -0,0 +1,14 @@ ++//Provides: caml_capsule_mutex_new ++function caml_capsule_mutex_new () { ++ return 0; ++} ++ ++//Provides: caml_capsule_mutex_lock ++function caml_capsule_mutex_lock () { ++ return 0; ++} ++ ++//Provides: caml_capsule_mutex_unlock ++function caml_capsule_mutex_unlock () { ++ return 0; ++} +diff --git a/runtime/js/dune b/runtime/js/dune +index f31ffd1..7e76a14 100644 +--- a/runtime/js/dune ++++ b/runtime/js/dune +@@ -4,6 +4,7 @@ + (files + bigarray.js + bigstring.js ++ capsule.js + dynlink.js + fs.js + fs_fake.js +diff --git a/runtime/js/float32.js b/runtime/js/float32.js +index 0c60d3d..74bb433 100644 +--- a/runtime/js/float32.js ++++ b/runtime/js/float32.js +@@ -12,6 +12,11 @@ + by native programs and vice versa. + */ + ++//Provides: caml_is_boot_compiler ++function caml_is_boot_compiler(x) { ++ return 0; ++} ++ + //Provides: caml_float_of_float32 const + function caml_float_of_float32(x) { + return x; +diff --git a/runtime/js/toplevel.js b/runtime/js/toplevel.js +index 2e4547e..adaffd3 100644 +--- a/runtime/js/toplevel.js ++++ b/runtime/js/toplevel.js +@@ -94,7 +94,7 @@ function jsoo_toplevel_init_reloc(f) { + //Requires: caml_callback + //Requires: caml_string_of_uint8_array, caml_ba_to_typed_array + //Requires: jsoo_toplevel_compile, caml_failwith +-//Version: >= 5.2 ++//Version: >= 5.3 + function caml_reify_bytecode(code, debug, _digest) { + if (!jsoo_toplevel_compile) { + caml_failwith("Toplevel not initialized (jsoo_toplevel_compile)"); +@@ -107,7 +107,7 @@ function caml_reify_bytecode(code, debug, _digest) { + //Requires: caml_callback + //Requires: caml_string_of_uint8_array, caml_uint8_array_of_bytes + //Requires: jsoo_toplevel_compile, caml_failwith +-//Version: < 5.2 ++//Version: < 5.3 + function caml_reify_bytecode(code, debug, _digest) { + if (!jsoo_toplevel_compile) { + caml_failwith("Toplevel not initialized (jsoo_toplevel_compile)"); diff --git a/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/wasm_of_ocaml-sourcemap-contents.patch b/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/wasm_of_ocaml-sourcemap-contents.patch new file mode 100644 index 0000000000..dccaf3e0c3 --- /dev/null +++ b/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/files/wasm_of_ocaml-sourcemap-contents.patch @@ -0,0 +1,17 @@ +--- a/compiler/bin-wasm_of_ocaml/compile.ml ++++ b/compiler/bin-wasm_of_ocaml/compile.ml +@@ -226,8 +226,14 @@ + Option.iter sm ~f:(fun sm -> + if not sourcemap_don't_inline_content + then ++ let rewrite = ++ match Build_path_prefix_map.get_build_path_prefix_map () with ++ | Some map -> let map = Build_path_prefix_map.flip map in (fun path -> Build_path_prefix_map.rewrite map path) ++ | None -> Fun.id ++ in + Wasm_source_map.iter_sources sm (fun i j file -> ++ let file = rewrite file in + if Sys.file_exists file && not (Sys.is_directory file) + then + let sm = Fs.read_file file in + Zip.add_entry diff --git a/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/opam b/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/opam index cdb149c190..4668c125b9 100644 --- a/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/opam +++ b/packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/opam @@ -53,7 +53,6 @@ patches: [ "js_of_ocaml-add-unboxed-and-float-block.patch" "js_of_ocaml-ident-is_global.patch" "js_of_ocaml-remove-float-externals.patch" - "js_of_ocaml-ocaml_version-ppx.patch" "js_of_ocaml-test-diffs-caused-by-build-differences.patch" "js_of_ocaml-fix-build_fs.patch" "js_of_ocaml-iarray-primitives.patch" @@ -73,6 +72,7 @@ patches: [ "js_of_ocaml-jane-street-5.2-compatibility.patch" "js_of_ocaml-migrate-labeled-tuples-shims.patch" "js_of_ocaml-floatarray_create_local.patch" + "wasm_of_ocaml-sourcemap-contents.patch" "js_of_ocaml-jane-street-const_null-support.patch" "js_of_ocaml-float32.patch" "js_of_ocaml-caml_array_append.patch" @@ -84,6 +84,8 @@ patches: [ "js_of_ocaml-obj_stubs.patch" "js_of_ocaml-float32-2.patch" "dune.patch" + "js_of_ocaml-top-effects.patch" + "js_of_ocaml-toplevel.patch" ] extra-files: [ [ @@ -114,10 +116,6 @@ extra-files: [ "js_of_ocaml-remove-float-externals.patch" "sha256=a3aa95ee08210377c1470e5bf0f832bc27ad98299bca22c7a88eb9fd6c32e655" ] - [ - "js_of_ocaml-ocaml_version-ppx.patch" - "sha256=df6bcb6da8aa3dfd6bd0a178679987d41c400ec1803f4a66659cfc822d1b280f" - ] [ "js_of_ocaml-test-diffs-caused-by-build-differences.patch" "sha256=00d38ead67c67220351605d72c2b3a4e3faa8053087ef8ab47b7067b42900ba9" @@ -194,6 +192,10 @@ extra-files: [ "js_of_ocaml-floatarray_create_local.patch" "sha256=f17e392acc941dde475cb7be0654037df9b8d550aeae0d96b65394e4c4a1d4ca" ] + [ + "wasm_of_ocaml-sourcemap-contents.patch" + "sha256=93b7dddf6313836ce02fbe762c40380e20daefdd8b87ec885ee0f4ef779ad76b" + ] [ "js_of_ocaml-jane-street-const_null-support.patch" "sha256=e708cdc01c0cef3fce1cb9f31b33324977dcca1c166601905fcac1ef10262c3a" @@ -238,4 +240,12 @@ extra-files: [ "dune.patch" "sha256=f76da998ab76de56309bd0da3e4db1fb496d6d235d7a0ac2f78e3bafe098714e" ] + [ + "js_of_ocaml-top-effects.patch" + "sha256=638247bd3f7bacb99612353b29c0afdcc48598c5771a52602a96baabbc141370" + ] + [ + "js_of_ocaml-toplevel.patch" + "sha256=56c305aa9ed8cb35e9a3bee9fb17aaae244522bacb54a78115b03182a746b7b2" + ] ] diff --git a/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-obj_stubs.patch b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-obj_stubs.patch new file mode 100644 index 0000000000..abc1cf740b --- /dev/null +++ b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-obj_stubs.patch @@ -0,0 +1,49 @@ +--- a/runtime/js/obj.js ++++ b/runtime/js/obj.js +@@ -44,6 +44,22 @@ + return +Array.isArray(x); + } + ++//Provides: caml_obj_is_stack ++function caml_obj_is_stack(x) { ++ return 0; ++} ++ ++//Provides: caml_succ_scannable_prefix_len ++function caml_succ_scannable_prefix_len(x) { ++ return 0; ++} ++ ++//Provides: caml_obj_uniquely_reachable_words ++//Requires: caml_failwith ++function caml_obj_uniquely_reachable_words(x) { ++ caml_failwith("Obj.uniquely_reachable_words is not available in javascript."); ++} ++ + //Provides: caml_obj_tag + //Requires: caml_is_ml_bytes, caml_is_ml_string + function caml_obj_tag(x) { +--- a/runtime/wasm/obj.wat ++++ b/runtime/wasm/obj.wat +@@ -101,6 +101,21 @@ + (global $double_array_tag (export "double_array_tag") i32 (i32.const 254)) + (global $custom_tag i32 (i32.const 255)) + ++ (func (export "caml_obj_is_stack") ++ (param (ref eq)) (result (ref eq)) ++ (ref.i31 (i32.const 0))) ++ ++ (func (export "caml_succ_scannable_prefix_len") ++ (param (ref eq)) (result (ref eq)) ++ (ref.i31 (i32.const 0))) ++ ++ (@string $unique_words_unsupported "Obj.uniquely_reachable_words is not available in wasm.") ++ ++ (func (export "caml_obj_uniquely_reachable_words") ++ (param (ref eq)) (result (ref eq)) ++ (call $caml_failwith (global.get $unique_words_unsupported)) ++ (ref.i31 (i32.const 0))) ++ + (func $caml_is_closure (export "caml_is_closure") + (param $v (ref eq)) (result i32) + (i32.or (ref.test (ref $closure) (local.get $v)) diff --git a/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch deleted file mode 100644 index d82b9d1fb8..0000000000 --- a/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/toplevel/lib/jsooTop.ml -+++ b/toplevel/lib/jsooTop.ml -@@ -65,6 +65,7 @@ - p := !p + len''; - len'' - -+[%%if ocaml_version < (4, 14, 0)] - let use ffp content = - let fname, oc = - Filename.open_temp_file ~mode:[ Open_binary ] "jsoo_toplevel" "fake_stdin" -@@ -78,10 +79,11 @@ - with e -> - Sys.remove fname; - raise e --[@@if ocaml_version < (4, 14, 0)] -+[%%endif] - -+[%%if ocaml_version >= (4, 14, 0)] - let use ffp content = Toploop.use_silently ffp (String content) --[@@if ocaml_version >= (4, 14, 0)] -+[%%endif] - - let execute printval ?pp_code ?highlight_location pp_answer s = - let lb = Lexing.from_function (refill_lexbuf s (ref 0) pp_code) in diff --git a/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-top-effects.patch b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-top-effects.patch new file mode 100644 index 0000000000..d2f36b6d7b --- /dev/null +++ b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-top-effects.patch @@ -0,0 +1,16 @@ +diff --git a/runtime/js/jslib.js b/runtime/js/jslib.js +index 6a711bbb1d..081361a841 100644 +--- a/runtime/js/jslib.js ++++ b/runtime/js/jslib.js +@@ -134,8 +134,9 @@ function caml_jsoo_flags_use_js_string(unit) { + } + + //Provides: caml_jsoo_flags_effects ++//Requires: caml_string_of_jsstring + function caml_jsoo_flags_effects(unit) { +- return CONFIG("effects"); ++ return caml_string_of_jsstring(CONFIG("effects")); + } + + //Provides: caml_wrap_exception const (mutable) + diff --git a/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-toplevel.patch b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-toplevel.patch new file mode 100644 index 0000000000..c291dee46c --- /dev/null +++ b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-toplevel.patch @@ -0,0 +1,208 @@ +diff --git a/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml b/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml +index 140a53b..d857289 100644 +--- a/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml ++++ b/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml +@@ -4,7 +4,7 @@ module J = Jsoo_runtime.Js + + type bytecode_sections = + { symb : Ocaml_compiler.Symtable.GlobalMap.t +- ; crcs : (string * Digest.t option) list ++ ; crcs : Import_info.t array + ; prim : string list + ; dlpt : string list + } +diff --git a/compiler/lib/link_js.ml b/compiler/lib/link_js.ml +index 68f0c32..3ec9ddc 100644 +--- a/compiler/lib/link_js.ml ++++ b/compiler/lib/link_js.ml +@@ -426,7 +426,7 @@ let link ~output ~linkall ~mklib ~toplevel ~files ~resolve_sourcemap_url ~(sourc + List.fold_left units ~init:StringSet.empty ~f:(fun acc (u : Unit_info.t) -> + StringSet.union acc (StringSet.of_list u.primitives)) + in +- let code = Parse_bytecode.link_info ~symbols:!sym ~primitives ~crcs:[] in ++ let code = Parse_bytecode.link_info ~symbols:!sym ~primitives ~crcs:[||] in + let b = Buffer.create 100 in + let fmt = Pretty_print.to_buffer b in + Driver.configure fmt; +diff --git a/compiler/lib/parse_bytecode.ml b/compiler/lib/parse_bytecode.ml +index 79e0c8f..bf8751a 100644 +--- a/compiler/lib/parse_bytecode.ml ++++ b/compiler/lib/parse_bytecode.ml +@@ -35,6 +35,9 @@ let predefined_exceptions = + + let new_closure_repr = Ocaml_version.compare Ocaml_version.current [ 4; 12 ] >= 0 + ++let crc_name v = Import_info.name v |> Compilation_unit.Name.to_string ++let crc_crc v = Import_info.crc v ++ + (* Read and manipulate debug section *) + module Debug : sig + type t +@@ -76,11 +79,11 @@ module Debug : sig + -> unit + + val read : +- t -> crcs:(string * string option) list -> includes:string list -> in_channel -> unit ++ t -> crcs:Import_info.t list -> includes:string list -> in_channel -> unit + + val read_event_list : + t +- -> crcs:(string * string option) list ++ -> crcs:Import_info.t list + -> includes:string list + -> orig:int + -> in_channel +@@ -146,6 +149,7 @@ end = struct + | Some _ as x -> x + | None -> Fs.find_in_path paths (name ^ ".ml") + ++ + let read_event + ~paths + ~crcs +@@ -216,7 +220,7 @@ end = struct + fun debug ~crcs ~includes ~orig ic -> + let crcs = + let t = Hashtbl.create 17 in +- List.iter crcs ~f:(fun (m, crc) -> Hashtbl.add t m crc); ++ List.iter crcs ~f:(fun i -> Hashtbl.add t (crc_name i) (crc_crc i)); + t + in + let evl : debug_event list = input_value ic in +@@ -2520,7 +2524,7 @@ module Toc : sig + + val read_data : t -> in_channel -> Obj.t array + +- val read_crcs : t -> in_channel -> (string * Digest.t option) list ++ val read_crcs : t -> in_channel -> Import_info.t array + + val read_prim : t -> in_channel -> string + +@@ -2570,9 +2574,10 @@ end = struct + let read_crcs toc ic = + ignore (seek_section toc ic "CRCS"); + let orig_crcs : Import_info.t array = input_value ic in +- List.map (Array.to_list orig_crcs) ~f:(fun import -> +- Import_info.name import |> Compilation_unit.Name.to_string, +- Import_info.crc import) ++ orig_crcs ++ (* List.map (Array.to_list orig_crcs) ~f:(fun import -> *) ++ (* Import_info.name import |> Compilation_unit.Name.to_string, *) ++ (* Import_info.crc import) *) + + let read_prim toc ic = + let prim_size = seek_section toc ic "PRIM" in +@@ -2587,12 +2592,13 @@ let read_primitives toc ic = + + type bytesections = + { symb : Ocaml_compiler.Symtable.GlobalMap.t +- ; crcs : (string * Digest.t option) list ++ ; crcs : Import_info.t array + ; prim : string list + ; dlpt : string list + } + [@@ocaml.warning "-unused-field"] + ++ + let from_exe + ?(includes = []) + ~linkall +@@ -2625,7 +2631,7 @@ let from_exe + | Some l -> List.mem s ~set:l + | None -> true) + in +- let crcs = List.filter ~f:(fun (unit, _crc) -> keep unit) orig_crcs in ++ let crcs = List.filter ~f:(fun info -> keep (crc_name info)) (Array.to_list orig_crcs) in + let symbols = + Ocaml_compiler.Symtable.GlobalMap.filter + (function +@@ -2690,7 +2696,7 @@ let from_exe + |> Array.of_list + in + (* Include linking information *) +- let sections = { symb = symbols; crcs; prim = primitives; dlpt = [] } in ++ let sections = { symb = symbols; crcs = Array.of_list crcs; prim = primitives; dlpt = [] } in + let gdata = Var.fresh () in + let need_gdata = ref false in + let infos = +diff --git a/compiler/lib/parse_bytecode.mli b/compiler/lib/parse_bytecode.mli +index 7bcc822..b34113b 100644 +--- a/compiler/lib/parse_bytecode.mli ++++ b/compiler/lib/parse_bytecode.mli +@@ -91,5 +91,5 @@ val predefined_exceptions : unit -> Code.program * Unit_info.t + val link_info : + symbols:Ocaml_compiler.Symtable.GlobalMap.t + -> primitives:StringSet.t +- -> crcs:(string * Digest.t option) list ++ -> crcs:Import_info.t array + -> Code.program +diff --git a/runtime/js/capsule.js b/runtime/js/capsule.js +new file mode 100644 +index 0000000..0c02acc +--- /dev/null ++++ b/runtime/js/capsule.js +@@ -0,0 +1,14 @@ ++//Provides: caml_capsule_mutex_new ++function caml_capsule_mutex_new () { ++ return 0; ++} ++ ++//Provides: caml_capsule_mutex_lock ++function caml_capsule_mutex_lock () { ++ return 0; ++} ++ ++//Provides: caml_capsule_mutex_unlock ++function caml_capsule_mutex_unlock () { ++ return 0; ++} +diff --git a/runtime/js/dune b/runtime/js/dune +index f31ffd1..7e76a14 100644 +--- a/runtime/js/dune ++++ b/runtime/js/dune +@@ -4,6 +4,7 @@ + (files + bigarray.js + bigstring.js ++ capsule.js + dynlink.js + fs.js + fs_fake.js +diff --git a/runtime/js/float32.js b/runtime/js/float32.js +index 0c60d3d..74bb433 100644 +--- a/runtime/js/float32.js ++++ b/runtime/js/float32.js +@@ -12,6 +12,11 @@ + by native programs and vice versa. + */ + ++//Provides: caml_is_boot_compiler ++function caml_is_boot_compiler(x) { ++ return 0; ++} ++ + //Provides: caml_float_of_float32 const + function caml_float_of_float32(x) { + return x; +diff --git a/runtime/js/toplevel.js b/runtime/js/toplevel.js +index 2e4547e..adaffd3 100644 +--- a/runtime/js/toplevel.js ++++ b/runtime/js/toplevel.js +@@ -94,7 +94,7 @@ function jsoo_toplevel_init_reloc(f) { + //Requires: caml_callback + //Requires: caml_string_of_uint8_array, caml_ba_to_typed_array + //Requires: jsoo_toplevel_compile, caml_failwith +-//Version: >= 5.2 ++//Version: >= 5.3 + function caml_reify_bytecode(code, debug, _digest) { + if (!jsoo_toplevel_compile) { + caml_failwith("Toplevel not initialized (jsoo_toplevel_compile)"); +@@ -107,7 +107,7 @@ function caml_reify_bytecode(code, debug, _digest) { + //Requires: caml_callback + //Requires: caml_string_of_uint8_array, caml_uint8_array_of_bytes + //Requires: jsoo_toplevel_compile, caml_failwith +-//Version: < 5.2 ++//Version: < 5.3 + function caml_reify_bytecode(code, debug, _digest) { + if (!jsoo_toplevel_compile) { + caml_failwith("Toplevel not initialized (jsoo_toplevel_compile)"); diff --git a/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-version-directive-removal.patch b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-version-directive-removal.patch new file mode 100644 index 0000000000..37cd43ed47 --- /dev/null +++ b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/files/js_of_ocaml-version-directive-removal.patch @@ -0,0 +1,10 @@ +--- a/runtime/js/stdlib.js ++++ b/runtime/js/stdlib.js +@@ -302,7 +302,6 @@ + } + + //Provides: caml_process_pending_actions_with_root +-//Version: >= 5.3 + function caml_process_pending_actions_with_root(extra_root) { + return 0; + } diff --git a/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/opam b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/opam index 8e329d3a70..2107f9509a 100644 --- a/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/opam +++ b/packages/js_of_ocaml-ppx/js_of_ocaml-ppx.6.0.1+ox/opam @@ -42,7 +42,6 @@ patches: [ "js_of_ocaml-add-unboxed-and-float-block.patch" "js_of_ocaml-ident-is_global.patch" "js_of_ocaml-remove-float-externals.patch" - "js_of_ocaml-ocaml_version-ppx.patch" "js_of_ocaml-test-diffs-caused-by-build-differences.patch" "js_of_ocaml-fix-build_fs.patch" "js_of_ocaml-iarray-primitives.patch" @@ -70,8 +69,12 @@ patches: [ "js_of_ocaml-5.3-tests-runtime.patch" "js_of_ocaml-caml_bigstring_strncmp.patch" "wasm_of_ocaml-stub-caml_ml_set_channel_refill.patch" + "js_of_ocaml-version-directive-removal.patch" + "js_of_ocaml-obj_stubs.patch" "js_of_ocaml-float32-2.patch" "dune.patch" + "js_of_ocaml-top-effects.patch" + "js_of_ocaml-toplevel.patch" ] extra-files: [ [ @@ -102,10 +105,6 @@ extra-files: [ "js_of_ocaml-remove-float-externals.patch" "sha256=a3aa95ee08210377c1470e5bf0f832bc27ad98299bca22c7a88eb9fd6c32e655" ] - [ - "js_of_ocaml-ocaml_version-ppx.patch" - "sha256=df6bcb6da8aa3dfd6bd0a178679987d41c400ec1803f4a66659cfc822d1b280f" - ] [ "js_of_ocaml-test-diffs-caused-by-build-differences.patch" "sha256=00d38ead67c67220351605d72c2b3a4e3faa8053087ef8ab47b7067b42900ba9" @@ -214,6 +213,14 @@ extra-files: [ "wasm_of_ocaml-stub-caml_ml_set_channel_refill.patch" "sha256=005bce63009b9539b65036b22a7b7cc531755c7caa3cf1ed8d8697698090e136" ] + [ + "js_of_ocaml-version-directive-removal.patch" + "sha256=4b1565454d0b61bc2450ab7b5fff8c5c82babc104ea6b7b9a5446eb9a929740c" + ] + [ + "js_of_ocaml-obj_stubs.patch" + "sha256=9e9064f255c065a3152f665bd5b464040f3cfbbd2580aa4bb6e17be9c2b7fcc8" + ] [ "js_of_ocaml-float32-2.patch" "sha256=3ff1eda6175f96cc3a5b2c2ae1ee395c9317d248554282c5f157c723a9fae32f" @@ -222,4 +229,12 @@ extra-files: [ "dune.patch" "sha256=f76da998ab76de56309bd0da3e4db1fb496d6d235d7a0ac2f78e3bafe098714e" ] + [ + "js_of_ocaml-top-effects.patch" + "sha256=638247bd3f7bacb99612353b29c0afdcc48598c5771a52602a96baabbc141370" + ] + [ + "js_of_ocaml-toplevel.patch" + "sha256=56c305aa9ed8cb35e9a3bee9fb17aaae244522bacb54a78115b03182a746b7b2" + ] ] diff --git a/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-obj_stubs.patch b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-obj_stubs.patch new file mode 100644 index 0000000000..abc1cf740b --- /dev/null +++ b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-obj_stubs.patch @@ -0,0 +1,49 @@ +--- a/runtime/js/obj.js ++++ b/runtime/js/obj.js +@@ -44,6 +44,22 @@ + return +Array.isArray(x); + } + ++//Provides: caml_obj_is_stack ++function caml_obj_is_stack(x) { ++ return 0; ++} ++ ++//Provides: caml_succ_scannable_prefix_len ++function caml_succ_scannable_prefix_len(x) { ++ return 0; ++} ++ ++//Provides: caml_obj_uniquely_reachable_words ++//Requires: caml_failwith ++function caml_obj_uniquely_reachable_words(x) { ++ caml_failwith("Obj.uniquely_reachable_words is not available in javascript."); ++} ++ + //Provides: caml_obj_tag + //Requires: caml_is_ml_bytes, caml_is_ml_string + function caml_obj_tag(x) { +--- a/runtime/wasm/obj.wat ++++ b/runtime/wasm/obj.wat +@@ -101,6 +101,21 @@ + (global $double_array_tag (export "double_array_tag") i32 (i32.const 254)) + (global $custom_tag i32 (i32.const 255)) + ++ (func (export "caml_obj_is_stack") ++ (param (ref eq)) (result (ref eq)) ++ (ref.i31 (i32.const 0))) ++ ++ (func (export "caml_succ_scannable_prefix_len") ++ (param (ref eq)) (result (ref eq)) ++ (ref.i31 (i32.const 0))) ++ ++ (@string $unique_words_unsupported "Obj.uniquely_reachable_words is not available in wasm.") ++ ++ (func (export "caml_obj_uniquely_reachable_words") ++ (param (ref eq)) (result (ref eq)) ++ (call $caml_failwith (global.get $unique_words_unsupported)) ++ (ref.i31 (i32.const 0))) ++ + (func $caml_is_closure (export "caml_is_closure") + (param $v (ref eq)) (result i32) + (i32.or (ref.test (ref $closure) (local.get $v)) diff --git a/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch deleted file mode 100644 index d82b9d1fb8..0000000000 --- a/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/toplevel/lib/jsooTop.ml -+++ b/toplevel/lib/jsooTop.ml -@@ -65,6 +65,7 @@ - p := !p + len''; - len'' - -+[%%if ocaml_version < (4, 14, 0)] - let use ffp content = - let fname, oc = - Filename.open_temp_file ~mode:[ Open_binary ] "jsoo_toplevel" "fake_stdin" -@@ -78,10 +79,11 @@ - with e -> - Sys.remove fname; - raise e --[@@if ocaml_version < (4, 14, 0)] -+[%%endif] - -+[%%if ocaml_version >= (4, 14, 0)] - let use ffp content = Toploop.use_silently ffp (String content) --[@@if ocaml_version >= (4, 14, 0)] -+[%%endif] - - let execute printval ?pp_code ?highlight_location pp_answer s = - let lb = Lexing.from_function (refill_lexbuf s (ref 0) pp_code) in diff --git a/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-top-effects.patch b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-top-effects.patch new file mode 100644 index 0000000000..d2f36b6d7b --- /dev/null +++ b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-top-effects.patch @@ -0,0 +1,16 @@ +diff --git a/runtime/js/jslib.js b/runtime/js/jslib.js +index 6a711bbb1d..081361a841 100644 +--- a/runtime/js/jslib.js ++++ b/runtime/js/jslib.js +@@ -134,8 +134,9 @@ function caml_jsoo_flags_use_js_string(unit) { + } + + //Provides: caml_jsoo_flags_effects ++//Requires: caml_string_of_jsstring + function caml_jsoo_flags_effects(unit) { +- return CONFIG("effects"); ++ return caml_string_of_jsstring(CONFIG("effects")); + } + + //Provides: caml_wrap_exception const (mutable) + diff --git a/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-toplevel.patch b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-toplevel.patch new file mode 100644 index 0000000000..c291dee46c --- /dev/null +++ b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-toplevel.patch @@ -0,0 +1,208 @@ +diff --git a/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml b/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml +index 140a53b..d857289 100644 +--- a/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml ++++ b/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml +@@ -4,7 +4,7 @@ module J = Jsoo_runtime.Js + + type bytecode_sections = + { symb : Ocaml_compiler.Symtable.GlobalMap.t +- ; crcs : (string * Digest.t option) list ++ ; crcs : Import_info.t array + ; prim : string list + ; dlpt : string list + } +diff --git a/compiler/lib/link_js.ml b/compiler/lib/link_js.ml +index 68f0c32..3ec9ddc 100644 +--- a/compiler/lib/link_js.ml ++++ b/compiler/lib/link_js.ml +@@ -426,7 +426,7 @@ let link ~output ~linkall ~mklib ~toplevel ~files ~resolve_sourcemap_url ~(sourc + List.fold_left units ~init:StringSet.empty ~f:(fun acc (u : Unit_info.t) -> + StringSet.union acc (StringSet.of_list u.primitives)) + in +- let code = Parse_bytecode.link_info ~symbols:!sym ~primitives ~crcs:[] in ++ let code = Parse_bytecode.link_info ~symbols:!sym ~primitives ~crcs:[||] in + let b = Buffer.create 100 in + let fmt = Pretty_print.to_buffer b in + Driver.configure fmt; +diff --git a/compiler/lib/parse_bytecode.ml b/compiler/lib/parse_bytecode.ml +index 79e0c8f..bf8751a 100644 +--- a/compiler/lib/parse_bytecode.ml ++++ b/compiler/lib/parse_bytecode.ml +@@ -35,6 +35,9 @@ let predefined_exceptions = + + let new_closure_repr = Ocaml_version.compare Ocaml_version.current [ 4; 12 ] >= 0 + ++let crc_name v = Import_info.name v |> Compilation_unit.Name.to_string ++let crc_crc v = Import_info.crc v ++ + (* Read and manipulate debug section *) + module Debug : sig + type t +@@ -76,11 +79,11 @@ module Debug : sig + -> unit + + val read : +- t -> crcs:(string * string option) list -> includes:string list -> in_channel -> unit ++ t -> crcs:Import_info.t list -> includes:string list -> in_channel -> unit + + val read_event_list : + t +- -> crcs:(string * string option) list ++ -> crcs:Import_info.t list + -> includes:string list + -> orig:int + -> in_channel +@@ -146,6 +149,7 @@ end = struct + | Some _ as x -> x + | None -> Fs.find_in_path paths (name ^ ".ml") + ++ + let read_event + ~paths + ~crcs +@@ -216,7 +220,7 @@ end = struct + fun debug ~crcs ~includes ~orig ic -> + let crcs = + let t = Hashtbl.create 17 in +- List.iter crcs ~f:(fun (m, crc) -> Hashtbl.add t m crc); ++ List.iter crcs ~f:(fun i -> Hashtbl.add t (crc_name i) (crc_crc i)); + t + in + let evl : debug_event list = input_value ic in +@@ -2520,7 +2524,7 @@ module Toc : sig + + val read_data : t -> in_channel -> Obj.t array + +- val read_crcs : t -> in_channel -> (string * Digest.t option) list ++ val read_crcs : t -> in_channel -> Import_info.t array + + val read_prim : t -> in_channel -> string + +@@ -2570,9 +2574,10 @@ end = struct + let read_crcs toc ic = + ignore (seek_section toc ic "CRCS"); + let orig_crcs : Import_info.t array = input_value ic in +- List.map (Array.to_list orig_crcs) ~f:(fun import -> +- Import_info.name import |> Compilation_unit.Name.to_string, +- Import_info.crc import) ++ orig_crcs ++ (* List.map (Array.to_list orig_crcs) ~f:(fun import -> *) ++ (* Import_info.name import |> Compilation_unit.Name.to_string, *) ++ (* Import_info.crc import) *) + + let read_prim toc ic = + let prim_size = seek_section toc ic "PRIM" in +@@ -2587,12 +2592,13 @@ let read_primitives toc ic = + + type bytesections = + { symb : Ocaml_compiler.Symtable.GlobalMap.t +- ; crcs : (string * Digest.t option) list ++ ; crcs : Import_info.t array + ; prim : string list + ; dlpt : string list + } + [@@ocaml.warning "-unused-field"] + ++ + let from_exe + ?(includes = []) + ~linkall +@@ -2625,7 +2631,7 @@ let from_exe + | Some l -> List.mem s ~set:l + | None -> true) + in +- let crcs = List.filter ~f:(fun (unit, _crc) -> keep unit) orig_crcs in ++ let crcs = List.filter ~f:(fun info -> keep (crc_name info)) (Array.to_list orig_crcs) in + let symbols = + Ocaml_compiler.Symtable.GlobalMap.filter + (function +@@ -2690,7 +2696,7 @@ let from_exe + |> Array.of_list + in + (* Include linking information *) +- let sections = { symb = symbols; crcs; prim = primitives; dlpt = [] } in ++ let sections = { symb = symbols; crcs = Array.of_list crcs; prim = primitives; dlpt = [] } in + let gdata = Var.fresh () in + let need_gdata = ref false in + let infos = +diff --git a/compiler/lib/parse_bytecode.mli b/compiler/lib/parse_bytecode.mli +index 7bcc822..b34113b 100644 +--- a/compiler/lib/parse_bytecode.mli ++++ b/compiler/lib/parse_bytecode.mli +@@ -91,5 +91,5 @@ val predefined_exceptions : unit -> Code.program * Unit_info.t + val link_info : + symbols:Ocaml_compiler.Symtable.GlobalMap.t + -> primitives:StringSet.t +- -> crcs:(string * Digest.t option) list ++ -> crcs:Import_info.t array + -> Code.program +diff --git a/runtime/js/capsule.js b/runtime/js/capsule.js +new file mode 100644 +index 0000000..0c02acc +--- /dev/null ++++ b/runtime/js/capsule.js +@@ -0,0 +1,14 @@ ++//Provides: caml_capsule_mutex_new ++function caml_capsule_mutex_new () { ++ return 0; ++} ++ ++//Provides: caml_capsule_mutex_lock ++function caml_capsule_mutex_lock () { ++ return 0; ++} ++ ++//Provides: caml_capsule_mutex_unlock ++function caml_capsule_mutex_unlock () { ++ return 0; ++} +diff --git a/runtime/js/dune b/runtime/js/dune +index f31ffd1..7e76a14 100644 +--- a/runtime/js/dune ++++ b/runtime/js/dune +@@ -4,6 +4,7 @@ + (files + bigarray.js + bigstring.js ++ capsule.js + dynlink.js + fs.js + fs_fake.js +diff --git a/runtime/js/float32.js b/runtime/js/float32.js +index 0c60d3d..74bb433 100644 +--- a/runtime/js/float32.js ++++ b/runtime/js/float32.js +@@ -12,6 +12,11 @@ + by native programs and vice versa. + */ + ++//Provides: caml_is_boot_compiler ++function caml_is_boot_compiler(x) { ++ return 0; ++} ++ + //Provides: caml_float_of_float32 const + function caml_float_of_float32(x) { + return x; +diff --git a/runtime/js/toplevel.js b/runtime/js/toplevel.js +index 2e4547e..adaffd3 100644 +--- a/runtime/js/toplevel.js ++++ b/runtime/js/toplevel.js +@@ -94,7 +94,7 @@ function jsoo_toplevel_init_reloc(f) { + //Requires: caml_callback + //Requires: caml_string_of_uint8_array, caml_ba_to_typed_array + //Requires: jsoo_toplevel_compile, caml_failwith +-//Version: >= 5.2 ++//Version: >= 5.3 + function caml_reify_bytecode(code, debug, _digest) { + if (!jsoo_toplevel_compile) { + caml_failwith("Toplevel not initialized (jsoo_toplevel_compile)"); +@@ -107,7 +107,7 @@ function caml_reify_bytecode(code, debug, _digest) { + //Requires: caml_callback + //Requires: caml_string_of_uint8_array, caml_uint8_array_of_bytes + //Requires: jsoo_toplevel_compile, caml_failwith +-//Version: < 5.2 ++//Version: < 5.3 + function caml_reify_bytecode(code, debug, _digest) { + if (!jsoo_toplevel_compile) { + caml_failwith("Toplevel not initialized (jsoo_toplevel_compile)"); diff --git a/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-version-directive-removal.patch b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-version-directive-removal.patch new file mode 100644 index 0000000000..37cd43ed47 --- /dev/null +++ b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/files/js_of_ocaml-version-directive-removal.patch @@ -0,0 +1,10 @@ +--- a/runtime/js/stdlib.js ++++ b/runtime/js/stdlib.js +@@ -302,7 +302,6 @@ + } + + //Provides: caml_process_pending_actions_with_root +-//Version: >= 5.3 + function caml_process_pending_actions_with_root(extra_root) { + return 0; + } diff --git a/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/opam b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/opam index 3ab118d373..7c920967f9 100644 --- a/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/opam +++ b/packages/js_of_ocaml-toplevel/js_of_ocaml-toplevel.6.0.1+ox/opam @@ -45,7 +45,6 @@ patches: [ "js_of_ocaml-add-unboxed-and-float-block.patch" "js_of_ocaml-ident-is_global.patch" "js_of_ocaml-remove-float-externals.patch" - "js_of_ocaml-ocaml_version-ppx.patch" "js_of_ocaml-test-diffs-caused-by-build-differences.patch" "js_of_ocaml-fix-build_fs.patch" "js_of_ocaml-iarray-primitives.patch" @@ -73,8 +72,12 @@ patches: [ "js_of_ocaml-5.3-tests-runtime.patch" "js_of_ocaml-caml_bigstring_strncmp.patch" "wasm_of_ocaml-stub-caml_ml_set_channel_refill.patch" + "js_of_ocaml-version-directive-removal.patch" + "js_of_ocaml-obj_stubs.patch" "js_of_ocaml-float32-2.patch" "dune.patch" + "js_of_ocaml-top-effects.patch" + "js_of_ocaml-toplevel.patch" ] extra-files: [ [ @@ -105,10 +108,6 @@ extra-files: [ "js_of_ocaml-remove-float-externals.patch" "sha256=a3aa95ee08210377c1470e5bf0f832bc27ad98299bca22c7a88eb9fd6c32e655" ] - [ - "js_of_ocaml-ocaml_version-ppx.patch" - "sha256=df6bcb6da8aa3dfd6bd0a178679987d41c400ec1803f4a66659cfc822d1b280f" - ] [ "js_of_ocaml-test-diffs-caused-by-build-differences.patch" "sha256=00d38ead67c67220351605d72c2b3a4e3faa8053087ef8ab47b7067b42900ba9" @@ -217,6 +216,14 @@ extra-files: [ "wasm_of_ocaml-stub-caml_ml_set_channel_refill.patch" "sha256=005bce63009b9539b65036b22a7b7cc531755c7caa3cf1ed8d8697698090e136" ] + [ + "js_of_ocaml-version-directive-removal.patch" + "sha256=4b1565454d0b61bc2450ab7b5fff8c5c82babc104ea6b7b9a5446eb9a929740c" + ] + [ + "js_of_ocaml-obj_stubs.patch" + "sha256=9e9064f255c065a3152f665bd5b464040f3cfbbd2580aa4bb6e17be9c2b7fcc8" + ] [ "js_of_ocaml-float32-2.patch" "sha256=3ff1eda6175f96cc3a5b2c2ae1ee395c9317d248554282c5f157c723a9fae32f" @@ -225,4 +232,12 @@ extra-files: [ "dune.patch" "sha256=f76da998ab76de56309bd0da3e4db1fb496d6d235d7a0ac2f78e3bafe098714e" ] + [ + "js_of_ocaml-top-effects.patch" + "sha256=638247bd3f7bacb99612353b29c0afdcc48598c5771a52602a96baabbc141370" + ] + [ + "js_of_ocaml-toplevel.patch" + "sha256=56c305aa9ed8cb35e9a3bee9fb17aaae244522bacb54a78115b03182a746b7b2" + ] ] diff --git a/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-obj_stubs.patch b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-obj_stubs.patch new file mode 100644 index 0000000000..abc1cf740b --- /dev/null +++ b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-obj_stubs.patch @@ -0,0 +1,49 @@ +--- a/runtime/js/obj.js ++++ b/runtime/js/obj.js +@@ -44,6 +44,22 @@ + return +Array.isArray(x); + } + ++//Provides: caml_obj_is_stack ++function caml_obj_is_stack(x) { ++ return 0; ++} ++ ++//Provides: caml_succ_scannable_prefix_len ++function caml_succ_scannable_prefix_len(x) { ++ return 0; ++} ++ ++//Provides: caml_obj_uniquely_reachable_words ++//Requires: caml_failwith ++function caml_obj_uniquely_reachable_words(x) { ++ caml_failwith("Obj.uniquely_reachable_words is not available in javascript."); ++} ++ + //Provides: caml_obj_tag + //Requires: caml_is_ml_bytes, caml_is_ml_string + function caml_obj_tag(x) { +--- a/runtime/wasm/obj.wat ++++ b/runtime/wasm/obj.wat +@@ -101,6 +101,21 @@ + (global $double_array_tag (export "double_array_tag") i32 (i32.const 254)) + (global $custom_tag i32 (i32.const 255)) + ++ (func (export "caml_obj_is_stack") ++ (param (ref eq)) (result (ref eq)) ++ (ref.i31 (i32.const 0))) ++ ++ (func (export "caml_succ_scannable_prefix_len") ++ (param (ref eq)) (result (ref eq)) ++ (ref.i31 (i32.const 0))) ++ ++ (@string $unique_words_unsupported "Obj.uniquely_reachable_words is not available in wasm.") ++ ++ (func (export "caml_obj_uniquely_reachable_words") ++ (param (ref eq)) (result (ref eq)) ++ (call $caml_failwith (global.get $unique_words_unsupported)) ++ (ref.i31 (i32.const 0))) ++ + (func $caml_is_closure (export "caml_is_closure") + (param $v (ref eq)) (result i32) + (i32.or (ref.test (ref $closure) (local.get $v)) diff --git a/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch deleted file mode 100644 index d82b9d1fb8..0000000000 --- a/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-ocaml_version-ppx.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/toplevel/lib/jsooTop.ml -+++ b/toplevel/lib/jsooTop.ml -@@ -65,6 +65,7 @@ - p := !p + len''; - len'' - -+[%%if ocaml_version < (4, 14, 0)] - let use ffp content = - let fname, oc = - Filename.open_temp_file ~mode:[ Open_binary ] "jsoo_toplevel" "fake_stdin" -@@ -78,10 +79,11 @@ - with e -> - Sys.remove fname; - raise e --[@@if ocaml_version < (4, 14, 0)] -+[%%endif] - -+[%%if ocaml_version >= (4, 14, 0)] - let use ffp content = Toploop.use_silently ffp (String content) --[@@if ocaml_version >= (4, 14, 0)] -+[%%endif] - - let execute printval ?pp_code ?highlight_location pp_answer s = - let lb = Lexing.from_function (refill_lexbuf s (ref 0) pp_code) in diff --git a/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-top-effects.patch b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-top-effects.patch new file mode 100644 index 0000000000..d2f36b6d7b --- /dev/null +++ b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-top-effects.patch @@ -0,0 +1,16 @@ +diff --git a/runtime/js/jslib.js b/runtime/js/jslib.js +index 6a711bbb1d..081361a841 100644 +--- a/runtime/js/jslib.js ++++ b/runtime/js/jslib.js +@@ -134,8 +134,9 @@ function caml_jsoo_flags_use_js_string(unit) { + } + + //Provides: caml_jsoo_flags_effects ++//Requires: caml_string_of_jsstring + function caml_jsoo_flags_effects(unit) { +- return CONFIG("effects"); ++ return caml_string_of_jsstring(CONFIG("effects")); + } + + //Provides: caml_wrap_exception const (mutable) + diff --git a/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-toplevel.patch b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-toplevel.patch new file mode 100644 index 0000000000..c291dee46c --- /dev/null +++ b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-toplevel.patch @@ -0,0 +1,208 @@ +diff --git a/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml b/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml +index 140a53b..d857289 100644 +--- a/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml ++++ b/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml +@@ -4,7 +4,7 @@ module J = Jsoo_runtime.Js + + type bytecode_sections = + { symb : Ocaml_compiler.Symtable.GlobalMap.t +- ; crcs : (string * Digest.t option) list ++ ; crcs : Import_info.t array + ; prim : string list + ; dlpt : string list + } +diff --git a/compiler/lib/link_js.ml b/compiler/lib/link_js.ml +index 68f0c32..3ec9ddc 100644 +--- a/compiler/lib/link_js.ml ++++ b/compiler/lib/link_js.ml +@@ -426,7 +426,7 @@ let link ~output ~linkall ~mklib ~toplevel ~files ~resolve_sourcemap_url ~(sourc + List.fold_left units ~init:StringSet.empty ~f:(fun acc (u : Unit_info.t) -> + StringSet.union acc (StringSet.of_list u.primitives)) + in +- let code = Parse_bytecode.link_info ~symbols:!sym ~primitives ~crcs:[] in ++ let code = Parse_bytecode.link_info ~symbols:!sym ~primitives ~crcs:[||] in + let b = Buffer.create 100 in + let fmt = Pretty_print.to_buffer b in + Driver.configure fmt; +diff --git a/compiler/lib/parse_bytecode.ml b/compiler/lib/parse_bytecode.ml +index 79e0c8f..bf8751a 100644 +--- a/compiler/lib/parse_bytecode.ml ++++ b/compiler/lib/parse_bytecode.ml +@@ -35,6 +35,9 @@ let predefined_exceptions = + + let new_closure_repr = Ocaml_version.compare Ocaml_version.current [ 4; 12 ] >= 0 + ++let crc_name v = Import_info.name v |> Compilation_unit.Name.to_string ++let crc_crc v = Import_info.crc v ++ + (* Read and manipulate debug section *) + module Debug : sig + type t +@@ -76,11 +79,11 @@ module Debug : sig + -> unit + + val read : +- t -> crcs:(string * string option) list -> includes:string list -> in_channel -> unit ++ t -> crcs:Import_info.t list -> includes:string list -> in_channel -> unit + + val read_event_list : + t +- -> crcs:(string * string option) list ++ -> crcs:Import_info.t list + -> includes:string list + -> orig:int + -> in_channel +@@ -146,6 +149,7 @@ end = struct + | Some _ as x -> x + | None -> Fs.find_in_path paths (name ^ ".ml") + ++ + let read_event + ~paths + ~crcs +@@ -216,7 +220,7 @@ end = struct + fun debug ~crcs ~includes ~orig ic -> + let crcs = + let t = Hashtbl.create 17 in +- List.iter crcs ~f:(fun (m, crc) -> Hashtbl.add t m crc); ++ List.iter crcs ~f:(fun i -> Hashtbl.add t (crc_name i) (crc_crc i)); + t + in + let evl : debug_event list = input_value ic in +@@ -2520,7 +2524,7 @@ module Toc : sig + + val read_data : t -> in_channel -> Obj.t array + +- val read_crcs : t -> in_channel -> (string * Digest.t option) list ++ val read_crcs : t -> in_channel -> Import_info.t array + + val read_prim : t -> in_channel -> string + +@@ -2570,9 +2574,10 @@ end = struct + let read_crcs toc ic = + ignore (seek_section toc ic "CRCS"); + let orig_crcs : Import_info.t array = input_value ic in +- List.map (Array.to_list orig_crcs) ~f:(fun import -> +- Import_info.name import |> Compilation_unit.Name.to_string, +- Import_info.crc import) ++ orig_crcs ++ (* List.map (Array.to_list orig_crcs) ~f:(fun import -> *) ++ (* Import_info.name import |> Compilation_unit.Name.to_string, *) ++ (* Import_info.crc import) *) + + let read_prim toc ic = + let prim_size = seek_section toc ic "PRIM" in +@@ -2587,12 +2592,13 @@ let read_primitives toc ic = + + type bytesections = + { symb : Ocaml_compiler.Symtable.GlobalMap.t +- ; crcs : (string * Digest.t option) list ++ ; crcs : Import_info.t array + ; prim : string list + ; dlpt : string list + } + [@@ocaml.warning "-unused-field"] + ++ + let from_exe + ?(includes = []) + ~linkall +@@ -2625,7 +2631,7 @@ let from_exe + | Some l -> List.mem s ~set:l + | None -> true) + in +- let crcs = List.filter ~f:(fun (unit, _crc) -> keep unit) orig_crcs in ++ let crcs = List.filter ~f:(fun info -> keep (crc_name info)) (Array.to_list orig_crcs) in + let symbols = + Ocaml_compiler.Symtable.GlobalMap.filter + (function +@@ -2690,7 +2696,7 @@ let from_exe + |> Array.of_list + in + (* Include linking information *) +- let sections = { symb = symbols; crcs; prim = primitives; dlpt = [] } in ++ let sections = { symb = symbols; crcs = Array.of_list crcs; prim = primitives; dlpt = [] } in + let gdata = Var.fresh () in + let need_gdata = ref false in + let infos = +diff --git a/compiler/lib/parse_bytecode.mli b/compiler/lib/parse_bytecode.mli +index 7bcc822..b34113b 100644 +--- a/compiler/lib/parse_bytecode.mli ++++ b/compiler/lib/parse_bytecode.mli +@@ -91,5 +91,5 @@ val predefined_exceptions : unit -> Code.program * Unit_info.t + val link_info : + symbols:Ocaml_compiler.Symtable.GlobalMap.t + -> primitives:StringSet.t +- -> crcs:(string * Digest.t option) list ++ -> crcs:Import_info.t array + -> Code.program +diff --git a/runtime/js/capsule.js b/runtime/js/capsule.js +new file mode 100644 +index 0000000..0c02acc +--- /dev/null ++++ b/runtime/js/capsule.js +@@ -0,0 +1,14 @@ ++//Provides: caml_capsule_mutex_new ++function caml_capsule_mutex_new () { ++ return 0; ++} ++ ++//Provides: caml_capsule_mutex_lock ++function caml_capsule_mutex_lock () { ++ return 0; ++} ++ ++//Provides: caml_capsule_mutex_unlock ++function caml_capsule_mutex_unlock () { ++ return 0; ++} +diff --git a/runtime/js/dune b/runtime/js/dune +index f31ffd1..7e76a14 100644 +--- a/runtime/js/dune ++++ b/runtime/js/dune +@@ -4,6 +4,7 @@ + (files + bigarray.js + bigstring.js ++ capsule.js + dynlink.js + fs.js + fs_fake.js +diff --git a/runtime/js/float32.js b/runtime/js/float32.js +index 0c60d3d..74bb433 100644 +--- a/runtime/js/float32.js ++++ b/runtime/js/float32.js +@@ -12,6 +12,11 @@ + by native programs and vice versa. + */ + ++//Provides: caml_is_boot_compiler ++function caml_is_boot_compiler(x) { ++ return 0; ++} ++ + //Provides: caml_float_of_float32 const + function caml_float_of_float32(x) { + return x; +diff --git a/runtime/js/toplevel.js b/runtime/js/toplevel.js +index 2e4547e..adaffd3 100644 +--- a/runtime/js/toplevel.js ++++ b/runtime/js/toplevel.js +@@ -94,7 +94,7 @@ function jsoo_toplevel_init_reloc(f) { + //Requires: caml_callback + //Requires: caml_string_of_uint8_array, caml_ba_to_typed_array + //Requires: jsoo_toplevel_compile, caml_failwith +-//Version: >= 5.2 ++//Version: >= 5.3 + function caml_reify_bytecode(code, debug, _digest) { + if (!jsoo_toplevel_compile) { + caml_failwith("Toplevel not initialized (jsoo_toplevel_compile)"); +@@ -107,7 +107,7 @@ function caml_reify_bytecode(code, debug, _digest) { + //Requires: caml_callback + //Requires: caml_string_of_uint8_array, caml_uint8_array_of_bytes + //Requires: jsoo_toplevel_compile, caml_failwith +-//Version: < 5.2 ++//Version: < 5.3 + function caml_reify_bytecode(code, debug, _digest) { + if (!jsoo_toplevel_compile) { + caml_failwith("Toplevel not initialized (jsoo_toplevel_compile)"); diff --git a/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-version-directive-removal.patch b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-version-directive-removal.patch new file mode 100644 index 0000000000..37cd43ed47 --- /dev/null +++ b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/files/js_of_ocaml-version-directive-removal.patch @@ -0,0 +1,10 @@ +--- a/runtime/js/stdlib.js ++++ b/runtime/js/stdlib.js +@@ -302,7 +302,6 @@ + } + + //Provides: caml_process_pending_actions_with_root +-//Version: >= 5.3 + function caml_process_pending_actions_with_root(extra_root) { + return 0; + } diff --git a/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/opam b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/opam index a394cc27a5..8dacb8ffdc 100644 --- a/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/opam +++ b/packages/js_of_ocaml/js_of_ocaml.6.0.1+ox/opam @@ -42,7 +42,6 @@ patches: [ "js_of_ocaml-add-unboxed-and-float-block.patch" "js_of_ocaml-ident-is_global.patch" "js_of_ocaml-remove-float-externals.patch" - "js_of_ocaml-ocaml_version-ppx.patch" "js_of_ocaml-test-diffs-caused-by-build-differences.patch" "js_of_ocaml-fix-build_fs.patch" "js_of_ocaml-iarray-primitives.patch" @@ -70,8 +69,12 @@ patches: [ "js_of_ocaml-5.3-tests-runtime.patch" "js_of_ocaml-caml_bigstring_strncmp.patch" "wasm_of_ocaml-stub-caml_ml_set_channel_refill.patch" + "js_of_ocaml-version-directive-removal.patch" + "js_of_ocaml-obj_stubs.patch" "js_of_ocaml-float32-2.patch" "dune.patch" + "js_of_ocaml-top-effects.patch" + "js_of_ocaml-toplevel.patch" ] extra-files: [ [ @@ -102,10 +105,6 @@ extra-files: [ "js_of_ocaml-remove-float-externals.patch" "sha256=a3aa95ee08210377c1470e5bf0f832bc27ad98299bca22c7a88eb9fd6c32e655" ] - [ - "js_of_ocaml-ocaml_version-ppx.patch" - "sha256=df6bcb6da8aa3dfd6bd0a178679987d41c400ec1803f4a66659cfc822d1b280f" - ] [ "js_of_ocaml-test-diffs-caused-by-build-differences.patch" "sha256=00d38ead67c67220351605d72c2b3a4e3faa8053087ef8ab47b7067b42900ba9" @@ -214,6 +213,14 @@ extra-files: [ "wasm_of_ocaml-stub-caml_ml_set_channel_refill.patch" "sha256=005bce63009b9539b65036b22a7b7cc531755c7caa3cf1ed8d8697698090e136" ] + [ + "js_of_ocaml-version-directive-removal.patch" + "sha256=4b1565454d0b61bc2450ab7b5fff8c5c82babc104ea6b7b9a5446eb9a929740c" + ] + [ + "js_of_ocaml-obj_stubs.patch" + "sha256=9e9064f255c065a3152f665bd5b464040f3cfbbd2580aa4bb6e17be9c2b7fcc8" + ] [ "js_of_ocaml-float32-2.patch" "sha256=3ff1eda6175f96cc3a5b2c2ae1ee395c9317d248554282c5f157c723a9fae32f" @@ -222,4 +229,12 @@ extra-files: [ "dune.patch" "sha256=f76da998ab76de56309bd0da3e4db1fb496d6d235d7a0ac2f78e3bafe098714e" ] + [ + "js_of_ocaml-top-effects.patch" + "sha256=638247bd3f7bacb99612353b29c0afdcc48598c5771a52602a96baabbc141370" + ] + [ + "js_of_ocaml-toplevel.patch" + "sha256=56c305aa9ed8cb35e9a3bee9fb17aaae244522bacb54a78115b03182a746b7b2" + ] ]