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.

Update the installation test for enable-relative

+127 -58
+2
.depend
··· 10778 10778 testsuite/tools/test_in_prefix.cmi 10779 10779 testsuite/tools/test_in_prefix.cmi : 10780 10780 testsuite/tools/test_ld_conf.cmo : \ 10781 + otherlibs/unix/unix.cmi \ 10781 10782 testsuite/tools/harness.cmi \ 10782 10783 testsuite/tools/environment.cmi \ 10783 10784 utils/config.cmi \ 10784 10785 testsuite/tools/test_ld_conf.cmi 10785 10786 testsuite/tools/test_ld_conf.cmx : \ 10787 + otherlibs/unix/unix.cmx \ 10786 10788 testsuite/tools/harness.cmx \ 10787 10789 testsuite/tools/environment.cmx \ 10788 10790 utils/config.cmx \
+1 -1
testsuite/in_prefix/Makefile.test
··· 23 23 endif 24 24 25 25 DRIVER_ARGS = \ 26 - $(VERBOSE_FLAG) --bindir "$(BINDIR)" --libdir "$(LIBDIR)" \ 26 + $(VERBOSE_FLAG) --bindir "$(BINDIR)" --libdir '$(TARGET_LIBDIR)' \ 27 27 $(call bool_to_with, ocamlnat, $(INSTALL_OCAMLNAT)) \ 28 28 $(call bool_to_with, ocamlopt, $(NATIVE_COMPILER)) \ 29 29 $(OTHERLIBRARIES) --pwd "$(SRCDIR_ABS)/testsuite/in_prefix"
+6 -3
testsuite/in_prefix/README.md
··· 46 46 During this second execution, the test harness does whatever is physically 47 47 possible to allow these tests to proceed: 48 48 - Environment variables `CAML_LD_LIBRARY_PATH` and `OCAMLLIB` are manipulated to 49 - allow the compiler to operate 49 + allow the compiler to operate (unless the compiler has been configured with 50 + `--with-relative-libdir`) 50 51 - Bytecode executables which will no longer be able to find `ocamlrun` are 51 52 explicitly passed to `ocamlrun`. The harness always verifies that this step is 52 53 required by first executing the binary and ensuring that it fails and then ··· 72 73 - On Unix, the bytecode toplevel contains the absolute location of `ocamlrun`, 73 74 so must be explicitly invoked via `ocamlrun` 74 75 - Both toplevels contain the absolute location of the Standard Library, 75 - requiring `OCAMLLIB` to be set 76 + requiring `OCAMLLIB` to be set, unless the compiler was configured with 77 + `--with-relative-libdir` 76 78 77 79 ### Loading archives/plugins (.cma / .cmxs) with `Dynlink` 78 80 ··· 84 86 compiler is available, then both `ocamlc` and `ocamlopt` will be native 85 87 executables) 86 88 - Both compilers contain the absolute location of the Standard Library, 87 - requiring `OCAMLLIB` to be set 89 + requiring `OCAMLLIB` to be set, unless the comnpiler was configured with 90 + `--with-relative-libdir` 88 91 - The executable created by `ocamlc` contains the absolute location of 89 92 `ocamlrun`, so must be both explicitly invoked via `ocamlrun` and also have 90 93 `CAML_LD_LIBRARY_PATH` or `OCAMLLIB` adjusted, as that `ocamlrun` will not be
+1 -1
testsuite/tools/cmdline.ml
··· 176 176 "--pwd", Arg.Set_string pwd, "<pwd>\tCurrent working directory to use"; 177 177 "--bindir", Arg.String (check_exists ~absolute:true bindir), "\ 178 178 <bindir>\tDirectory containing programs (must share a prefix with --libdir)"; 179 - "--libdir", Arg.String (check_exists ~absolute:true libdir), "\ 179 + "--libdir", Arg.String (check_exists ~absolute:false libdir), "\ 180 180 <libdir>\tDirectory containing stdlib.cma (must share a prefix with --bindir)"; 181 181 "--summary", Arg.Set summary, ""; 182 182 "--verbose", Arg.Set verbose, "";
+2 -1
testsuite/tools/harness.mli
··· 53 53 has_ocamlopt: bool; 54 54 (** {v [$(NATIVE_COMPILER)] v} - {v Makefile.config v} *) 55 55 has_relative_libdir: string option; 56 - (** Not implemented; always None. *) 56 + (** {v $(TARGET_LIBDIR_IS_RELATIVE) v} and {v $(TARGET_LIBDIR) v} - 57 + {v Makefile.build_config v} *) 57 58 has_runtime_search: bool option; 58 59 (** Not implemented; always None. *) 59 60 launcher_searches_for_ocamlrun: bool;
+7 -4
testsuite/tools/testBytecodeBinaries.ml
··· 44 44 if classification <> Vanilla then 45 45 let fails = 46 46 (* After the prefix has been renamed, bytecode executables compiled 47 - with -custom will still work. Otherwise, only executables where the 48 - header can search for ocamlrun and which do not require any C stubs 49 - to be loaded will still work. *) 47 + with -custom will still work. Otherwise, the header needs to be 48 + able to search for ocamlrun and, if applicable, ocamlrun needs to 49 + be able to load C stubs (which will only happen if the runtime 50 + locates the Standard Library using a relative directory, so that it 51 + can find ld.conf) *) 50 52 Environment.is_renamed env 51 53 && match classification with 52 54 | Tendered {dlls; _} -> 53 - not config.launcher_searches_for_ocamlrun || dlls 55 + not config.launcher_searches_for_ocamlrun 56 + || dlls && config.has_relative_libdir = None 54 57 | _ -> 55 58 false 56 59 in
+16 -7
testsuite/tools/testDynlink.ml
··· 64 64 let runtime = 65 65 mode = Bytecode && Harness.ocamlc_fails_after_rename config in 66 66 (* In the Renamed phase, Config.standard_library will still point to the 67 - Original location *) 68 - let stdlib = true in 67 + Original location, unless the compiler has been configured with a 68 + relative libdir *) 69 + let stdlib = (config.has_relative_libdir = None) in 69 70 let (_, output) = 70 71 Environment.run_process ~runtime ~stdlib env compiler args in 71 72 Environment.display_output output ··· 88 89 mode = Bytecode 89 90 && expected_exit_code = None 90 91 && not config.target_launcher_searches_for_ocamlrun 92 + && config.has_relative_libdir = None 91 93 in 92 94 (* If the library needs C stubs to be loaded dynamically, then the runtime 93 95 will need CAML_LD_LIBRARY_PATH set in the Renamed phase. *) 94 96 let stubs = 95 97 has_c_stubs 96 98 && expected_exit_code = None 99 + && Config.supports_shared_libraries 100 + && config.has_relative_libdir = None 97 101 in 98 102 let expected_exit_code = 99 103 match expected_exit_code with ··· 136 140 let not_dynlink l = not (List.mem "dynlink" l) in 137 141 let files, re_compile = compile_test_program () in 138 142 let expected_exit_code = 139 - (* Bytecode executables launched using the executable header require 140 - caml_executable_name to know where the runtime is. As the Standard 141 - Library is only stored as an absolute path, this doesn't affect the 142 - execution of the test driver (yet). *) 143 - None in 143 + (* Relocatable OCaml bytecode executables launched using the executable 144 + header require caml_executable_name, or they end up being accidentally 145 + relative, since the exec call leaves argv[0] as being the bytecode image 146 + itself. *) 147 + if mode = Bytecode && config.has_relative_libdir <> None 148 + && Harness.no_caml_executable_name 149 + && Environment.launched_via_stub test_program then 150 + Some 2 151 + else 152 + None in 144 153 let libraries = List.filter not_dynlink config.libraries in 145 154 let () = 146 155 List.iter (test_libraries_in_prog ?expected_exit_code env) libraries;
+33 -16
testsuite/tools/testLinkModes.ml
··· 125 125 around some problems with shared runtimes on s390x and riscv which don't 126 126 reliably fail. 127 127 *) 128 - let run_program env _config = 128 + let run_program env config = 129 129 let prefix = Environment.prefix env in 130 130 let libdir_suffix = Environment.libdir_suffix env in 131 131 let prefix, libdir_suffix = ··· 142 142 if Environment.is_renamed env then 143 143 stdlib_exists_when_renamed 144 144 else 145 - false in 145 + config.has_relative_libdir <> None 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 ··· 259 259 - Sys.argv.(0) doesn't equal Sys.argv.(3) 260 260 - Config.standard_library exists when it shouldn't (or vice versa) *) 261 261 let test_runs usr_bin_sh test_program_path test_program 262 - _config env ~via_ocamlrun = 262 + config env ~via_ocamlrun = 263 263 let tests = 264 264 let test_program_relative = 265 265 Filename.concat Filename.current_dir_name test_program ··· 315 315 else if Sys.win32 then 316 316 (* stdlib/header.c correctly preserves argv[0] for Windows *) 317 317 Success {executable_name = test_program_path; argv0} 318 + else if Harness.no_caml_executable_name 319 + && config.has_relative_libdir <> None then 320 + (* Without caml_executable_name, ocamlrun will be forced to 321 + interpret the relative standard library relative to argv[0], 322 + which will fail. *) 323 + Fail 134 318 324 else 319 325 (* stdlib/header.c does not preserve argv[0] for Unix *) 320 326 Success {executable_name = argv0_resolved; ··· 351 357 run in the Renamed phase for other reasons. *) 352 358 let make_test_runner ~stdlib_exists_when_renamed ~may_segfault ~with_unix 353 359 ~tendered ~target_launcher_searches_for_ocamlrun usr_bin_sh 354 - test_program_path test_program config _env = 355 - (* Bytecode executables with absolute headers will need to be 356 - invoked via ocamlrun after the prefix has been renamed. *) 360 + test_program_path test_program config env = 361 + (* Bytecode executables with absolute headers will need to be invoked via 362 + ocamlrun after the prefix has been renamed. *) 357 363 let via_ocamlrun = 358 364 tendered && not target_launcher_searches_for_ocamlrun 365 + && (config.has_relative_libdir = None || not (Environment.is_renamed env)) 359 366 in 360 367 let rec run env = 361 368 let runs = ··· 367 374 | Fail code -> "", code, "" 368 375 | Success {executable_name; argv0} -> executable_name, 0, argv0 369 376 in 370 - let stubs = tendered && with_unix in 377 + let stubs = tendered && with_unix && config.has_relative_libdir = None in 371 378 run_program 372 379 env config ~runtime:via_ocamlrun ~stubs 373 380 test_program_path ~prefix_path_with_cwd expected_executable_name ··· 563 570 options 564 571 in 565 572 let options = 566 - if Environment.is_renamed env then 573 + if Environment.is_renamed env || config.has_relative_libdir <> None then 567 574 options 568 575 else 569 576 let new_libdir = ··· 604 611 let runtime = 605 612 mode = Bytecode && Harness.ocamlc_fails_after_rename config in 606 613 (* In the Renamed phase, Config.standard_library will still point to 607 - the Original location *) 608 - let stdlib = true in 614 + the Original location, unless the compiler has been configured 615 + with a relative libdir *) 616 + let stdlib = (config.has_relative_libdir = None) in 609 617 Environment.run_process ~fails ~runtime ~stdlib env compiler args 610 618 in 611 619 Environment.display_output output; ··· 633 641 `None 634 642 else 635 643 let stdlib_exists_when_renamed = 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) 644 + if config.has_relative_libdir = None then 645 + (* In the Original phase, for a compiler with an absolute libdir, 646 + -set-runtime-default is used to set standard_library_default to 647 + the Renamed phase's location. When the tests are recompiled in 648 + the Renamed phase, this is not done. The effect is that if any 649 + test is being run in the Renamed phase, Config.standard_library 650 + will be correct. *) 651 + not (Environment.is_renamed env) 652 + else 653 + (* When the compiler has a relative libdir, -set-runtime-default 654 + is implicitly being tested by the build process, and we wish to 655 + test the opposite in the harness - thus the test programs 656 + compiled in the Original phase will _not_ be able to find the 657 + Standard Library in the Renamed phase. *) 658 + Environment.is_renamed env 642 659 in 643 660 make_test_runner ~stdlib_exists_when_renamed ~may_segfault ~with_unix 644 661 ~tendered ~target_launcher_searches_for_ocamlrun
+32 -12
testsuite/tools/testRelocation.ml
··· 59 59 (* Determine if the installation prefix should be found in this file *) 60 60 let prefix = 61 61 let code_embeds_stdlib_location = 62 - (* The runtime binaries all contain OCAML_STDLIB_DIR and everything 63 - except flexlink and ocamllex link with the Config module, either 64 - directly or via ocamlcommon *) 65 - not (List.mem basename ["flexlink.byte"; "flexlink.opt"; "flexlink"; 66 - "ocamllex.byte"; "ocamllex.opt"; "ocamllex"; 67 - "ocamlyacc"]) 62 + (* If the compiler is configured with an absolute libdir, the runtime 63 + binaries all contain OCAML_STDLIB_DIR and everything except flexlink 64 + and ocamllex link with the Config module, either directly or via 65 + ocamlcommon *) 66 + config.has_relative_libdir = None 67 + && not (List.mem basename ["flexlink.byte"; "flexlink.opt"; "flexlink"; 68 + "ocamllex.byte"; "ocamllex.opt"; "ocamllex"; 69 + "ocamlyacc"]) 68 70 in 69 71 let linker_embeds_stdlib_location = 70 72 (* If the launcher doesn't search for ocamlrun, then either the #! stub ··· 160 162 ~ocaml_debug:has_ocaml_debug_info, 161 163 ~c_debug:has_c_debug_info, 162 164 ~s:contains_assembled_objects) = 163 - if basename = "Makefile.config" || basename = "runtime-launch-info" then 164 - (* These files all embed the Standard Library location *) 165 + if basename = "Makefile.config" then 166 + (* Embeds the Standard Library location *) 165 167 (~stdlib:true, ~ocaml_debug:false, ~c_debug:false, ~s:false) 166 168 else if basename = "config.cmx" then 167 169 (* config.cmx contains Config.standard_library for inlining *) 168 - (~stdlib:true, ~ocaml_debug:false, ~c_debug:false, ~s:false) 170 + let stdlib = 171 + config.has_relative_libdir = None && not Config.flambda in 172 + (~stdlib, ~ocaml_debug:false, ~c_debug:false, ~s:false) 169 173 else if List.mem ext [".cma"; ".cmo"; ".cmt"; ".cmti"] then 170 174 let stdlib = (* via Config.standard_library *) 171 - List.mem basename ["config.cmt"; "config_main.cmt"; 172 - "ocamlcommon.cma"] in 175 + config.has_relative_libdir = None 176 + && List.mem basename ["config.cmt"; "config_main.cmt"; 177 + "ocamlcommon.cma"] in 178 + (* The compiler's artefacts are all compiled with -g *) 173 179 (~stdlib, ~ocaml_debug:true, ~c_debug:false, ~s:false) 180 + else if basename = "runtime-launch-info" then 181 + (* When the compiler is configured with a relative libdir, 182 + runtime-launch-info just contains ".", rather than the prefix *) 183 + let stdlib = (config.has_relative_libdir = None) in 184 + (~stdlib, ~ocaml_debug:false, ~c_debug:false, ~s:false) 174 185 else if ext = ".cmxs" then 175 186 (* All the .cmxs files built by the distribution at present include C 176 187 objects and obviously contain assembled objects. *) ··· 191 202 Sys.file_exists (Filename.remove_extension file ^ ".cmxa") in 192 203 (* Config.standard_library is in ocamlcommon and the bytecode runtime 193 204 embeds the Standard Library location *) 194 - let stdlib = Filename.remove_extension basename = "ocamlcommon" in 205 + let stdlib = 206 + config.has_relative_libdir = None 207 + && Filename.remove_extension basename = "ocamlcommon" in 195 208 (~stdlib, ~ocaml_debug:false, ~c_debug:(not is_ocaml), ~s:is_ocaml) 196 209 else 197 210 (* DLLs are either the shared versions of the runtime libraries or ··· 225 238 LocationSet.singleton Prefix 226 239 else 227 240 LocationSet.empty 241 + in 242 + let prefix = 243 + if config.has_relative_libdir <> None 244 + && basename = "Makefile.config" then 245 + LocationSet.add Relative prefix 246 + else 247 + prefix 228 248 in 229 249 if contains_build_path then 230 250 LocationSet.add Build prefix
+1 -1
testsuite/tools/testToplevel.ml
··· 97 97 Environment.run_process 98 98 ~fails:(expected_exit_code <> 0) 99 99 ~runtime:(mode = Bytecode && not config.launcher_searches_for_ocamlrun) 100 - ~stdlib:true env toplevel args 100 + ~stdlib:(config.has_relative_libdir = None) env toplevel args 101 101 in 102 102 Environment.display_output output; 103 103 if exit_code <> expected_exit_code then
+7 -5
testsuite/tools/test_in_prefix.ml
··· 144 144 145 145 For the compiler's files to be reproducible, the compiler needs to be both 146 146 relocatable and also required support from the assembler and C compiler. *) 147 - let relocatable = false in 147 + let relocatable = 148 + config.has_relative_libdir <> None 149 + && config.launcher_searches_for_ocamlrun 150 + in 148 151 let reproducible = 149 - relocatable 152 + relocatable && false 150 153 (* At present, the compiler build doesn't actually take advantage of this 151 - configuration, but this does not matter because the compiler cannot yet 152 - be relocatable! *) 154 + configuration *) 153 155 && (not config.has_ocamlopt 154 156 || not Toolchain.assembler_embeds_build_path 155 157 || Config.as_has_debug_prefix_map && Config.architecture <> "riscv") ··· 157 159 && (not Toolchain.c_compiler_always_embeds_build_path 158 160 || not Toolchain.c_compiler_debug_paths_can_be_absolute) 159 161 in 160 - let target_relocatable = false in 162 + let target_relocatable = config.target_launcher_searches_for_ocamlrun in 161 163 (* Use Harness.pp_path unless --verbose was specified *) 162 164 let pp_path = 163 165 if verbose then
+19 -7
testsuite/tools/test_ld_conf.ml
··· 39 39 and var_setting = Unset | Empty | Set of string list 40 40 41 41 (* Set of tests to run in a given environment *) 42 - let tests _config env = 42 + let tests config env = 43 43 (* Convenience function - [if_ld_conf_found outcome] returns the empty list in 44 44 the Renamed phase. *) 45 45 let if_ld_conf_found outcome = 46 - (* ocamlrun can't find ld.conf after the prefix has been renamed *) 47 - if Environment.is_renamed env then 46 + (* ocamlrun can only find ld.conf after the prefix has been renamed if it's 47 + configured with --with-relative-libdir *) 48 + if Environment.is_renamed env && config.has_relative_libdir = None then 48 49 [] 49 50 else 50 51 outcome ··· 63 64 Environment.libdir env 64 65 else 65 66 Config.standard_library in 67 + let libdir = 68 + if config.has_relative_libdir = None then 69 + libdir 70 + else 71 + (* Unix.realpath raises Invalid_argument if it's not available *) 72 + try Unix.realpath libdir 73 + with Invalid_argument _ -> libdir in 66 74 let (/) = Filename.concat in 67 75 let data = [ 68 76 (* Root directory (both forms) preserved *) ··· 326 334 let runtime = 327 335 mode = Bytecode && Harness.ocamlc_fails_after_rename config in 328 336 (* In the Renamed phase, Config.standard_library will still point to the 329 - Original location *) 330 - let stdlib = true in 337 + Original location, unless the compiler has been configured with a 338 + relative libdir *) 339 + let stdlib = (config.has_relative_libdir = None) in 331 340 let (_, output) = 332 341 Environment.run_process ~runtime ~stdlib env compiler args in 333 342 Environment.display_output output; ··· 342 351 in 343 352 (* In the Renamed phase, the test driver will need to be launched with 344 353 ocamlrun, unless executables produced by the compiler are capable of 345 - searching for the runtime (as the Windows executable launcher does) *) 354 + searching for the runtime (as the Windows executable launcher does) or 355 + the compiler has been configured with a relative libdir (as in this mode 356 + the bytecode header will have the correct location) *) 346 357 let runtime = 347 358 mode = Bytecode 348 - && not config.target_launcher_searches_for_ocamlrun in 359 + && not config.target_launcher_searches_for_ocamlrun 360 + && config.has_relative_libdir = None in 349 361 let run run_process test = 350 362 let code, lines = 351 363 run_process ~runtime test_program []