Skip to content

[GOB] Relocatable OCaml 5.4#297

Open
dra27 wants to merge 19 commits into
test-in-prefix-5.4from
relocatable-ocaml-5.4
Open

[GOB] Relocatable OCaml 5.4#297
dra27 wants to merge 19 commits into
test-in-prefix-5.4from
relocatable-ocaml-5.4

Conversation

@dra27

@dra27 dra27 commented Jun 13, 2026

Copy link
Copy Markdown
Owner

No description provided.

nojb and others added 8 commits March 31, 2026 21:23
Unify the two executable header implementations

(cherry picked from commit 076b435)
Relocatable OCaml - explicit-relative paths in `ld.conf`

(cherry picked from commit 1e05f34)
Relocatable OCaml - `--with-relative-libdir`

(cherry picked from commit cfbf210)
(cherry picked from commit d315509)
(cherry picked from commit 1ecddf1)
boot/ocamlc doesn't yet support -set-runtime-default and
%standard_library_default.
Misc.String.to_utf_8_seq was added in PR#14014 for the testsuite, but
isn't part of the backport. It's only needed in Bytelink, so share it
from there instead.
Relocatable OCaml - Searching and Suffixing

(cherry picked from commit da60a2e)
(cherry picked from commit c40b687)
boot/ocamlc still uses the old runtime-launch-info format and doesn't
yet support -launch-method or -runtime-search.
Config.shebangscripts was added in PR#14014 for the testuiste, but isn't
part of the backport. Similarly, Bytelink.read_runtime_launch_info was
exposed, only to be deleted as part of PR#14245, so the backport cuts
out this intermediate step by temporarily copying
Bytelink.read_rutime_launch_info, which therefore needs deleting here.
@dra27 dra27 added CI: Skip testsuite Skip the testsuite runs on a PR run-crosscompiler-tests CI: Full matrix Full CI test matrix labels Jun 13, 2026
- Byterntm removed from ocamlbytecomp and linked directly in
  ocamlobjinfo (the test-in-prefix driver likewise links it directly)
- Cmm_helpers.emit_global_string_constant inlined into its single use in
  Asmlink.make_startup_file
- Compenv.parse_runtime_parameter inlined into its single use in
  Main_args and Compenv.fatalf consequently removed
- Config.as_is_cc moved to Toolchain.as_is_cc
- Config.target_{unix,win32,cygwin} removed and uses of
  Config.target_win32 inlined
@dra27 dra27 force-pushed the relocatable-ocaml-5.4 branch 2 times, most recently from f374e30 to aeb2d60 Compare June 18, 2026 17:10
dra27 and others added 10 commits June 18, 2026 18:39
Virtually elimates changes to the runtime headers:
- caml_parse_ld_conf (protected by CAML_INTERNALS) changes arguments,
  but this function was already checked for not being used outside the
  runtime as part of OCaml 5.5
- exec.h now includes <stdint.h> (protected by CAML_INTERNALS)
- version.h now defines OCAML_RELEASE_NUMBER
In OCaml 5.5, the suffixing mode is enabled by default. For
compatibility, the backports only enable this mode by default if
--enable-runtime-search and/or --enable-runtime-search-target is
specified (the usual validation rules for these flags still applies -
i.e. --disable-suffixing is still prohibited if either
--enable-runtime-search or --enable-runtime-search-target is specified)
Cmo_format.library.lib_dllibs is able to change type without a bootstrap
because the bootstrap cycle never reads a .cma which has any entries for
dllibs (it fundamentally can't, because that would imply a dependency on
dynamic loading, which isn't permitted in ultra-portable bootstrap)

However, the format absolutely cannot change without ultimately changing
the cma magic number, which is non-trivial, because we don't normally
change the magic numbers in maintenance releases, and the numbering
scheme consequently doesn't reserve space for them.

This is worked around instead by leaving Cmo_format.library unaltered
and instead writing a _second_ list after the Cmo_format.library in the
cma format. This list is guarded with the cma magic number, but written
in reverse. If this magic number is present, then the list must follow
and must be the same length as lib_dllibs. If the magic number is not
present, then the suffixed member of each lib_dllibs is assumed to be
false, which is used also used as an "optimisation" to avoid writing the
extra list at all when none of entries have suffixed:true.
As with Cmo_format.library, the type of Cmx_format.unit_infos cannot
change without changing the cmx and cmxa magic numbers, which is
similarly awkward.

The workaround here is slightly simpler, if also somewhat more devious.
Cmx_format.unit_infos is handily a fully mutable record, meaning that
there are few if any optimisation assumptions which will ever be made
around it.

For the compiler, the interface is altered to add
Compilenv.needs_stdlib_location which takes a Cmx_format.unit_infos and
"accesses" its ui_need_stdlib field. In parallel,
Compilenv.write_unit_info gains an optional ui_need_stdlib argument
which allows the field to be specified when a Cmx_format.unit_infos is
written to a file.

The devious part is that instead of writing a Cmx_format.unit_infos
value, Compilenv.write_unit_info writes a tuple with one extra element
for the ui_need_stdlib field to be added in.
Compilenv.needs_stdlib_location looks to see if the
Cmx_format.unit_infos it has been passed in fact contains an extra field
in the block and, if it does, reads it.
Relocatable OCaml - to opam and beyond

(cherry picked from commit f6c8af4)
Improve installation time in opam by shrinking the Git-generated source archives

(cherry picked from commit 172b5c5)
@dra27 dra27 force-pushed the relocatable-ocaml-5.4 branch 6 times, most recently from ea0e710 to 47650b0 Compare June 19, 2026 08:33
@dra27 dra27 force-pushed the relocatable-ocaml-5.4 branch 2 times, most recently from 6a05d55 to be815cc Compare June 19, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: Full matrix Full CI test matrix CI: Skip testsuite Skip the testsuite runs on a PR run-crosscompiler-tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants