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.

Build suffixed shared runtimes

New names for libcamlrun_shared.so and libasmrun_shared.so without the
_shared suffix and using the target triplet and runtime ID. Both ocamlc
and ocamlopt explicitly recognise `-runtime-variant _shared` and select
the correct name.

Symbolic links for libcamlrun_shared.so and libasmrun_shared.so to allow
any C programs which linked against the the output of `-output-obj` to
continue to work.

+97 -25
+4 -3
Changes
··· 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 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 + triplet, to provide mangled names for the ocamlrun executable and its variants 98 + and the DLL versions of both the bytecode and native runtimes, with symlinks 99 + created for the original names. The behaviour is disabled by configuring with 100 + --disable-suffixing. 100 101 (David Allsopp, review by Damien Doligez and Samuel Hym) 101 102 102 103 - #12269, #12410, #13063: Fix unsafety, deadlocks, and/or leaks should
+34 -12
Makefile
··· 1320 1320 ifeq "$(UNIX_OR_WIN32)" "unix" 1321 1321 ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "true" 1322 1322 runtime_BYTECODE_STATIC_LIBRARIES += runtime/libcamlrun_pic.$(A) 1323 - runtime_BYTECODE_SHARED_LIBRARIES += runtime/libcamlrun_shared.$(SO) 1323 + runtime_BYTECODE_SHARED_LIBRARIES += camlrun 1324 1324 runtime_NATIVE_STATIC_LIBRARIES += runtime/libasmrun_pic.$(A) 1325 - runtime_NATIVE_SHARED_LIBRARIES += runtime/libasmrun_shared.$(SO) 1325 + runtime_NATIVE_SHARED_LIBRARIES += asmrun 1326 1326 endif 1327 1327 endif 1328 1328 ··· 1373 1373 1374 1374 .PHONY: runtime-all 1375 1375 runtime-all: \ 1376 - $(runtime_BYTECODE_STATIC_LIBRARIES) $(runtime_BYTECODE_SHARED_LIBRARIES) \ 1376 + $(runtime_BYTECODE_STATIC_LIBRARIES) \ 1377 + $(runtime_BYTECODE_SHARED_LIBRARIES:%=runtime/lib%_shared$(EXT_DLL)) \ 1377 1378 $(runtime_PROGRAMS:%=runtime/%$(EXE)) $(SAK) 1378 1379 1379 1380 .PHONY: runtime-allopt 1380 1381 ifeq "$(NATIVE_COMPILER)" "true" 1381 1382 runtime-allopt: \ 1382 - $(runtime_NATIVE_STATIC_LIBRARIES) $(runtime_NATIVE_SHARED_LIBRARIES) 1383 + $(runtime_NATIVE_STATIC_LIBRARIES) \ 1384 + $(runtime_NATIVE_SHARED_LIBRARIES:%=runtime/lib%_shared$(EXT_DLL)) 1383 1385 else 1384 1386 runtime-allopt: 1385 1387 $(error The build has been configured with --disable-native-compiler) ··· 2771 2773 2772 2774 ifeq "$(SUFFIXING)" "true" 2773 2775 MANGLE_RUNTIME_NAME = $(TARGET)-$(1)-$(BYTECODE_RUNTIME_ID)$(EXE) 2776 + MANGLE_RUNTIME_DLL_NAME = lib$(1)-$(TARGET)-$($(2)_RUNTIME_ID)$(EXT_DLL) 2774 2777 else 2775 2778 MANGLE_RUNTIME_NAME = $(1)$(EXE) 2779 + MANGLE_RUNTIME_DLL_NAME = lib$(1)_shared$(EXT_DLL) 2776 2780 endif 2777 2781 2778 2782 define INSTALL_RUNTIME ··· 2788 2792 "$(1)-$(ZINC_RUNTIME_ID)$(EXE)" 2789 2793 endif 2790 2794 endef 2795 + define INSTALL_RUNTIME_LIB 2796 + ifeq "$(2)" "BYTECODE" 2797 + install:: 2798 + else 2799 + installopt:: 2800 + endif 2801 + $(INSTALL_PROG) \ 2802 + runtime/lib$(1)_shared$(EXT_DLL) \ 2803 + "$(INSTALL_LIBDIR)/$(call MANGLE_RUNTIME_DLL_NAME,$(1),$(2))" 2804 + ifeq "$(SUFFIXING)" "true" 2805 + cd "$(INSTALL_LIBDIR)" && \ 2806 + $(LN) "$(call MANGLE_RUNTIME_DLL_NAME,$(1),$(2))" \ 2807 + "lib$(1)_shared$(EXT_DLL)" 2808 + endif 2809 + endef 2791 2810 2792 2811 $(foreach runtime, $(runtime_PROGRAMS), \ 2793 2812 $(eval $(call INSTALL_RUNTIME,$(runtime)))) ··· 2795 2814 install:: 2796 2815 $(INSTALL_DATA) runtime/ld.conf $(runtime_BYTECODE_STATIC_LIBRARIES) \ 2797 2816 "$(INSTALL_LIBDIR)" 2798 - ifneq "$(runtime_BYTECODE_SHARED_LIBRARIES)" "" 2799 - $(INSTALL_PROG) $(runtime_BYTECODE_SHARED_LIBRARIES) \ 2800 - "$(INSTALL_LIBDIR)" 2801 - endif 2817 + 2818 + $(foreach shared_runtime, $(runtime_BYTECODE_SHARED_LIBRARIES), \ 2819 + $(eval $(call INSTALL_RUNTIME_LIB,$(shared_runtime),BYTECODE))) 2820 + 2821 + install:: 2802 2822 $(INSTALL_DATA) runtime/caml/domain_state.tbl runtime/caml/*.h \ 2803 2823 "$(INSTALL_INCDIR)" 2804 2824 $(INSTALL_PROG) ocaml$(EXE) "$(INSTALL_BINDIR)" ··· 2950 2970 2951 2971 # Installation of the native-code compiler 2952 2972 .PHONY: installopt 2953 - installopt: 2973 + installopt:: 2954 2974 $(INSTALL_DATA) $(runtime_NATIVE_STATIC_LIBRARIES) "$(INSTALL_LIBDIR)" 2955 - ifneq "$(runtime_NATIVE_SHARED_LIBRARIES)" "" 2956 - $(INSTALL_PROG) $(runtime_NATIVE_SHARED_LIBRARIES) "$(INSTALL_LIBDIR)" 2957 - endif 2975 + 2976 + $(foreach shared_runtime, $(runtime_NATIVE_SHARED_LIBRARIES), \ 2977 + $(eval $(call INSTALL_RUNTIME_LIB,$(shared_runtime),NATIVE))) 2978 + 2979 + installopt:: 2958 2980 ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true" 2959 2981 $(call INSTALL_STRIPPED_BYTE_PROG,\ 2960 2982 ocamlopt$(EXE),"$(INSTALL_BINDIR)/ocamlopt.byte$(EXE)")
+12 -6
asmcomp/asmlink.ml
··· 105 105 end 106 106 107 107 let runtime_lib () = 108 - let libname = "libasmrun" ^ !Clflags.runtime_variant ^ ext_lib in 109 - try 110 - if !Clflags.nopervasives || not !Clflags.with_runtime then [] 111 - else [ Load_path.find libname ] 112 - with Not_found -> 113 - raise(Error(File_not_found libname)) 108 + if !Clflags.runtime_variant = "_shared" then 109 + if Config.suffixing then 110 + [Misc.RuntimeID.shared_runtime Sys.Native] 111 + else 112 + ["-lasmrun_shared"] 113 + else 114 + let libname = "libasmrun" ^ !Clflags.runtime_variant ^ ext_lib in 115 + try 116 + if !Clflags.nopervasives || not !Clflags.with_runtime then [] 117 + else [ Load_path.find libname ] 118 + with Not_found -> 119 + raise(Error(File_not_found libname)) 114 120 115 121 (* First pass: determine which units are needed *) 116 122
+10 -2
bytecomp/bytelink.ml
··· 843 843 if not with_main && !Clflags.debug then 844 844 output_cds_file ((Filename.chop_extension outfile) ^ ".cds") 845 845 846 + let runtime_library_name runtime_variant = 847 + if runtime_variant = "_shared" && Config.suffixing then 848 + Misc.RuntimeID.shared_runtime Sys.Bytecode 849 + else 850 + "-lcamlrun" ^ runtime_variant 851 + 846 852 (* Build a custom runtime *) 847 853 848 854 let build_custom_runtime prim_name exec_name = 849 855 let runtime_lib = 850 856 if not !Clflags.with_runtime 851 857 then "" 852 - else "-lcamlrun" ^ !Clflags.runtime_variant in 858 + else runtime_library_name !Clflags.runtime_variant 859 + in 853 860 let stable_name = 854 861 if not !Clflags.keep_camlprimc_file then 855 862 Some "camlprim.c" ··· 992 999 let runtime_lib = 993 1000 if not !Clflags.with_runtime 994 1001 then "" 995 - else "-lcamlrun" ^ !Clflags.runtime_variant in 1002 + else runtime_library_name !Clflags.runtime_variant 1003 + in 996 1004 Ccomp.call_linker mode output_name 997 1005 ([obj_file] @ List.rev !Clflags.ccobjs @ [runtime_lib]) 998 1006 c_libs = 0
+3 -2
testsuite/tools/testLinkModes.ml
··· 576 576 ["-output-complete-obj"; "-noautolink"; "-cclib"; "-lunixnat"; 577 577 "-cclib"; "-lcomprmarsh"] 578 578 | Output_complete_obj(C_ocamlopt, Shared) -> 579 - (* ocamlopt doesn't correctly implement -runtime-variant _shared *) 580 - let compilation_exit_code = fails_if true in 579 + (* ocamlopt allows the .so to be passed to the partial linker which 580 + fails with GNU ld, but not with the macOS linker *) 581 + let compilation_exit_code = fails_if (Config.system <> "macosx") in 581 582 f ~mode:Native ~use_shared_runtime:true 582 583 ~compilation_exit_code ~clibs:[Config.compression_c_libraries] 583 584 ["-output-complete-obj"; "-noautolink"; "-cclib"; "-lunixnat";
+1
utils/config.fixed.ml
··· 85 85 let flexdll_dirs = [] 86 86 let ar_supports_response_files = true 87 87 let shebangscripts = false 88 + let suffixing = false 88 89 let launch_method = "sh"
+2
utils/config.generated.ml.in
··· 107 107 108 108 let shebangscripts = @shebangscripts@ 109 109 110 + let suffixing = @suffixing@ 111 + 110 112 let launch_method = {@QS@|@launch_method_target@|@QS@}
+6
utils/config.mli
··· 406 406 407 407 @since 5.5 *) 408 408 409 + val suffixing : bool 410 + (** Whether the runtime executable and shared library filenames are being 411 + mangled with Runtime IDs and the {!target}. 412 + 413 + @since 5.5 *) 414 + 409 415 val bytecode_runtime_id : string 410 416 (** The Runtime ID for this build of the bytecode runtime system 411 417
+12
utils/misc.ml
··· 1546 1546 Printf.sprintf "ocamlrun%s-%s" variant (to_string runtime_id) 1547 1547 else 1548 1548 invalid_arg "Misc.RuntimeID.ocamlrun" 1549 + 1550 + let shared_runtime ?runtime_id ?(host = Config.target) ?(prefix = "-l") 1551 + backend_type = 1552 + match backend_type with 1553 + | Sys.Native -> 1554 + let runtime_id = Option.value ~default:(make_native ()) runtime_id in 1555 + Printf.sprintf "%sasmrun-%s-%s" prefix host (to_string runtime_id) 1556 + | Sys.Bytecode -> 1557 + let runtime_id = Option.value ~default:(make_bytecode ()) runtime_id in 1558 + Printf.sprintf "%scamlrun-%s-%s" prefix host (to_string runtime_id) 1559 + | Sys.Other _ -> 1560 + invalid_arg "Misc.RuntimeID.shared_runtime" 1549 1561 end
+13
utils/misc.mli
··· 953 953 val ocamlrun: string -> t -> string 954 954 (** [ocamlrun variant runtime_id] returns the name for the runtime for the 955 955 given Zinc Runtime ID. *) 956 + 957 + val shared_runtime: ?runtime_id:t -> ?host:string 958 + -> ?prefix:string -> Sys.backend_type -> string 959 + (** [shared_runtime ?runtime_id ?host ?prefix backend] returns the name of the 960 + shared runtime for the given [backend]. [runtime_id] defaults to 961 + {!make_bytecode} if [backend = Sys.Bytecode] and {!make_native} if 962 + [backend = Sys.Native] and [host] to {!Config.target}. [prefix] defaults 963 + to ["-l"] and the function does not append {!Config.ext_dll}. 964 + 965 + e.g. [shared_runtime ~host:"x86_64-pc-linux-gnu" Native 966 + = "-lasmrun-x86_64-pc-linux-gnu-b100"] for a default OCaml 5.5 967 + build on a 64-bit system with shared library support and compressed 968 + marshalling. *) 956 969 end 957 970 958 971 (** {1 Miscellaneous type aliases} *)