My working unpac repository

Add Sys.runtime_executable

In native mode, same as Sys.executable_name, in bytecode, the path to
the interpreter executing Sys.executable_name, which may not be the same
from the same file.

+19
+4
Changes
··· 11 11 12 12 ### Standard library: 13 13 14 + - #13728: Add Sys.runtime_executable containing the full path (if available) to 15 + the currently executing runtime. 16 + (David Allsopp, review by Nicolás Ojeda Bär and Daniel Bünzli) 17 + 14 18 - #13916: Add Option.product and Option.Syntax. 15 19 (Nicolás Ojeda Bär, review by Daniel Bünzli, Gabriel Scherer and David 16 20 Allsopp)
+5
stdlib/sys.ml.in
··· 23 23 24 24 external get_config: unit -> string * int * bool = "caml_sys_get_config" 25 25 external get_executable_name : unit -> string = "caml_sys_executable_name" 26 + external get_proc_self_exe : unit -> string option = "caml_sys_proc_self_exe" 26 27 external argv : string array = "%sys_argv" 27 28 external big_endian : unit -> bool = "%big_endian" 28 29 external word_size : unit -> int = "%word_size" ··· 34 35 external get_backend_type : unit -> backend_type = "%backend_type" 35 36 36 37 let executable_name = get_executable_name() 38 + let runtime_executable = 39 + match get_proc_self_exe () with 40 + | None -> executable_name 41 + | Some proc_self_exe -> proc_self_exe 37 42 let (os_type, _, _) = get_config() 38 43 let backend_type = get_backend_type () 39 44 let big_endian = big_endian ()
+10
stdlib/sys.mli
··· 32 32 on the platform and whether the program was compiled to bytecode or a native 33 33 executable. *) 34 34 35 + val runtime_executable : string 36 + (** The name of the file containing the runtime currently running. For 37 + native code, this is always {!executable_name}, but in bytecode it may be 38 + ocamlrun, for example. This name may be absolute or relative to the current 39 + directory, depending on the platform (Linux, Windows and macOS should all 40 + return absolute paths). 41 + 42 + @since 5.5 43 + *) 44 + 35 45 external file_exists : string -> bool = "caml_sys_file_exists" 36 46 (** Test if a file with the given name exists. *) 37 47