Skip to content

Commit f19cfdf

Browse files
authored
flambda-backend: Remove Config.runtime5 check in dll.ml; guard the one in symbol.ml (#2072)
* Harmonize caml_dynlink_open_lib interface between 4 and 5 runtimes * Add check for running inside ocamlc
1 parent dba4687 commit f19cfdf

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

bytecomp/dll.ml

+1-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ type dll_handle
1919
type dll_address
2020
type dll_mode = For_checking | For_execution
2121

22-
external dll_open5: string -> dll_handle = "caml_dynlink_open_lib"
23-
24-
external dll_open4: dll_mode -> string -> dll_handle = "caml_dynlink_open_lib"
25-
26-
let dll_open mode path =
27-
if Config.runtime5 then dll_open5 path else dll_open4 mode path
28-
22+
external dll_open: dll_mode -> string -> dll_handle = "caml_dynlink_open_lib"
2923
external dll_close: dll_handle -> unit = "caml_dynlink_close_lib"
3024
external dll_sym: dll_handle -> string -> dll_address
3125
= "caml_dynlink_lookup_symbol"

driver/maindriver.ml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ open Clflags
1919
module Options = Main_args.Make_bytecomp_options (Main_args.Default.Main)
2020

2121
let main argv ppf =
22+
Symbol.this_is_ocamlc ();
2223
let program = "ocamlc" in
2324
Clflags.add_arguments __LOC__ Options.list;
2425
Clflags.add_arguments __LOC__

runtime/dynlink.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ void caml_free_shared_libs(void)
235235

236236
#define Handle_val(v) (*((void **) (v)))
237237

238-
CAMLprim value caml_dynlink_open_lib(value filename)
238+
/* The mode argument is here for compatibility with runtime4. */
239+
/* CR ocaml 5 runtime: Remove [mode] when all-runtime5. */
240+
CAMLprim value caml_dynlink_open_lib(value mode, value filename)
239241
{
240242
void * handle;
241243
value result;

utils/symbol.ml

+6
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,17 @@ end)
4747

4848
let caml_symbol_prefix = "caml"
4949

50+
(* CR ocaml 5 runtime: Remove this_is_ocamlc and force_runtime4_symbols once
51+
fully on runtime5 *)
52+
let this_is_ocamlc = ref false
5053
let force_runtime4_symbols = ref false
5154

5255
let separator () =
56+
if !this_is_ocamlc then
57+
Misc.fatal_error "Didn't expect utils/symbol.ml to be used in ocamlc";
5358
if Config.runtime5 && not !force_runtime4_symbols then "." else "__"
5459

60+
let this_is_ocamlc () = this_is_ocamlc := true
5561
let force_runtime4_symbols () = force_runtime4_symbols := true
5662

5763
let linkage_name t = t.linkage_name

utils/symbol.mli

+3
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ val is_predef_exn : t -> bool
4949
(* Temporary means by which to force symbol names to use __. Only for use
5050
for flambda2 flexpect tests. *)
5151
val force_runtime4_symbols : unit -> unit
52+
53+
(* Temporary means to identify that the program running is ocamlc. *)
54+
val this_is_ocamlc : unit -> unit

0 commit comments

Comments
 (0)