Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support OCaml 5.3.0 #148

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Support OCaml 5.3.0 #148

wants to merge 12 commits into from

Conversation

shym
Copy link
Contributor

@shym shym commented Jan 23, 2025

This PR replaces the supported OCaml version with 5.3.0. This PR sits at the moment on top of #147 in order to illustrate with the new examples at least some of new possibilities of that version.

Most of the patches that are required for the compiler have been accepted upstream (so to be part of 5.4) and are therefore backported here. As the patches that we have in main for 5.2.1 are slightly incompatible (they were drafts for the patches that got upstreamed), they would need to be reworked for our main Makefile to support both versions. As 5.2.1 was still considered experimental, this PR proposes to simply support 5.3.0.

The main part of this PR then is the set of patches for 5.3.0. Those patches are extracted from upstream PRs (selecting the commits that are relevant for OCaml/Solo5):

  • PR 13526 (merged upstream) (10 commits)
  • PR 13674 (merged upstream) (1 commit)
  • PR 13719 (merged upstream) (1 commit)
  • PR 13735 (under review) (3 commits)
  • a not-opened-yet PR to support freestanding targets (2 commits)
  • a not-to-be-upstreamed commit to fix the maximum number of domains to 1

Note that since upstream PR 13272, the maximum number of domains can be set using a parameter in OCAMLRUNPARAM so I tried to replace that last patch by adding to nolibc a secure_getenv returning "d=1" for the OCAMLRUNPARAM value. But that value is then parsed by OCaml using sscanf, which is not provided in nolibc. I settled to keep that simple patch, at least for now, rather than come up with a sscanf (do we want to provide a hard-coded version that would work only for that single use case or a real implementation?).

Commit overview

  • Support for 5.3.0
    • ce2f35b Add patches for 5.3.0
    • 6cb5764 Use OCaml’s crossopt and installcross rules
    • 8ce33a1 Add stubs for qsort and longjmp
  • Fix our solo5.conf to support OCaml-provided libraries
    • 5a4b20e Add OCaml’s directory to the toolchain-configuration path
  • Update the version in opam files, CI, README
    • b1029dd opam: Update dependency to OCaml 5.3.0
    • 2a817b4 CI: Update OCaml version to 5.3.0
    • 9447497 README: Update the supported OCaml version to 5.3.0
  • Drop patches for 5.2.1 (broken by the commit updating our Makefile)

shym added 11 commits January 22, 2025 16:47
Rename the examples, so that there are no longer `main.xyz.ml`, just
`xyz.ml`
Extract the common C modules into a library so that all the tests can be
compiled (and executed) in one run of `dune`
Set up a `dune_gen` to avoid the boilerplate of all the options (in
particular since putting the manifest in a library requires an explicit
option to link it in)
Those patches are extracted from (only keeping what is relevant for
OCaml/Solo5):

- PR 13526 (merged upstream) (10 commits)
- PR 13674 (merged upstream) (1 commit)
- PR 13719 (merged upstream) (1 commit)
- PR 13735 (under review) (3 commits)
- a not-opened-yet PR to support freestanding targets (2 commits)
- plus a not-to-be-upstreamed commit to fix the maximum number of
  domains to 1
Since PR 13526, the OCaml compiler comes with specific rules to build
and install a cross compiler so rely on them rather than
`ocaml-solo5`-specific workarounds
Use opam’s ability to install both what is registered in a .install file
and run the `install` commands to combine OCaml’s install rule with a
`.install` file for other files (`nolibc` and `openlibm` libraries,
`ocamlfind` files and the toolchain)
Those functions are necessary only to compile the bytecode part of the
OCaml compiler so they won’t be called
Follow the `ocamlfind` configuration for the standard OCaml compiler by
adding the compiler’s directory at the beginning of the configuration
`path` variable, so that OCaml-provided `META` files can be found by
`ocamlfind`
Remove the, now useless, dummy file that was created to ensure `threads`
could be found

This makes it possible to find not only `threads` but also all the other
OCaml-provided libraries, such as `compiler-libs`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant