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.

Use %standard_library_default in Config

Config.standard_library_default is now implemented using the
%standard_library_default primitive. This allows a convenient test which
can be added for `-set-runtime-default`.

The change also makes the host-like nature of of
Config.standard_library_default clearer, as the build of the
cross-compiler must now (correctly) specify the location of its (target)
Standard Library.

+49 -9
+4
Makefile.common
··· 176 176 OPTCOMPFLAGS += -function-sections 177 177 endif 178 178 179 + # Allow Makefile.cross to add flags to OC_COMMON_LINKFLAGS 180 + OC_CROSS_LINKFLAGS ?= 181 + OC_COMMON_LINKFLAGS += $(OC_CROSS_LINKFLAGS) 182 + 179 183 # The rule to compile C files 180 184 181 185 # This rule is similar to GNU make's implicit rule, except that it is more
+8 -1
Makefile.cross
··· 40 40 41 41 CROSS_OVERRIDES=OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun \ 42 42 BOOT_OCAMLLEX=ocamllex OCAMLYACC=ocamlyacc 43 + # The cross-compiler is linked as build/bin/ocamlopt -o cross/bin/ocamlopt 44 + # Config.standard_library_default for cross/bin/ocamlopt would by default be the 45 + # value for build/bin/ocamlopt (i.e. build/lib/ocaml), which is not what is 46 + # wanted. When linking the cross-compiler itself, therefore, this default must 47 + # be overridden with -set-runtime-default so that cross/bin/ocamlopt instead has 48 + # cross/lib/ocaml for Config.standard_library_default 43 49 CROSS_COMPILER_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc CAMLOPT=ocamlopt \ 44 - BEST_OCAMLC=ocamlc BEST_OCAMLOPT=ocamlopt BEST_OCAMLLEX=ocamllex 50 + BEST_OCAMLC=ocamlc BEST_OCAMLOPT=ocamlopt BEST_OCAMLLEX=ocamllex \ 51 + "OC_CROSS_LINKFLAGS=-set-runtime-default 'standard_library_default=$(LIBDIR)'" 45 52 CROSS_COMPILERLIBS_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc \ 46 53 CAMLOPT="$(ROOTDIR)/ocamlopt.opt$(EXE) $(STDLIBFLAGS)" 47 54
+11 -1
testsuite/tools/testDynlink.ml
··· 48 48 let compile ?(custom = false) () = 49 49 if Sys.file_exists test_program then 50 50 Harness.erase_file test_program; 51 - let args = if custom then "-custom" :: args else args in 51 + let args = 52 + if custom then 53 + "-custom" :: args 54 + else 55 + (* Hardening to ensure that Bytecode Dynlink is using the runtime's 56 + search path, not compiler's (i.e. unix.cma should be located using 57 + Config.standard_library_default but dllunixbyt.so should be located 58 + using caml_runtime_standard_library_default) *) 59 + "-set-runtime-default" :: "standard_library_default=/does-not-exist" 60 + :: args 61 + in 52 62 (* In the Renamed phase for a bytecode-only build, ocamlc will be 53 63 ocamlc.byte and will need to be called via ocamlrun *) 54 64 let runtime =
+22 -4
testsuite/tools/testLinkModes.ml
··· 142 142 if Environment.is_renamed env then 143 143 stdlib_exists_when_renamed 144 144 else 145 - true in 145 + false in 146 146 let args = [string_of_bool stdlib_exists; prefix; libdir_suffix] in 147 147 let argv0 = 148 148 if argv0 = test_program then ··· 562 562 else 563 563 options 564 564 in 565 + let options = 566 + if Environment.is_renamed env then 567 + options 568 + else 569 + let new_libdir = 570 + Filename.concat (Environment.prefix env ^ ".new") 571 + (Environment.libdir_suffix env) in 572 + let stdlib_default = "standard_library_default=" ^ new_libdir in 573 + let options = "-set-runtime-default" :: stdlib_default :: options in 574 + if tendered then 575 + let libdir = Environment.libdir env in 576 + "-dllpath" :: (Filename.concat libdir "stublibs") :: options 577 + else 578 + options 579 + in 565 580 let args = 566 581 "-o" :: output :: 567 582 "test_install_script.ml" :: options ··· 618 633 `None 619 634 else 620 635 let stdlib_exists_when_renamed = 621 - (* Config.standard_library is an absolute path, and therefore will 622 - always point to the Original location in the Renamed phase. *) 623 - false 636 + (* In the Original phase, -set-runtime-default is used to set 637 + standard_library_default to the Renamed phase's location. When 638 + the tests are recompiled in the Renamed phase, this is not done. 639 + The effect is that if any test is being run in the Renamed phase, 640 + Config.standard_library will be correct. *) 641 + not (Environment.is_renamed env) 624 642 in 625 643 make_test_runner ~stdlib_exists_when_renamed ~may_segfault ~with_unix 626 644 ~tendered ~target_launcher_searches_for_ocamlrun
+4
utils/config.common.ml.in
··· 20 20 (* The main OCaml version string has moved to ../build-aux/ocaml_version.m4 *) 21 21 let version = Sys.ocaml_version 22 22 23 + external standard_library_default : unit -> string = "%standard_library_default" 24 + 25 + let standard_library_default = standard_library_default () 26 + 23 27 let standard_library = 24 28 try 25 29 Sys.getenv "OCAMLLIB"
-1
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 standard_library_default = "/tmp" 25 24 let ccomp_type = "n/a" 26 25 let c_compiler = boot_cannot_call "the C compiler" 27 26 let c_compiler_vendor = ""
-2
utils/config.generated.ml.in
··· 20 20 21 21 let bindir = {@QS@|@ocaml_bindir@|@QS@} 22 22 23 - let standard_library_default = {@QS@|@ocaml_libdir@|@QS@} 24 - 25 23 let ccomp_type = {@QS@|@ccomp_type@|@QS@} 26 24 let c_compiler = {@QS@|@CC@|@QS@} 27 25 let c_compiler_vendor = {@QS@|@ocaml_cc_vendor@|@QS@}