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.

Remove metadata from runtime-launch-info

-launch-method encapsulates the first line of runtime-launch-info. The
argument to -launch-method is extended slightly to encompass the second
line, thus `-launch-method 'sh /usr/local/bin'` represents the default
runtime-launch-info file on Unix. Additional fields are added to Config
so that the installed compiler simply uses default values, rather than
reading the two lines from runtime-launch-info. The build of the
compiler itself explicitly uses `-launch-method`, which leaves only the
executable launcher compiled from stdlib/header.c in
runtime-launch-info.

+184 -164
-2
.depend
··· 10769 10769 driver/compmisc.cmi \ 10770 10770 testsuite/tools/cmdline.cmi \ 10771 10771 utils/clflags.cmi \ 10772 - bytecomp/bytelink.cmi \ 10773 10772 testsuite/tools/test_in_prefix.cmi 10774 10773 testsuite/tools/test_in_prefix.cmx : \ 10775 10774 otherlibs/unix/unix.cmx \ ··· 10787 10786 driver/compmisc.cmx \ 10788 10787 testsuite/tools/cmdline.cmx \ 10789 10788 utils/clflags.cmx \ 10790 - bytecomp/bytelink.cmx \ 10791 10789 testsuite/tools/test_in_prefix.cmi 10792 10790 testsuite/tools/test_in_prefix.cmi : 10793 10791 testsuite/tools/test_ld_conf.cmo : \
+31 -2
Makefile
··· 662 662 rm -f $(FLEXDLL_SOURCE_DIR)/flexlink.exe 663 663 $(MAKE) -C $(FLEXDLL_SOURCE_DIR) $(FLEXLINK_BUILD_ENV) \ 664 664 OCAMLRUN='$$(ROOTDIR)/boot/ocamlrun$(EXE)' NATDYNLINK=false \ 665 - OCAMLOPT=$(call QUOTE_SINGLE,$(value BOOT_OCAMLC) $(USE_RUNTIME_PRIMS) \ 666 - $(USE_STDLIB)) \ 665 + OCAMLOPT=$(call QUOTE_SINGLE,$(value BOOT_OCAMLC) \ 666 + $(USE_RUNTIME_PRIMS) \ 667 + $(BYTECODE_LAUNCHER_FLAGS) \ 668 + $(USE_STDLIB)) \ 667 669 flexlink.exe support 668 670 cp $(FLEXDLL_SOURCE_DIR)/flexlink.exe $@ 669 671 cp $(addprefix $(FLEXDLL_SOURCE_DIR)/, $(FLEXDLL_OBJECTS)) $(ROOTDIR) ··· 1886 1888 ocamldoc/%: CAMLC = $(BEST_OCAMLC) $(STDLIBFLAGS) 1887 1889 ocamldoc/%: CAMLOPT = $(BEST_OCAMLOPT) $(STDLIBFLAGS) 1888 1890 1891 + ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "false" 1892 + # ocamldoc needs a custom runtime when building statically owing to the C stubs 1893 + # in unix.cma and str.cma. This is specified explicitly to suppress the default 1894 + # linking flags (see $(MAYBE_ADD_BYTECODE_LAUNCHER_FLAGS) in Makefile.common) 1895 + ocamldoc/ocamldoc$(EXE): ocamldoc_BYTECODE_LINKFLAGS += -custom 1896 + else 1897 + ocamldoc/ocamldoc$(EXE): ocamldoc_BYTECODE_LINKFLAGS += $(ROOT_LINK_FLAGS) 1898 + endif 1899 + 1889 1900 .PHONY: ocamldoc 1890 1901 ocamldoc: ocamldoc/ocamldoc$(EXE) ocamldoc/odoc_test.cmo \ 1891 1902 ocamlc ocamlyacc ocamllex ··· 2253 2264 2254 2265 debugger/ocamldebug_entry.cmo: debugger/ocamldebug.cmo 2255 2266 2267 + ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "false" 2268 + # ocamldebug needs a custom runtime when building statically owing to the 2269 + # C stubs in unix.cma. This is specified explicitly to suppress the default 2270 + # linking flags (see $(MAYBE_ADD_BYTECODE_LAUNCHER_FLAGS) in Makefile.common) 2271 + debugger/ocamldebug$(EXE): ocamldebug_BYTECODE_LINKFLAGS += -custom 2272 + else 2273 + debugger/ocamldebug$(EXE): ocamldebug_BYTECODE_LINKFLAGS += $(ROOT_LINK_FLAGS) 2274 + endif 2275 + 2256 2276 clean:: 2257 2277 rm -f debugger/ocamldebug debugger/ocamldebug.exe 2258 2278 rm -f debugger/debugger_lexer.ml ··· 2520 2540 $(ocamltex): VPATH += $(addprefix otherlibs/,str unix) 2521 2541 2522 2542 tools/ocamltex.cmo: OC_COMMON_COMPFLAGS += -no-alias-deps 2543 + 2544 + ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "false" 2545 + # ocamltex needs a custom runtime when building statically owing to the C stubs 2546 + # in unix.cma and str.cma. This is specified explicitly to suppress the default 2547 + # linking flags (see $(MAYBE_ADD_BYTECODE_LAUNCHER_FLAGS) in Makefile.common) 2548 + tools/ocamltex$(EXE): ocamltex_BYTECODE_LINKFLAGS += -custom 2549 + else 2550 + tools/ocamltex$(EXE): ocamltex_BYTECODE_LINKFLAGS += $(ROOT_LINK_FLAGS) 2551 + endif 2523 2552 2524 2553 # we need str and unix which depend on the bytecode version of other tools 2525 2554 # thus we use the othertools target
+2
Makefile.build_config.in
··· 109 109 110 110 MKEXE_VIA_CC=$(CC) @mkexe_via_cc_ldflags@ @mkexe_via_cc_extra_cmd@ 111 111 112 + LAUNCH_METHOD = @launch_method@ 113 + 112 114 # How to build sak 113 115 SAK_BUILD=@SAK_BUILD@ 114 116 # How to invoke sak
+31 -3
Makefile.common
··· 342 342 $(basename $(notdir $(1)))_COMMON_LINKFLAGS = 343 343 endef # _OCAML_PROGRAM_BASE 344 344 345 + # $(ROOTDIR)/ocamlc needs -launch-method to be given explicitly as its default 346 + # values are those for the target (cf. --with-target-sh and TARGET_BINDIR). 347 + BYTECODE_LAUNCHER_FLAGS = \ 348 + -launch-method $(call QUOTE_SINGLE,$(LAUNCH_METHOD) $(BINDIR)) 349 + 350 + # $(BOOTSTRAPPED) will be non-empty after the compiler has been bootstrapped, as 351 + # the -launch-method string will appear in it. 352 + BOOTSTRAPPED := \ 353 + $(shell grep -Fq 'launch-method' $(ROOTDIR)/boot/ocamlc && echo Bootstrapped) 354 + 355 + # Prior to bootstrapping, boot/ocamlc gets the correct host values from 356 + # boot/runtime-launch-info and doesn't yet recognise -launch-method. After 357 + # bootstrapping, both compilers must be passed -launch-method. 358 + ifeq "$(BOOTSTRAPPED)" "" 359 + ROOT_LINK_FLAGS := $(BYTECODE_LAUNCHER_FLAGS) 360 + BYTECODE_LAUNCHER_FLAGS := 361 + endif 362 + 363 + MAYBE_ADD_BYTECODE_LAUNCHER_FLAGS = \ 364 + $(if $(filter -custom, $(1)),,\ 365 + -use-prims $(ROOTDIR)/runtime/primitives $(BYTECODE_LAUNCHER_FLAGS)) 366 + 345 367 LINK_BYTECODE_PROGRAM =\ 346 - $(CAMLC) $(OC_COMMON_LINKFLAGS) $(OC_BYTECODE_LINKFLAGS) 368 + $(CAMLC) $(OC_COMMON_LINKFLAGS) \ 369 + $(call MAYBE_ADD_BYTECODE_LAUNCHER_FLAGS, \ 370 + $(OC_COMMON_LINKFLAGS) $(OC_BYTECODE_LINKFLAGS)) $(OC_BYTECODE_LINKFLAGS) 347 371 348 372 # The _OCAML_BYTECODE_PROGRAM macro defines a bytecode program but assuming 349 373 # that _OCAML_PROGRAM_BASE has already been called. Its public counterpart ··· 367 391 368 392 $(basename $(notdir $(1)))_BYTECODE_LINKCMD = \ 369 393 $(strip \ 370 - $$(CAMLC) $$(OC_COMMON_LINKFLAGS) $$(OC_BYTECODE_LINKFLAGS) \ 371 - $$($(basename $(notdir $(1)))_COMMON_LINKFLAGS) \ 394 + $$(CAMLC) $$(OC_COMMON_LINKFLAGS) \ 395 + $$(call MAYBE_ADD_BYTECODE_LAUNCHER_FLAGS, \ 396 + $$(OC_COMMON_LINKFLAGS) $$(OC_BYTECODE_LINKFLAGS) \ 397 + $$($(basename $(notdir $(1)))_COMMON_LINKFLAGS) \ 398 + $$($(basename $(notdir $(1)))_BYTECODE_LINKFLAGS)) \ 399 + $$(OC_BYTECODE_LINKFLAGS) $$($(basename $(notdir $(1)))_COMMON_LINKFLAGS) \ 372 400 $$($(basename $(notdir $(1)))_BYTECODE_LINKFLAGS)) 373 401 374 402 $(1)$(EXE): $$$$($(basename $(notdir $(1)))_BCOBJS)
+37 -92
bytecomp/bytelink.ml
··· 293 293 | Shebang_runtime 294 294 | Executable 295 295 296 - type runtime_launch_info = { 297 - buffer : string; 298 - bindir : string; 299 - launcher : launch_method; 300 - executable_offset : int 301 - } 302 - 303 296 (* See https://www.in-ulm.de/~mascheck/various/shebang/#origin for a deep 304 297 dive into shebangs. 305 298 - Whitespace (space or horizontal tab) delimits the interpreter from an ··· 312 305 let invalid_char = function ' ' | '\t' | '\n' -> true | _ -> false in 313 306 String.length path > 125 || String.exists invalid_char path 314 307 315 - (* The runtime-launch-info file consists of two "lines" followed by binary data. 316 - The file is _always_ LF-formatted, even on Windows. The sequence of bytes up 317 - to the first '\n' is interpreted: 318 - - "sh" - use a shebang-style launcher. If sh is needed, determine its 319 - location from [command -p -v sh] 320 - - "exe" - use the executable launcher contained in this runtime-launch-info 321 - file. 322 - - "/" ^ path - use a shebang-style launcher. If sh is needed, path is the 323 - absolute location of sh. path must be valid for a shebang 324 - line. 325 - The second "line" is interpreted as the next "\000\n"-terminated sequence and 326 - is the directory containing the default runtimes (ocamlrun, ocamlrund, etc.). 327 - The null terminator is used since '\n' is valid in a nefarious installation 328 - prefix but Posix forbids filenames including the nul character. 329 - The remainder of the file is then the executable launcher for bytecode 330 - programs (see stdlib/header{,nt}.c). *) 331 - 332 - let read_runtime_launch_info file = 333 - let buffer = 334 - try 335 - In_channel.with_open_bin file In_channel.input_all 336 - with Sys_error msg -> raise (Error (Camlheader (msg, file))) 337 - in 338 - try 339 - let bindir_start = String.index buffer '\n' + 1 in 340 - let bindir_end = String.index_from buffer bindir_start '\000' in 341 - let bindir = String.sub buffer bindir_start (bindir_end - bindir_start) in 342 - let bindir = 343 - if bindir = Filename.current_dir_name then 344 - Filename.dirname Sys.executable_name 345 - else 346 - bindir in 347 - let executable_offset = bindir_end + 2 in 348 - let launcher = 349 - let kind = String.sub buffer 0 (bindir_start - 1) in 350 - if kind = "exe" then 351 - Executable 352 - else if kind <> "" && (kind.[0] = '/' || kind = "sh") then 353 - Shebang_bin_sh kind 354 - else 355 - raise Not_found in 356 - if String.length buffer < executable_offset 357 - || buffer.[executable_offset - 1] <> '\n' then 358 - raise Not_found 359 - else 360 - {bindir; launcher; buffer; executable_offset} 361 - with Not_found -> 362 - raise (Error (Camlheader ("corrupt header", file))) 363 - 364 308 let find_bin_sh () = 365 309 let output_file = Filename.temp_file "caml_bin_sh" "" in 366 310 let result = ··· 392 336 called) *) 393 337 394 338 let write_header outchan = 395 - let runtime_info = 396 - let header = "runtime-launch-info" in 397 - try read_runtime_launch_info (Load_path.find header) 398 - with Not_found -> raise (Error (File_not_found header)) 399 - in 400 - let runtime_info = 401 - match !Clflags.launch_method with 402 - | Some Executable -> 403 - {runtime_info with launcher = Executable} 404 - | Some (Shebang sh) -> 405 - {runtime_info with launcher = 406 - Shebang_bin_sh (Option.value ~default:"sh" sh)} 407 - | None -> 408 - runtime_info 409 - in 410 339 let runtime = 411 340 if String.length !Clflags.use_runtime > 0 then 412 341 (* Do not use BUILD_PATH_PREFIX_MAP mapping for this. *) ··· 422 351 if Sys.win32 then 423 352 runtime 424 353 else 425 - Filename.concat runtime_info.bindir runtime 354 + Filename.concat !Clflags.target_bindir runtime 426 355 in 427 356 (* Determine which method will be used for launching the executable: 428 357 Executable: concatenate the bytecode image to the executable stub 429 358 Shebang_runtime: #! line with the required runtime 430 359 Shebang_bin_sh: #! for a shell script calling exec *) 431 360 let launcher = 432 - if runtime_info.launcher = Executable then 433 - Executable 434 - else 435 - if invalid_for_shebang_line runtime then 436 - match runtime_info.launcher with 437 - | Shebang_bin_sh sh -> 438 - let sh = 439 - if sh = "sh" then 440 - find_bin_sh () 441 - else 442 - sh in 443 - if sh = "" || invalid_for_shebang_line sh then 444 - Executable 445 - else 446 - Shebang_bin_sh sh 447 - | _ -> 361 + match !Clflags.launch_method with 362 + | Config.Executable -> 363 + Executable 364 + | Config.Shebang sh -> 365 + if invalid_for_shebang_line runtime then 366 + let sh = 367 + match sh with 368 + | Some sh -> sh 369 + | None -> find_bin_sh () 370 + in 371 + if sh = "" || invalid_for_shebang_line sh then 448 372 Executable 373 + else 374 + Shebang_bin_sh sh 375 + else 376 + Shebang_runtime 377 + in 378 + let write_exe_launcher data = 379 + (* Compatibility with previous header format - remove post-bootstrap *) 380 + let data = 381 + if data = "" || not (List.mem data.[0] ['/'; 'e'; 's']) then 382 + data 449 383 else 450 - Shebang_runtime 384 + let exe_start = String.index data '\000' + 2 in 385 + let len = String.length data in 386 + String.sub data exe_start (len - exe_start) 387 + in 388 + Out_channel.output_string outchan data 451 389 in 452 390 (* Write the header *) 453 391 match launcher with ··· 463 401 Bytesections.init_record outchan 464 402 | Executable -> 465 403 (* Use the executable stub launcher *) 466 - let pos = runtime_info.executable_offset in 467 - let len = String.length runtime_info.buffer - pos in 468 - Out_channel.output_substring outchan runtime_info.buffer pos len; 404 + let header = 405 + let header = "runtime-launch-info" in 406 + try Load_path.find header 407 + with Not_found -> raise (Error (File_not_found header)) 408 + in 409 + let data = 410 + try In_channel.with_open_bin header In_channel.input_all 411 + with Sys_error msg -> raise (Error (Camlheader (msg, header))) 412 + in 413 + write_exe_launcher data; 469 414 (* The runtime name needs recording in RNTM *) 470 415 let toc_writer = Bytesections.init_record outchan in 471 416 Printf.fprintf outchan "%s\000" runtime;
-21
bytecomp/bytelink.mli
··· 30 30 31 31 val extract_crc_interfaces: unit -> crcs 32 32 33 - (** Ways of starting a bytecode executable *) 34 - type launch_method = 35 - | Shebang_bin_sh of string (** Use a shell script *) 36 - | Shebang_runtime (** Invoke the runtime directly *) 37 - | Executable (** Use the executable stub *) 38 - 39 - (** runtime-launch-info files *) 40 - type runtime_launch_info = { 41 - buffer : string; (** Content of the file *) 42 - bindir : string; (** Directory containing runtime executables *) 43 - launcher : launch_method; (** Default launch method (this is never 44 - {!Shebang_runtime}) *) 45 - executable_offset : int (** Offset in the buffer field at which the 46 - executable stub data begins *) 47 - } 48 - 49 - val read_runtime_launch_info : string -> runtime_launch_info 50 - (** [read_runtime_launch_info file] loads the {!runtime_launch_info} from [file] 51 - 52 - @raise Error if the file cannot be parsed *) 53 - 54 33 type error = 55 34 | File_not_found of filepath 56 35 | Not_an_object_file of filepath
+14 -10
configure
··· 884 884 supports_shared_libraries 885 885 mklib 886 886 AR 887 + launch_method_target 888 + launch_method 887 889 shebangscripts 888 890 winpthreads_source_include_dir 889 891 winpthreads_source_dir ··· 3540 3542 3541 3543 3542 3544 3545 + 3546 + 3543 3547 # TODO: rename this variable 3544 3548 3545 3549 ··· 4279 4283 then : 4280 4284 withval=$with_target_sh; if test x"$withval" = 'xno' 4281 4285 then : 4282 - target_launch_method='exe' 4286 + launch_method_target='exe' 4283 4287 else $as_nop 4284 - target_launch_method="$withval" 4288 + launch_method_target="$withval" 4285 4289 fi 4286 4290 else $as_nop 4287 - target_launch_method='' 4291 + launch_method_target='' 4288 4292 fi 4289 4293 4290 4294 ··· 15306 15310 # not use shebang scripts 15307 15311 shebangscripts=true 15308 15312 launch_method='sh' 15309 - if test x"$target_launch_method" = 'x' 15313 + if test x"$launch_method_target" = 'x' 15310 15314 then : 15311 - target_launch_method='exe' 15315 + launch_method_target='exe' 15312 15316 fi ;; #( 15313 15317 *-w64-mingw32*|*-pc-windows) : 15314 15318 ;; #( ··· 24676 24680 TARGET_LIBDIR="$bindir_to_libdir" 24677 24681 fi 24678 24682 fi 24679 - if test x"$target_launch_method" = 'x' 24683 + if test x"$launch_method_target" = 'x' 24680 24684 then : 24681 - target_launch_method="$launch_method" 24685 + launch_method_target="$launch_method" 24682 24686 fi 24683 24687 prefix="$saved_prefix" 24684 24688 exec_prefix="$saved_exec_prefix" ··· 25636 25640 25637 25641 25638 25642 launch_method='$(echo "$launch_method" | sed -e "s/'/'\"'\"'/g")' 25639 - target_launch_method=\ 25640 - '$(echo "$target_launch_method" | sed -e "s/'/'\"'\"'/g")' 25643 + launch_method_target=\ 25644 + '$(echo "$launch_method_target" | sed -e "s/'/'\"'\"'/g")' 25641 25645 HOST_BINDIR='$(echo "$HOST_BINDIR" | sed -e "s/'/'\"'\"'/g")' 25642 25646 TARGET_BINDIR='$(echo "$TARGET_BINDIR" | sed -e "s/'/'\"'\"'/g")' 25643 25647 ··· 26826 26830 ;; 26827 26831 "shebang":C) printf '%s\n%s\000\n' "$launch_method" "$HOST_BINDIR" \ 26828 26832 > stdlib/runtime.info 26829 - printf '%s\n%s\000\n' "$target_launch_method" "$TARGET_BINDIR" \ 26833 + printf '%s\n%s\000\n' "$launch_method_target" "$TARGET_BINDIR" \ 26830 26834 > stdlib/target_runtime.info ;; 26831 26835 "runtime/ld.conf":C) rm -f runtime/ld.conf 26832 26836 test x"$ocaml_additional_stublibs_dir" = 'x' || \
+12 -10
configure.ac
··· 193 193 AC_SUBST([winpthreads_source_dir]) 194 194 AC_SUBST([winpthreads_source_include_dir]) 195 195 AC_SUBST([shebangscripts]) 196 + AC_SUBST([launch_method]) 197 + AC_SUBST([launch_method_target]) 196 198 AC_SUBST([AR]) 197 199 AC_SUBST([mklib]) 198 200 AC_SUBST([supports_shared_libraries]) ··· 631 633 [AS_HELP_STRING([--with-target-sh], 632 634 [location of Posix sh on the target system])], 633 635 [AS_IF([test x"$withval" = 'xno'], 634 - [target_launch_method='exe'], 635 - [target_launch_method="$withval"])], 636 - [target_launch_method='']) 636 + [launch_method_target='exe'], 637 + [launch_method_target="$withval"])], 638 + [launch_method_target='']) 637 639 638 640 AC_ARG_WITH([additional-stublibsdir], 639 641 [AS_HELP_STRING([--with-additional-stublibsdir], ··· 968 970 # not use shebang scripts 969 971 shebangscripts=true 970 972 launch_method='sh' 971 - AS_IF([test x"$target_launch_method" = 'x'], 972 - [target_launch_method='exe'])], 973 + AS_IF([test x"$launch_method_target" = 'x'], 974 + [launch_method_target='exe'])], 973 975 [*-w64-mingw32*|*-pc-windows], [], 974 976 [shebangscripts=true 975 977 launch_method='sh'] ··· 982 984 AC_CONFIG_COMMANDS([shebang], 983 985 [printf '%s\n%s\000\n' "$launch_method" "$HOST_BINDIR" \ 984 986 > stdlib/runtime.info 985 - printf '%s\n%s\000\n' "$target_launch_method" "$TARGET_BINDIR" \ 987 + printf '%s\n%s\000\n' "$launch_method_target" "$TARGET_BINDIR" \ 986 988 > stdlib/target_runtime.info], 987 989 dnl These declarations are put in a here-document in configure, so the command 988 990 dnl in '$(...)' _is_ evaluated as the content is written to config.status (by 989 991 dnl standard interpretation of a here-document). The sed commands quote any 990 992 dnl nefarious single quotes which may appear in any of the strings. 991 993 [launch_method='$(echo "$launch_method" | sed -e "s/'/'\"'\"'/g")' 992 - target_launch_method=\ 993 - '$(echo "$target_launch_method" | sed -e "s/'/'\"'\"'/g")' 994 + launch_method_target=\ 995 + '$(echo "$launch_method_target" | sed -e "s/'/'\"'\"'/g")' 994 996 HOST_BINDIR='$(echo "$HOST_BINDIR" | sed -e "s/'/'\"'\"'/g")' 995 997 TARGET_BINDIR='$(echo "$TARGET_BINDIR" | sed -e "s/'/'\"'\"'/g")']) 996 998 ··· 3122 3124 [AS_IF([test "x$bindir_to_libdir" = 'x'], 3123 3125 [TARGET_LIBDIR="$ocaml_libdir"], 3124 3126 [TARGET_LIBDIR="$bindir_to_libdir"])]) 3125 - AS_IF([test x"$target_launch_method" = 'x'], 3126 - [target_launch_method="$launch_method"]) 3127 + AS_IF([test x"$launch_method_target" = 'x'], 3128 + [launch_method_target="$launch_method"]) 3127 3129 prefix="$saved_prefix" 3128 3130 exec_prefix="$saved_exec_prefix"]) 3129 3131
+19 -10
driver/main_args.ml
··· 2000 2000 let _output_obj () = output_c_object := true; custom_runtime := true 2001 2001 let _use_prims s = use_prims := s 2002 2002 let _use_runtime s = use_runtime := s 2003 - let _launch_method = function 2004 - | "exe" -> 2005 - launch_method := Some Config.Executable 2006 - | "sh" -> 2007 - launch_method := Some (Config.Shebang None) 2008 - | s when s <> "" && s.[0] = '/' -> 2009 - launch_method := Some (Config.Shebang (Some s)) 2010 - | _ -> 2011 - Compenv.fatal 2012 - "-launch-method: expect sh, exe or an absolute path for <method>" 2003 + let _launch_method s = 2004 + let setting = 2005 + try 2006 + let s, bindir = Misc.cut_at s ' ' in 2007 + target_bindir := bindir; 2008 + s 2009 + with Not_found -> 2010 + s 2011 + in 2012 + match setting with 2013 + | "exe" -> 2014 + launch_method := Config.Executable; 2015 + | "sh" -> 2016 + launch_method := Config.Shebang None 2017 + | s when s <> "" && s.[0] = '/' -> 2018 + launch_method := Config.Shebang (Some s) 2019 + | _ -> 2020 + Compenv.fatal 2021 + "-launch-method: expect sh, exe or an absolute path for <method>" 2013 2022 let _v () = Compenv.print_version_and_library "compiler" 2014 2023 let _vmthread () = Compenv.fatal vmthread_removed_message 2015 2024 end
+4 -1
stdlib/Makefile
··· 84 84 stdlib.cmxa stdlib.$(A) std_exit.$(O) *.cmx \ 85 85 "$(INSTALL_LIBDIR)" 86 86 87 - %-launch-info: %.info tmpheader.exe 87 + runtime-launch-info: runtime.info tmpheader.exe 88 + @cat $^ > $@ 89 + 90 + target_runtime-launch-info: tmpheader.exe 88 91 @cat $^ > $@ 89 92 90 93 # The mingw-w64 and MSVC versions of tmpheader.exe are linked with special flags
-5
testsuite/tools/testRelocation.ml
··· 182 182 "ocamlcommon.cma"] in 183 183 (* The compiler's artefacts are all compiled with -g *) 184 184 (~stdlib, ~ocaml_debug:true, ~c_debug:false, ~s:false) 185 - else if basename = "runtime-launch-info" then 186 - (* When the compiler is configured with a relative libdir, 187 - runtime-launch-info just contains ".", rather than the prefix *) 188 - let stdlib = (config.has_relative_libdir = None) in 189 - (~stdlib, ~ocaml_debug:false, ~c_debug:false, ~s:false) 190 185 else if ext = ".cmxs" then 191 186 (* All the .cmxs files built by the distribution at present include C 192 187 objects and obviously contain assembled objects. *)
+2 -6
testsuite/tools/test_in_prefix.ml
··· 115 115 in 116 116 List.map add_dependencies libraries 117 117 in 118 - let runtime_launch_info = 119 - let file = Filename.concat libdir "runtime-launch-info" in 120 - Bytelink.read_runtime_launch_info file in 121 118 let header_size = 122 - let {Bytelink.buffer; executable_offset; _} = runtime_launch_info in 123 - String.length buffer - executable_offset in 119 + (Unix.stat (Filename.concat libdir "runtime-launch-info")).Unix.st_size in 124 120 let bytecode_shebangs_by_default = 125 - runtime_launch_info.launcher <> Bytelink.Executable in 121 + Config.launch_method <> Config.Executable in 126 122 let launcher_searches_for_ocamlrun = Sys.win32 in 127 123 let target_launcher_searches_for_ocamlrun = Sys.win32 in 128 124 let config =
+4 -1
utils/clflags.ml
··· 87 87 and open_modules = ref [] (* -open *) 88 88 and use_prims = ref "" (* -use-prims ... *) 89 89 and use_runtime = ref "" (* -use-runtime ... *) 90 - and launch_method = ref None (* -launch-method ... *) 90 + and target_bindir = (* -launch-method ... *) 91 + ref Config.target_bindir 92 + and launch_method = 93 + ref Config.launch_method 91 94 and plugin = ref false (* -plugin ... *) 92 95 and principal = ref false (* -principal *) 93 96 and real_paths = ref true (* -short-paths *)
+2 -1
utils/clflags.mli
··· 114 114 val noversion : bool ref 115 115 val use_prims : string ref 116 116 val use_runtime : string ref 117 - val launch_method : Config.launch_method option ref 117 + val target_bindir : string ref 118 + val launch_method : Config.launch_method ref 118 119 val plugin : bool ref 119 120 val principal : bool ref 120 121 val print_variance : bool ref
+11
utils/config.common.ml.in
··· 46 46 standard_library_default 47 47 48 48 let bindir = Option.value ~default:bindir relative_root_dir 49 + let target_bindir = 50 + if target_bindir = Filename.current_dir_name then 51 + Filename.dirname Sys.executable_name 52 + else 53 + target_bindir 49 54 50 55 let exec_magic_number = {magic|@EXEC_MAGIC_NUMBER@|magic} 51 56 (* exec_magic_number is duplicated in runtime/caml/exec.h *) ··· 65 70 let naked_pointers = false 66 71 67 72 type launch_method = Executable | Shebang of string option 73 + 74 + let launch_method = 75 + match launch_method with 76 + | "exe" -> Executable 77 + | "sh" -> Shebang None 78 + | _ -> Shebang (Some launch_method) 68 79 69 80 let interface_suffix = ref ".mli" 70 81
+2
utils/config.fixed.ml
··· 21 21 let boot_cannot_call s = "/ The boot compiler should not call " ^ s 22 22 23 23 let bindir = "/tmp" 24 + let target_bindir = bindir 24 25 let ccomp_type = "n/a" 25 26 let c_compiler = boot_cannot_call "the C compiler" 26 27 let c_compiler_vendor = "" ··· 82 83 let flexdll_dirs = [] 83 84 let ar_supports_response_files = true 84 85 let shebangscripts = false 86 + let launch_method = "sh"
+3
utils/config.generated.ml.in
··· 19 19 than compiled on its own *) 20 20 21 21 let bindir = {@QS@|@ocaml_bindir@|@QS@} 22 + let target_bindir = {@QS@|@TARGET_BINDIR@|@QS@} 22 23 23 24 let ccomp_type = {@QS@|@ccomp_type@|@QS@} 24 25 let c_compiler = {@QS@|@CC@|@QS@} ··· 102 103 let tsan = @tsan@ 103 104 104 105 let shebangscripts = @shebangscripts@ 106 + 107 + let launch_method = {@QS@|@launch_method_target@|@QS@}
+10
utils/config.mli
··· 35 35 36 36 @since 5.5 *) 37 37 38 + val target_bindir: string 39 + (** The directory containing the runtime binaries on the target system 40 + 41 + @since 5.5 *) 42 + 38 43 val standard_library_default: string 39 44 (** The effective value for the default directory containing the standard 40 45 libraries. This is always an absolute path, computed using ··· 368 373 shebang line, then a shell script is generated. When this is necessary, 369 374 the parameter in [Shebang (Some sh)] is the full path to [sh]; if the 370 375 parameter is [None], then the linker searches PATH for [sh]. *) 376 + 377 + val launch_method : launch_method 378 + (** Default launch mechanism for bytecode executables 379 + 380 + @since 5.5 *) 371 381 372 382 val shebangscripts : bool 373 383 (** Whether the target supports shebang scripts