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.

Mangle the bytecode runtime executable names

New option --disable-suffixing controls whether the build should use any
of the computed values for mangling its own files.

+297 -62
+10
.depend
··· 2478 2478 typing/env.cmi \ 2479 2479 file_formats/cmo_format.cmi 2480 2480 bytecomp/byterntm.cmo : \ 2481 + utils/misc.cmi \ 2481 2482 bytecomp/bytesections.cmi \ 2482 2483 bytecomp/byterntm.cmi 2483 2484 bytecomp/byterntm.cmx : \ 2485 + utils/misc.cmx \ 2484 2486 bytecomp/bytesections.cmx \ 2485 2487 bytecomp/byterntm.cmi 2486 2488 bytecomp/byterntm.cmi : \ 2489 + utils/misc.cmi \ 2487 2490 bytecomp/bytesections.cmi 2488 2491 bytecomp/bytesections.cmo : \ 2489 2492 utils/config.cmi \ ··· 8066 8069 typing/ident.cmi \ 8067 8070 utils/format_doc.cmi \ 8068 8071 middle_end/flambda/export_info.cmi \ 8072 + utils/config.cmi \ 8069 8073 middle_end/compilation_unit.cmi \ 8070 8074 file_formats/cmxs_format.cmi \ 8071 8075 file_formats/cmx_format.cmi \ ··· 8090 8094 typing/ident.cmx \ 8091 8095 utils/format_doc.cmx \ 8092 8096 middle_end/flambda/export_info.cmx \ 8097 + utils/config.cmx \ 8093 8098 middle_end/compilation_unit.cmx \ 8094 8099 file_formats/cmxs_format.cmi \ 8095 8100 file_formats/cmx_format.cmi \ ··· 10610 10615 parsing/location.cmi 10611 10616 testsuite/tools/harness.cmo : \ 10612 10617 otherlibs/unix/unix.cmi \ 10618 + utils/misc.cmi \ 10613 10619 utils/config.cmi \ 10614 10620 bytecomp/byterntm.cmi \ 10615 10621 testsuite/tools/harness.cmi 10616 10622 testsuite/tools/harness.cmx : \ 10617 10623 otherlibs/unix/unix.cmx \ 10624 + utils/misc.cmx \ 10618 10625 utils/config.cmx \ 10619 10626 bytecomp/byterntm.cmx \ 10620 10627 testsuite/tools/harness.cmi 10621 10628 testsuite/tools/harness.cmi : \ 10629 + utils/misc.cmi \ 10622 10630 bytecomp/byterntm.cmi 10623 10631 testsuite/tools/lexcmm.cmo : \ 10624 10632 testsuite/tools/parsecmm.cmi \ ··· 10681 10689 middle_end/backend_var.cmi 10682 10690 testsuite/tools/testBytecodeBinaries.cmo : \ 10683 10691 otherlibs/unix/unix.cmi \ 10692 + utils/misc.cmi \ 10684 10693 testsuite/tools/harness.cmi \ 10685 10694 testsuite/tools/environment.cmi \ 10686 10695 utils/config.cmi \ 10687 10696 testsuite/tools/testBytecodeBinaries.cmi 10688 10697 testsuite/tools/testBytecodeBinaries.cmx : \ 10689 10698 otherlibs/unix/unix.cmx \ 10699 + utils/misc.cmx \ 10690 10700 testsuite/tools/harness.cmx \ 10691 10701 testsuite/tools/environment.cmx \ 10692 10702 utils/config.cmx \
+4 -1
Changes
··· 93 93 94 94 - #14245: Introduce Runtime IDs for use in filename mangling to allow different 95 95 configurations and different versions of the runtime system to coexist 96 - harmoniously on a single system. 96 + harmoniously on a single system. The IDs are used, along with the host 97 + triplet, to provide mangled names for the ocamlrun executable and its 98 + variants, with symlinks created for the original names. The behaviour is 99 + disabled by configuring with --disable-suffixing. 97 100 (David Allsopp, review by Damien Doligez and Samuel Hym) 98 101 99 102 - #12269, #12410, #13063: Fix unsafety, deadlocks, and/or leaks should
+32 -6
Makefile
··· 1298 1298 1299 1299 ## Targets to build and install 1300 1300 1301 - runtime_PROGRAMS = runtime/ocamlrun$(EXE) 1301 + runtime_PROGRAMS = ocamlrun 1302 1302 runtime_BYTECODE_STATIC_LIBRARIES = runtime/libcamlrun.$(A) 1303 1303 runtime_BYTECODE_SHARED_LIBRARIES = 1304 1304 runtime_NATIVE_STATIC_LIBRARIES = \ ··· 1306 1306 runtime_NATIVE_SHARED_LIBRARIES = 1307 1307 1308 1308 ifeq "$(RUNTIMED)" "true" 1309 - runtime_PROGRAMS += runtime/ocamlrund$(EXE) 1309 + runtime_PROGRAMS += ocamlrund 1310 1310 runtime_BYTECODE_STATIC_LIBRARIES += runtime/libcamlrund.$(A) 1311 1311 runtime_NATIVE_STATIC_LIBRARIES += runtime/libasmrund.$(A) 1312 1312 endif 1313 1313 1314 1314 ifeq "$(INSTRUMENTED_RUNTIME)" "true" 1315 - runtime_PROGRAMS += runtime/ocamlruni$(EXE) 1315 + runtime_PROGRAMS += ocamlruni 1316 1316 runtime_BYTECODE_STATIC_LIBRARIES += runtime/libcamlruni.$(A) 1317 1317 runtime_NATIVE_STATIC_LIBRARIES += runtime/libasmruni.$(A) 1318 1318 endif ··· 1374 1374 .PHONY: runtime-all 1375 1375 runtime-all: \ 1376 1376 $(runtime_BYTECODE_STATIC_LIBRARIES) $(runtime_BYTECODE_SHARED_LIBRARIES) \ 1377 - $(runtime_PROGRAMS) $(SAK) 1377 + $(runtime_PROGRAMS:%=runtime/%$(EXE)) $(SAK) 1378 1378 1379 1379 .PHONY: runtime-allopt 1380 1380 ifeq "$(NATIVE_COMPILER)" "true" ··· 1422 1422 printf '#define OCAML_STDLIB_DIR %s\n' \ 1423 1423 $(call QUOTE_SINGLE,$(call C_LITERAL,$(TARGET_LIBDIR))); \ 1424 1424 echo '#define HOST "$(HOST)"'; \ 1425 + echo '#define BYTECODE_RUNTIME_ID "$(BYTECODE_RUNTIME_ID)"'; \ 1425 1426 } > $@ 1426 1427 1427 1428 runtime/prims.$(O): runtime/build_config.h ··· 2755 2756 INSTALL_LIBDIR_DYNLINK = $(INSTALL_LIBDIR)/dynlink 2756 2757 2757 2758 # Installation 2759 + 2758 2760 .PHONY: install 2759 - install: 2761 + install:: 2760 2762 $(MKDIR) "$(INSTALL_BINDIR)" 2761 2763 $(MKDIR) "$(INSTALL_LIBDIR)" 2762 2764 ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "true" ··· 2766 2768 $(MKDIR) "$(INSTALL_DOCDIR)" 2767 2769 $(MKDIR) "$(INSTALL_INCDIR)" 2768 2770 $(MKDIR) "$(INSTALL_LIBDIR_PROFILING)" 2769 - $(INSTALL_PROG) $(runtime_PROGRAMS) "$(INSTALL_BINDIR)" 2771 + 2772 + ifeq "$(SUFFIXING)" "true" 2773 + MANGLE_RUNTIME_NAME = $(TARGET)-$(1)-$(BYTECODE_RUNTIME_ID)$(EXE) 2774 + else 2775 + MANGLE_RUNTIME_NAME = $(1)$(EXE) 2776 + endif 2777 + 2778 + define INSTALL_RUNTIME 2779 + install:: 2780 + $(INSTALL_PROG) \ 2781 + runtime/$(1)$(EXE) \ 2782 + "$(INSTALL_BINDIR)/$(call MANGLE_RUNTIME_NAME,$(1))" 2783 + ifeq "$(SUFFIXING)" "true" 2784 + cd "$(INSTALL_BINDIR)" && \ 2785 + $(LN) "$(TARGET)-$(1)-$(BYTECODE_RUNTIME_ID)$(EXE)" "$(1)$(EXE)" 2786 + cd "$(INSTALL_BINDIR)" && \ 2787 + $(LN) "$(TARGET)-$(1)-$(BYTECODE_RUNTIME_ID)$(EXE)" \ 2788 + "$(1)-$(ZINC_RUNTIME_ID)$(EXE)" 2789 + endif 2790 + endef 2791 + 2792 + $(foreach runtime, $(runtime_PROGRAMS), \ 2793 + $(eval $(call INSTALL_RUNTIME,$(runtime)))) 2794 + 2795 + install:: 2770 2796 $(INSTALL_DATA) runtime/ld.conf $(runtime_BYTECODE_STATIC_LIBRARIES) \ 2771 2797 "$(INSTALL_LIBDIR)" 2772 2798 ifneq "$(runtime_BYTECODE_SHARED_LIBRARIES)" ""
+1
Makefile.build_config.in
··· 110 110 MKEXE_VIA_CC=$(CC) @mkexe_via_cc_ldflags@ @mkexe_via_cc_extra_cmd@ 111 111 112 112 LAUNCH_METHOD = @launch_method@ 113 + SUFFIXING = @suffixing@ 113 114 114 115 # How to build sak 115 116 SAK_BUILD=@SAK_BUILD@
+17
Makefile.common
··· 367 367 BYTECODE_LAUNCHER_FLAGS := 368 368 endif 369 369 370 + ifeq "$(SUFFIXING)-$(UNIX_OR_WIN32)" "true-win32" 371 + # Historically, the native Windows ports are assumed to be finding ocamlrun 372 + # using a PATH search. -use-runtime ocamlrun-$(ZINC_RUNTIME_ID) won't work here 373 + # as ocamlc will convert it to an absolute path. Instead, we (ab)use 374 + # -runtime-variant to append the -$(ZINC_RUNTIME_ID) to the default ocamlrun. 375 + BYTECODE_LAUNCHER_FLAGS += -runtime-variant -$(ZINC_RUNTIME_ID) 376 + # boot/ocamlc is built with suffixing disabled, so this works both before and 377 + # after bootstrapping, however this would cause $(ROOTDIR)/ocamlc to add the 378 + # suffix twice. Thwart this by further (ab)using -runtime-variant. 379 + ROOT_LINK_FLAGS += -runtime-variant '' 380 + else ifeq "$(SUFFIXING)" "true" 381 + # boot/ocamlc is built with suffixing disabled or not yet bootstrapped, so 382 + # either way pass the suffixed runtime name explicitly with -use-runtime. 383 + BYTECODE_LAUNCHER_FLAGS += \ 384 + -use-runtime $(call QUOTE_SINGLE,$(BINDIR)/ocamlrun-$(ZINC_RUNTIME_ID)) 385 + endif 386 + 370 387 MAYBE_ADD_BYTECODE_LAUNCHER_FLAGS = \ 371 388 $(if $(filter -custom, $(1)),,\ 372 389 -use-prims $(ROOTDIR)/runtime/primitives $(BYTECODE_LAUNCHER_FLAGS))
+37 -23
bytecomp/bytelink.ml
··· 412 412 called) *) 413 413 414 414 let write_header outchan = 415 + let zinc_runtime_id, write_exe_launcher = 416 + let header = 417 + let header = "runtime-launch-info" in 418 + try Load_path.find header 419 + with Not_found -> raise (Error (File_not_found header)) 420 + in 421 + let data = 422 + try In_channel.with_open_bin header In_channel.input_all 423 + with Sys_error msg -> raise (Error (Camlheader (msg, header))) 424 + in 425 + let zinc_runtime_id, offset = 426 + if String.length data < 2 then 427 + raise (Error (Camlheader ("corrupt header", header))) 428 + (* Compatibility with previous header format - remove post-bootstrap *) 429 + else if List.mem data.[0] ['/'; 'e'; 's'] then 430 + None, String.index data '\000' + 2 431 + else if data.[0] = '\000' then 432 + None, 1 433 + else 434 + let zinc = Misc.RuntimeID.of_zinc_hi (String.sub data 0 2) in 435 + if Option.fold ~none:false ~some:Misc.RuntimeID.is_zinc zinc then 436 + zinc, 2 437 + else 438 + raise (Error (Camlheader ("corrupt header", header))) 439 + in 440 + let write_exe_header outchan = 441 + let len = String.length data in 442 + Out_channel.output_substring outchan data offset (len - offset) 443 + in 444 + zinc_runtime_id, write_exe_header 445 + in 415 446 let runtime, search = 416 447 if String.length !Clflags.use_runtime > 0 then 417 448 (* Do not use BUILD_PATH_PREFIX_MAP mapping for this. *) ··· 421 452 else 422 453 runtime, Config.Disable 423 454 else 424 - let runtime = "ocamlrun" ^ !Clflags.runtime_variant in 455 + let runtime = 456 + let runtime = "ocamlrun" ^ !Clflags.runtime_variant in 457 + let some = Misc.RuntimeID.ocamlrun !Clflags.runtime_variant in 458 + Option.fold ~none:runtime ~some zinc_runtime_id 459 + in 425 460 let runtime = 426 461 if !Clflags.search_method = Config.Disable then 427 462 Filename.concat !Clflags.target_bindir runtime ··· 452 487 else 453 488 Shebang_runtime 454 489 in 455 - let write_exe_launcher data = 456 - (* Compatibility with previous header format - remove post-bootstrap *) 457 - let data = 458 - if data = "" || not (List.mem data.[0] ['/'; 'e'; 's']) then 459 - data 460 - else 461 - let exe_start = String.index data '\000' + 2 in 462 - let len = String.length data in 463 - String.sub data exe_start (len - exe_start) 464 - in 465 - Out_channel.output_string outchan data 466 - in 467 490 (* Write the header *) 468 491 match launcher with 469 492 | Shebang_runtime -> ··· 477 500 Bytesections.init_record outchan 478 501 | Executable -> 479 502 (* Use the executable stub launcher *) 480 - let header = 481 - let header = "runtime-launch-info" in 482 - try Load_path.find header 483 - with Not_found -> raise (Error (File_not_found header)) 484 - in 485 - let data = 486 - try In_channel.with_open_bin header In_channel.input_all 487 - with Sys_error msg -> raise (Error (Camlheader (msg, header))) 488 - in 489 - write_exe_launcher data; 503 + write_exe_launcher outchan; 490 504 (* The runtime name needs recording in RNTM *) 491 505 let toc_writer = Bytesections.init_record outchan in 492 506 (* stdlib/header.c determines which mode is needed based on whether the
+2 -1
bytecomp/byterntm.mli
··· 26 26 (** Always search for the interpreter *) 27 27 28 28 val read_runtime : 29 - Bytesections.section_table -> in_channel -> (string * search_method) option 29 + Bytesections.section_table -> in_channel 30 + -> (string * Misc.RuntimeID.t option * search_method) option 30 31 (** Returns the runtime used by this tendered/standalone image. If the runtime 31 32 used cannot be parsed, or the image was linked using -without-runtime, then 32 33 [None] is returned. *)
+26 -8
bytecomp/byterntm.mll
··· 21 21 (* First word of the current line being analysed - [exec ...], [r=...], or 22 22 [c=...] *) 23 23 type state = Exec | R | C of string 24 + 25 + let cut_runtime_id search name = 26 + let len = String.length name in 27 + let id = 28 + if len < 6 || name.[len - 5] <> '-' then 29 + None 30 + else 31 + Misc.RuntimeID.of_string (String.sub name (len - 4) 4) 32 + in 33 + let name = 34 + if id = None then 35 + name 36 + else 37 + String.sub name 0 (len - 5) 38 + in 39 + Some (name, id, search) 24 40 } 25 41 26 42 rule analyze = parse ··· 31 47 ([^ '\\' '/' '\000']+ as runtime) eof (* Runtime portion *) 32 48 { if sep = '\000' then 33 49 if dir = "" then 34 - Some (runtime, Enable) 50 + cut_runtime_id Enable runtime 35 51 else 36 - Some (runtime, Fallback (Filename.concat dir "")) 52 + let dir = Filename.concat dir "" in 53 + cut_runtime_id (Fallback dir) runtime 37 54 else 38 - Some (runtime, Disable (dir ^ String.make 1 sep)) } 55 + let dir = dir ^ String.make 1 sep in 56 + cut_runtime_id (Disable dir) runtime } 39 57 40 58 (* Legacy RNTM (remove after bootstrap) *) 41 59 | (([^ '\000']* ['/' '\\']) as dir) 42 60 ([^ '\\' '/' '\000']+ as runtime) '\000' eof 43 61 { if dir = "" then 44 - Some (runtime, Enable) 62 + Some (runtime, None, Enable) 45 63 else 46 - Some (runtime, Disable dir) } 64 + Some (runtime, None, Disable dir) } 47 65 48 66 (* Shell script launcher (if it matches, this always matches more than the above 49 67 regexp) *) ··· 70 88 let dir = 71 89 String.sub name 0 (String.length name - String.length runtime) 72 90 in 73 - Some (runtime, Disable dir) 91 + cut_runtime_id (Disable dir) runtime 74 92 else 75 93 None } 76 94 ··· 79 97 { if state = R then 80 98 let runtime = Buffer.contents b in 81 99 if c = None then 82 - Some (runtime, Enable) 100 + cut_runtime_id Enable runtime 83 101 else 84 102 analyze_sh_launcher (C runtime) (Buffer.clear b; b) lexbuf 85 103 else ··· 89 107 | "'\"$r\"\n" 90 108 { match state with 91 109 | C runtime -> 92 - Some (runtime, Fallback (Buffer.contents b)) 110 + cut_runtime_id (Fallback (Buffer.contents b)) runtime 93 111 | _ -> 94 112 None } 95 113
+19
configure
··· 800 800 build_vendor 801 801 build_cpu 802 802 build 803 + suffixing 803 804 native_runtime_id 804 805 bytecode_runtime_id 805 806 zinc_runtime_id_hi ··· 1058 1059 enable_function_sections 1059 1060 enable_mmap_map_stack 1060 1061 with_relative_libdir 1062 + enable_suffixing 1061 1063 with_afl 1062 1064 with_flexdll 1063 1065 with_winpthreads_msvc ··· 1769 1771 --disable-function-sections 1770 1772 do not emit each function in a separate section 1771 1773 --enable-mmap-map-stack use mmap to allocate stacks instead of malloc 1774 + --disable-suffixing disable suffixing of runtime executables and shared 1775 + libraries 1772 1776 --enable-shared[=PKGS] build shared libraries [default=yes] 1773 1777 --enable-static[=PKGS] build static libraries [default=yes] 1774 1778 --enable-pic[=PKGS] try to use only PIC/non-PIC objects [default=use ··· 3612 3616 3613 3617 3614 3618 3619 + 3615 3620 ## Generated files 3616 3621 3617 3622 ac_config_files="$ac_config_files Makefile.build_config" ··· 4405 4410 esac 4406 4411 else $as_nop 4407 4412 bindir_to_libdir='' 4413 + fi 4414 + 4415 + 4416 + # Check whether --enable-suffixing was given. 4417 + if test ${enable_suffixing+y} 4418 + then : 4419 + enableval=$enable_suffixing; if test "x$enableval" = 'xno' 4420 + then : 4421 + suffixing=false 4422 + else $as_nop 4423 + suffixing=true 4424 + fi 4425 + else $as_nop 4426 + suffixing=true 4408 4427 fi 4409 4428 4410 4429
+7
configure.ac
··· 284 284 AC_SUBST([zinc_runtime_id_hi]) 285 285 AC_SUBST([bytecode_runtime_id]) 286 286 AC_SUBST([native_runtime_id]) 287 + AC_SUBST([suffixing]) 287 288 288 289 ## Generated files 289 290 ··· 710 711 [bindir_to_libdir="..${default_separator}lib${default_separator}ocaml"], 711 712 [bindir_to_libdir="$withval"])], 712 713 [bindir_to_libdir='']) 714 + 715 + AC_ARG_ENABLE([suffixing], 716 + [AS_HELP_STRING([--disable-suffixing], 717 + [disable suffixing of runtime executables and shared libraries])], 718 + [AS_IF([test "x$enableval" = 'xno'], [suffixing=false], [suffixing=true])], 719 + [suffixing=true]) 713 720 714 721 AC_ARG_WITH([afl], 715 722 [AS_HELP_STRING([--with-afl],
+3
release-info/howto.md
··· 166 166 # update build-aux/ocaml_version.m4 with the new future branch, 167 167 # 4.07.0+dev1-2018-06-26 => 4.08.0+dev0-2018-06-30 168 168 # Also increment OCAML__RELEASE_NUMBER in build-aux/ocaml_version.m4 169 + # If the major version number is changing, the logic in p_runtime_id in 170 + # tools/objinfo.ml mapping release number to major/minor version will need 171 + # altering. 169 172 # Update ocaml-variants.opam with new version. 170 173 tools/autogen 171 174 # Add a "Working version" section" to Changes
+1
runtime/startup_byt.c
··· 401 401 printf("word_size: %d\n", 8 * (int)sizeof(value) - 1); 402 402 printf("os_type: %s\n", OCAML_OS_TYPE); 403 403 printf("host: %s\n", HOST); 404 + printf("bytecode_runtime_id: %s\n", BYTECODE_RUNTIME_ID); 404 405 printf("flat_float_array: %s\n", 405 406 #ifdef FLAT_FLOAT_ARRAY 406 407 "true");
+5 -2
stdlib/Makefile
··· 85 85 "$(INSTALL_LIBDIR)" 86 86 87 87 runtime-launch-info: runtime.info tmpheader.exe 88 - @cat $^ > $@ 88 + @{ cat $^; \ 89 + printf '$(if $(filter true,$(SUFFIXING)),$(ZINC_RUNTIME_ID))'; } > $@ 89 90 91 + MANGLING = $(filter true,$(SUFFIXING)) 90 92 target_runtime-launch-info: tmpheader.exe 91 - @cat $^ > $@ 93 + @{ printf '$(if $(MANGLING),$(ZINC_RUNTIME_ID_HI),\000)'; \ 94 + cat $^; } > $@ 92 95 93 96 # The mingw-w64 and MSVC versions of tmpheader.exe are linked with special flags 94 97 # to reduce their size (considerably). In particular, the entry point is
+10 -3
testsuite/in_prefix/Makefile.test
··· 40 40 41 41 export PATH := $(SRCDIR_ABS)/testsuite/in_prefix/poisoned-runtime:$(PATH) 42 42 43 + ifeq "$(SUFFIXING)" "true" 44 + RUNTIME_NAME = ocamlrun-$(ZINC_RUNTIME_ID)$(EXE) 45 + else 46 + RUNTIME_NAME = ocamlrun$(EXE) 47 + endif 48 + 43 49 test-in-prefix: $(DRIVER) ../tools/main_in_c.$(O) ../tools/poisonedruntime$(EXE) 44 50 @rm -f ocamlrun* 45 - @$(LN) $(ROOTDIR)/runtime/ocamlrun$(EXE) test-ocamlrun$(EXE) 51 + @$(LN) $(ROOTDIR)/runtime/ocamlrun$(EXE) test-$(RUNTIME_NAME) 46 52 @$(MKDIR) poisoned-runtime 47 - @cd poisoned-runtime && $(LN) ../../tools/poisonedruntime$(EXE) ocamlrun$(EXE) 53 + @cd poisoned-runtime \ 54 + && $(LN) ../../tools/poisonedruntime$(EXE) $(RUNTIME_NAME) 48 55 @$< $(DRIVER_ARGS) 49 56 @rm -rf poisoned-runtime 50 - @rm -f test-ocamlrun$(EXE) 57 + @rm -f test-ocamlrun* 51 58 52 59 SCRUB_ENV = \ 53 60 CAML_LD_LIBRARY_PATH OCAMLLIB CAMLLIB OCAMLPARAM OCAMLRUNPARAM CAMLRUNPARAM
+2 -1
testsuite/tools/cmdline.ml
··· 106 106 ref {has_ocamlnat = false; has_ocamlopt = false; has_relative_libdir = None; 107 107 has_runtime_search = None; launcher_searches_for_ocamlrun = false; 108 108 target_launcher_searches_for_ocamlrun = false; 109 - bytecode_shebangs_by_default = false; libraries = []} 109 + bytecode_shebangs_by_default = false; filename_mangling = false; 110 + libraries = []; zinc_bootstrapped = false} 110 111 in 111 112 let error fmt = Printf.ksprintf (fun s -> raise (Arg.Bad s)) fmt in 112 113 let check_tree () =
+2 -2
testsuite/tools/environment.ml
··· 84 84 | Bytesections.{name = Name.DLLS; len} when len > 0 -> true 85 85 | _ -> false 86 86 in 87 - let tendered (runtime, search) = 87 + let tendered (runtime, id, search) = 88 88 let header = if start = "#!" then Header_shebang else Header_exe in 89 89 let dlls = List.exists is_DLLS sections in 90 - Tendered {header; dlls; runtime; search} 90 + Tendered {header; dlls; runtime; id; search} 91 91 in 92 92 Option.fold ~none:Custom ~some:tendered (Byterntm.read_runtime toc ic)) 93 93 with End_of_file | Bytesections.Bad_magic_number ->
+4 -1
testsuite/tools/harness.ml
··· 19 19 | Tendered of {header: launch_mode; 20 20 dlls: bool; 21 21 runtime: string; 22 + id: Misc.RuntimeID.t option; 22 23 search: Byterntm.search_method} 23 24 | Custom 24 25 | Vanilla ··· 35 36 launcher_searches_for_ocamlrun: bool; 36 37 target_launcher_searches_for_ocamlrun: bool; 37 38 bytecode_shebangs_by_default: bool; 38 - libraries: string list list 39 + filename_mangling: bool; 40 + libraries: string list list; 41 + zinc_bootstrapped: bool 39 42 } 40 43 end 41 44
+8 -1
testsuite/tools/harness.mli
··· 26 26 | Tendered of {header: launch_mode; 27 27 dlls: bool; 28 28 runtime: string; 29 + id: Misc.RuntimeID.t option; 29 30 search: Byterntm.search_method} 30 31 (** Tendered bytecode image. Executable uses the given mechanism to locate 31 32 a suitable runtime to execute the image. [dlls] is [true] if the ··· 74 75 bytecode_shebangs_by_default: bool; 75 76 (** True if ocamlc uses a shebang-style header rather than an executable 76 77 header for tendered bytecode executables. *) 77 - libraries: string list list 78 + filename_mangling: bool; 79 + (** True if the Runtime ID is being used for filename mangling. *) 80 + libraries: string list list; 78 81 (** Sorted list of basenames of libraries to test. 79 82 Derived from {v [$(OTHERLIBRARIES)] v} - {v Makefile.config v} *) 83 + zinc_bootstrapped: bool; 84 + (** True if boot/ocamlc has been bootstrapped (temporary, to allow the 85 + tests to pass on the bootstrap commit before they're updated following 86 + the bootstrap) *) 80 87 } 81 88 end 82 89
+23 -4
testsuite/tools/testBytecodeBinaries.ml
··· 83 83 program 84 84 else 85 85 failed, "compiled with -custom" 86 - | Tendered {runtime; header; search; _} -> 86 + | Tendered {runtime; id; header; search; _} -> 87 87 let reported_runtime = 88 + let id = 89 + Option.map 90 + (fun t -> "-" ^ Misc.RuntimeID.to_string t) id 91 + |> Option.value ~default:"" 92 + in 88 93 match search with 89 94 | Disable dir -> 90 - dir ^ runtime 95 + dir ^ runtime ^ id 91 96 | Fallback dir -> 92 - Printf.sprintf "[%s/]%s" dir runtime 97 + Printf.sprintf "[%s]%s%s" dir runtime id 93 98 | Enable -> 94 - runtime 99 + runtime ^ id 100 + in 101 + let expected_id = 102 + if config.filename_mangling then 103 + Some (Misc.RuntimeID.make_zinc ()) 104 + else 105 + None 95 106 in 96 107 let expected_search = 97 108 if Sys.win32 then ··· 105 116 Header_shebang 106 117 else 107 118 Header_exe 119 + in 120 + let pp_runtime_id f = function 121 + | None -> 122 + Format.pp_print_string f "<NONE>" 123 + | Some id -> 124 + Format.pp_print_string f (Misc.RuntimeID.to_string id) 108 125 in 109 126 let pp_search f = function 110 127 | Byterntm.Disable _ -> ··· 130 147 failed 131 148 |> check expected_search search 132 149 "search mechanism" pp_search 150 + |> check expected_id id 151 + "runtime ID" pp_runtime_id 133 152 |> check "ocamlrun" runtime 134 153 "runtime" Format.pp_print_string 135 154 |> check expected_launch_mode header
+1 -1
testsuite/tools/testRelocation.ml
··· 111 111 else 112 112 (* Bytecode runtimes and ocamlyacc of which only ocamlrund is linked 113 113 with -g *) 114 - `Other, (basename = "ocamlrund") 114 + `Other, (List.mem "ocamlrund" (String.split_on_char '-' basename)) 115 115 in 116 116 (* Combine this with the properties of the platform to determine whether the 117 117 executable will contain the build path. *)
+24 -6
testsuite/tools/test_in_prefix.ml
··· 49 49 \ @{<hint>libdir@} = [$prefix/]%s\n\ 50 50 \ - C compiler is %s [%s] for %s\n\ 51 51 \ - OCaml is %a%a; target binaries by default are %a\n\ 52 - \ - Executable header size is %.2fKiB (%d bytes)\n\ 52 + \ - Executable header size is %.2fKiB (%Ld bytes)\n\ 53 53 \ - Testing %s\n@?" 54 54 prefix bindir_suffix libdir_suffix 55 55 Config.c_compiler Config.c_compiler_vendor Config.target 56 56 pp_relocatable relocatable pp_reproducible reproducible 57 57 pp_relocatable target_relocatable 58 - (float_of_int header_size /. 1024.0) header_size summary 58 + (Int64.to_float header_size /. 1024.0) header_size summary 59 59 60 60 let run_tests ~sh config env = 61 61 TestDynlink.run config env Bytecode; ··· 119 119 in 120 120 List.map add_dependencies libraries 121 121 in 122 - let header_size = 123 - (Unix.stat (Filename.concat libdir "runtime-launch-info")).Unix.st_size in 122 + let header_size, filename_mangling = 123 + let file = Filename.concat libdir "runtime-launch-info" in 124 + In_channel.with_open_bin file @@ fun ic -> 125 + In_channel.length ic, (input_char ic <> '\000') 126 + in 124 127 let bytecode_shebangs_by_default = 125 128 Config.launch_method <> Config.Executable in 126 129 let launcher_searches_for_ocamlrun = Sys.win32 in ··· 129 132 {config with libraries; 130 133 launcher_searches_for_ocamlrun; 131 134 target_launcher_searches_for_ocamlrun; 132 - bytecode_shebangs_by_default} 135 + bytecode_shebangs_by_default; 136 + filename_mangling} 133 137 in 134 138 (* A compiler distribution is _Relocatable_ if its build, for a given system, 135 139 satisfies the following three properties: ··· 199 203 | _ -> 200 204 Harness.fail_because "Unexpected response from command -v sh" 201 205 in 206 + let config = 207 + let boot_ocamlc = Environment.in_test_root env "../../boot/ocamlc" in 208 + let ocamlrun = Environment.ocamlrun env in 209 + let zinc_bootstrapped = 210 + snd (Environment.run_process env ocamlrun [boot_ocamlc; "-config"]) 211 + |> List.exists (String.starts_with ~prefix:"zinc_runtime_id: ") 212 + in 213 + {config with zinc_bootstrapped} 214 + in 202 215 let run_tests = run_tests ~sh config in 203 216 (* 1. Relocation test *) 204 217 TestRelocation.run ~reproducible config env; ··· 225 238 Printf.printf "Re-running test programs\n%!"; 226 239 (* Verify that the searching runtimes are searching the directory containing 227 240 the program itself first. *) 228 - let runtime = "ocamlrun" in 241 + let runtime = 242 + if config.filename_mangling then 243 + Misc.RuntimeID.(ocamlrun "" (make_zinc ())) 244 + else 245 + "ocamlrun" 246 + in 229 247 rename_exe_in_test_root env ("test-" ^ runtime) runtime; 230 248 Fun.protect 231 249 ~finally:(fun () -> rename_exe_in_test_root env runtime ("test-" ^ runtime))
+41 -2
tools/objinfo.ml
··· 292 292 p_title title; 293 293 List.iter print l 294 294 295 - let p_runtime (runtime, search) = 295 + let p_runtime_id ({Misc.RuntimeID.dev; release; no_flat_float_array; fp; tsan; 296 + int31; static; no_compression; ansi; reserved} as t) = 297 + let version = 298 + if release > Config.release_number then 299 + "" 300 + else 301 + if release = 0 then 302 + " (Objective Caml 3.12)" 303 + else if release < 16 then 304 + Printf.sprintf " (OCaml 4.%02d)" (release - 1) 305 + else 306 + Printf.sprintf " (OCaml 5.%d)" (release - 16) 307 + in 308 + printf "\t%s = Release %d%s%s\n" 309 + (Misc.RuntimeID.to_string t) 310 + release version (if dev then " - development/altered version" else ""); 311 + if reserved > 0 then 312 + printf "\t - %d reserved header bit%s\n" 313 + reserved (if reserved = 1 then "" else "s"); 314 + if no_flat_float_array then 315 + printf "\t - Flat float array representation disabled\n"; 316 + if fp then 317 + printf "\t - Frame pointers enabled\n"; 318 + if tsan then 319 + printf "\t - TSAN enabled\n"; 320 + if int31 then 321 + printf "\t - Compiled without 64-bit support\n"; 322 + if static then 323 + printf "\t - Compiled without support dynamic loading\n"; 324 + if no_compression then 325 + printf "\t - Compiled without support for compressed marshalling\n"; 326 + if ansi then 327 + printf "\t - Windows Unicode support disabled\n" 328 + 329 + let p_runtime (runtime, id, search) = 330 + let runtime = 331 + let some id = runtime ^ "-" ^ Misc.RuntimeID.to_string id in 332 + Option.fold ~none:runtime ~some id 333 + in 296 334 let runtime = 297 335 match search with 298 336 | Byterntm.Enable -> runtime 299 337 | Byterntm.Disable dir -> dir ^ runtime 300 338 | Byterntm.Fallback dir -> Printf.sprintf "[%s]%s" dir runtime 301 339 in 302 - printf "Runtime:\n\t%s\n" runtime 340 + printf "Runtime:\n\t%s\n" runtime; 341 + Option.iter p_runtime_id id 303 342 304 343 let dump_byte ic = 305 344 let toc = Bytesections.read_toc ic in
+10
utils/misc.ml
··· 1536 1536 ansi = set 3 q3; (* bit 4 of q3 is unused *)} 1537 1537 else 1538 1538 None 1539 + 1540 + let of_zinc_hi ?(dev = not Config.is_official_release) 1541 + ?(release = Config.release_number) s = 1542 + Option.map (fun id -> {id with dev; release}) (of_string ("00" ^ s)) 1543 + 1544 + let ocamlrun variant runtime_id = 1545 + if is_zinc runtime_id then 1546 + Printf.sprintf "ocamlrun%s-%s" variant (to_string runtime_id) 1547 + else 1548 + invalid_arg "Misc.RuntimeID.ocamlrun" 1539 1549 end
+8
utils/misc.mli
··· 945 945 946 946 val of_string: string -> t option 947 947 (** Converts the 4-character representation back to a {!t} *) 948 + 949 + val of_zinc_hi: ?dev:bool -> ?release:int -> string -> t option 950 + (** Converts hi 2 characters of the representation back to a {!t} (using the 951 + default version information from {!Config}. *) 952 + 953 + val ocamlrun: string -> t -> string 954 + (** [ocamlrun variant runtime_id] returns the name for the runtime for the 955 + given Zinc Runtime ID. *) 948 956 end 949 957 950 958 (** {1 Miscellaneous type aliases} *)