The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add -set-runtime-default

Allows the default location used by the bytecode runtime for the
Standard Library to be overridden when creating bytecode executables.

+86 -5
+5
Changes
··· 339 339 (Gabriel Scherer, review by Nicolás Ojeda Bär and Florian Angeletti, 340 340 report by Kate Deplaix) 341 341 342 + - #14244: Add -set-runtime-default option to the compiler, allowing the default 343 + value of the Standard Library location used by the runtime to be overridden. 344 + (Antonin Décimo, review by David Allsopp, Jonah Beckford, Damien Doligez and 345 + Samuel Hym) 346 + 342 347 - #14190: `ocaml -e` now also processes `-init` (previously it was ignored). 343 348 (Emile Trotignon, review by David Allsopp and @ygrek) 344 349
+8
Makefile
··· 976 976 977 977 ocamlc_BYTECODE_LINKFLAGS = -compat-32 -g 978 978 979 + ifeq "$(IN_COREBOOT_CYCLE)" "true" 980 + ocamlc_BYTECODE_LINKFLAGS += -set-runtime-default standard_library_default=. 981 + endif 982 + 979 983 partialclean:: 980 984 rm -f ocamlc ocamlc.exe ocamlc.opt ocamlc.opt.exe 981 985 ··· 1712 1716 $(MAKE) lex-allopt 1713 1717 1714 1718 ocamllex_BYTECODE_LINKFLAGS = -compat-32 1719 + 1720 + ifeq "$(IN_COREBOOT_CYCLE)" "true" 1721 + ocamllex_BYTECODE_LINKFLAGS += -set-runtime-default standard_library_default=. 1722 + endif 1715 1723 1716 1724 partialclean:: 1717 1725 rm -f lex/*.cm* lex/*.o lex/*.obj \
+4 -1
asmcomp/asmlink.ml
··· 229 229 (fun i name -> compile_phrase (Cmm_helpers.predef_exception i name)) 230 230 Runtimedef.builtin_exceptions; 231 231 if need_stdlib then begin 232 + let standard_library_default = 233 + Option.value ~default:Config.standard_library_default 234 + !Clflags.standard_library_default in 232 235 compile_phrase 233 236 (Cmm_helpers.emit_global_string_constant 234 - "caml_standard_library_nat" Config.standard_library_default) 237 + "caml_standard_library_nat" standard_library_default) 235 238 end; 236 239 compile_phrase (Cmm_helpers.global_table name_list); 237 240 let globals_map = make_globals_map units_list ~crc_interfaces in
+10 -2
bytecomp/bytelink.ml
··· 529 529 already included in the runtime. *) 530 530 if standalone && needs_stdlib then begin 531 531 (* OCaml Standard Library Default location *) 532 - output_string outchan Config.standard_library_default; 532 + let standard_library_default = 533 + Option.value 534 + ~default:Config.standard_library_default 535 + !Clflags.standard_library_default 536 + in 537 + output_string outchan standard_library_default; 533 538 Bytesections.record toc_writer OSLD 534 539 end; 535 540 (* The map of global identifiers *) ··· 639 644 Buffer.contents b 640 645 641 646 let emit_runtime_standard_library_default outchan = 642 - let literal = c_string_literal_of_string Config.standard_library_default in 647 + let stdlib = 648 + let default = Config.standard_library_default in 649 + Option.value ~default !Clflags.standard_library_default in 650 + let literal = c_string_literal_of_string stdlib in 643 651 Printf.fprintf outchan 644 652 "const char_os * caml_runtime_standard_library_default = %s;\n" literal 645 653
+13
driver/compenv.ml
··· 43 43 prerr_endline err; 44 44 raise (Exit_with_status 2) 45 45 46 + let fatalf fmt = Printf.ksprintf fatal fmt 47 + 46 48 let extract_output = function 47 49 | Some s -> s 48 50 | None -> ··· 778 780 Printf.sprintf "Usage: %s <options> <files>\nOptions are:" program in 779 781 Printf.printf "%s\n%s" help_msg err_msg; 780 782 raise (Exit_with_status 0) 783 + 784 + let parse_runtime_parameter opt = 785 + let k, setting = 786 + try Misc.cut_at opt '=' 787 + with Not_found -> 788 + fatalf "-set-runtime-default: invalid runtime parameter '%s'. \ 789 + Expected <name>=<value>." opt in 790 + if k = "standard_library_default" then 791 + Clflags.standard_library_default := Some setting 792 + else 793 + fatalf "-set-runtime-default: unrecognized runtime parameter %s." k
+4
driver/compenv.mli
··· 23 23 val print_version_string : unit -> 'a 24 24 val print_standard_library : unit -> 'a 25 25 val fatal : string -> 'a 26 + val fatalf : ('a, unit, string, 'b) format4 -> 'a 26 27 27 28 val first_ccopts : string list ref 28 29 val first_ppx : string list ref ··· 79 80 *) 80 81 val parse_arguments : ?current:(int ref) 81 82 -> string array ref -> Arg.anon_fun -> string -> unit 83 + 84 + (** Validate a single -set-runtime-default parameter specification. *) 85 + val parse_runtime_parameter : string -> unit
+8
driver/main_args.ml
··· 163 163 "<dir> Add <dir> to the list of \"hidden\" include directories\n\ 164 164 \ (Like -I, but the program can not directly reference these dependencies)" 165 165 166 + let mk_set_runtime_default f = 167 + "-set-runtime-default", Arg.String f, "<param>=<value> Set the default for \ 168 + runtime parameter <param> to <value> (see the manual for further details)" 169 + 166 170 let mk_impl f = 167 171 "-impl", Arg.String f, "<file> Compile <file> as a .ml file" 168 172 ··· 893 897 val _runtime_variant : string -> unit 894 898 val _with_runtime : unit -> unit 895 899 val _without_runtime : unit -> unit 900 + val _set_runtime_default : string -> unit 896 901 val _short_paths : unit -> unit 897 902 val _thread : unit -> unit 898 903 val _v : unit -> unit ··· 1121 1126 mk_without_runtime F._without_runtime; 1122 1127 mk_safe_string; 1123 1128 mk_safer_matching F._safer_matching; 1129 + mk_set_runtime_default F._set_runtime_default; 1124 1130 mk_short_paths F._short_paths; 1125 1131 mk_strict_sequence F._strict_sequence; 1126 1132 mk_no_strict_sequence F._no_strict_sequence; ··· 1346 1352 mk_S F._S; 1347 1353 mk_safe_string; 1348 1354 mk_safer_matching F._safer_matching; 1355 + mk_set_runtime_default F._set_runtime_default; 1349 1356 mk_shared F._shared; 1350 1357 mk_short_paths F._short_paths; 1351 1358 mk_strict_sequence F._strict_sequence; ··· 1839 1846 let _plugin _p = plugin := true 1840 1847 let _pp s = preprocessor := (Some s) 1841 1848 let _runtime_variant s = runtime_variant := s 1849 + let _set_runtime_default s = Compenv.parse_runtime_parameter s 1842 1850 let _stop_after pass = 1843 1851 let module P = Compiler_pass in 1844 1852 match P.of_string pass with
+1
driver/main_args.mli
··· 119 119 val _runtime_variant : string -> unit 120 120 val _with_runtime : unit -> unit 121 121 val _without_runtime : unit -> unit 122 + val _set_runtime_default : string -> unit 122 123 val _short_paths : unit -> unit 123 124 val _thread : unit -> unit 124 125 val _v : unit -> unit
+1 -1
driver/maindriver.ml
··· 62 62 "Please specify at most one of -pack, -a, -c, -output-obj"; 63 63 | Some ((P.Parsing | P.Typing | P.Lambda) as p) -> 64 64 assert (P.is_compilation_pass p); 65 - Printf.ksprintf Compenv.fatal 65 + Compenv.fatalf 66 66 "Options -i and -stop-after (%s) \ 67 67 are incompatible with -pack, -a, -output-obj" 68 68 (String.concat "|"
+1 -1
driver/optmaindriver.ml
··· 78 78 -output-obj"; 79 79 | Some ((P.Parsing | P.Typing | P.Lambda | P.Scheduling | P.Emit) as p) -> 80 80 assert (P.is_compilation_pass p); 81 - Printf.ksprintf Compenv.fatal 81 + Compenv.fatalf 82 82 "Options -i and -stop-after (%s) \ 83 83 are incompatible with -pack, -a, -shared, -output-obj" 84 84 (String.concat "|"
+9
man/ocamlc.1
··· 674 674 wrongly assumed to be exhaustive. This only impacts GADT and 675 675 polymorphic variant compilation. 676 676 .TP 677 + .BI \-set\-runtime\-default " setting=value" 678 + When linking an executable, override the default value for a runtime setting. 679 + The only currently supported setting is: 680 + 681 + .B standard_library_default 682 + Specifies the default location used by the executable to locate the Standard 683 + Library. By default, this is the absolute path to the Standard Library the 684 + compiler itself was configured with. 685 + .TP 677 686 .B \-short\-paths 678 687 When a type is visible under several module-paths, use the shortest 679 688 one when printing the type's name in inferred interfaces and error and
+9
man/ocamlopt.1
··· 593 593 supported passes are: 594 594 .BR scheduling . 595 595 .TP 596 + .BI \-set\-runtime\-default " setting=value" 597 + When linking an executable, override the default value for a runtime setting. 598 + The only currently supported setting is: 599 + 600 + .B standard_library_default 601 + Specifies the default location used by the executable to locate the Standard 602 + Library. By default, this is the absolute path to the Standard Library the 603 + compiler itself was configured with. 604 + .TP 596 605 .B \-shared 597 606 Build a plugin (usually .cmxs) that can be dynamically loaded with 598 607 the
+11
manual/src/cmds/unified-options.etex
··· 711 711 ). 712 712 }%nat 713 713 714 + \notop{% 715 + \item["-set-runtime-default" \var{name=value}] 716 + When linking an executable, override the default value for a runtime setting. 717 + The currently supported settings are: 718 + \begin{description} 719 + \item["standard_library_default"] Specifies the default location used by the 720 + executable to locate the Standard Library. By default, this is the absolute 721 + path to the Standard Library the compiler itself was configured with. 722 + \end{description} 723 + }%notop 724 + 714 725 \nat{% 715 726 \item["-shared"] 716 727 Build a plugin (usually ".cmxs") that can be dynamically loaded with
+1
utils/clflags.ml
··· 48 48 and output_name = ref (None : string option) (* -o *) 49 49 and include_dirs = ref ([] : string list) (* -I *) 50 50 and hidden_include_dirs = ref ([] : string list) (* -H *) 51 + and standard_library_default = ref None (* -set-runtime-default *) 51 52 and no_std_include = ref false (* -nostdlib *) 52 53 and no_cwd = ref false (* -nocwd *) 53 54 and print_types = ref false (* -i *)
+1
utils/clflags.mli
··· 76 76 val output_name : string option ref 77 77 val include_dirs : string list ref 78 78 val hidden_include_dirs : string list ref 79 + val standard_library_default : string option ref 79 80 val no_std_include : bool ref 80 81 val no_cwd : bool ref 81 82 val print_types : bool ref