-
Notifications
You must be signed in to change notification settings - Fork 31
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
Support OCaml 5.3.0 #148
Conversation
90c8245
to
a2f9614
Compare
I updated this PR with the latest, merged, version of an upstream PR. In particular, it means that |
@@ -0,0 +1,196 @@ | |||
From ddf39e7e09d03f5e83c92b6bb1bc094e8f116a66 Mon Sep 17 00:00:00 2001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very quick review, is this patch really necessary? In particular, it changes the CRCs of the stdlib, which makes it impossible for a third-party library (compiled with the host compiler) to be linked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this patch to avoid the boostrap and retested a simple unikernel and it seems to me that this patch is not strictly necessary to ensure that the runtime can work with Solo5. Furthermore, the CRCs of the stdlib without this patch are the same as those of the host compiler, which makes it possible to link third-party libraries compiled with the host compiler with the stdlib of ocaml-solo5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good example of why I based this PR on top of #147: without that patch, the config
example is broken, as it reports
OS: None
Unix: true
(https://github.com/shym/ocaml-solo5/actions/runs/13496596181/job/37705178517#step:7:57).
On the other hand, maybe that’s a breakage we’d rather ignore for now (as it is broken on builds for OCaml 4, IIUC, so probably not expected to be correct in Mirage unikernels).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, maybe that’s a breakage we’d rather ignore for now (as it is broken on builds for OCaml 4, IIUC, so probably not expected to be correct in Mirage unikernels).
It depends on the objectives we have, but I think a conservative approach to OCaml's stdlib would be best. In addition, I think ocaml-solo5 should focus primarily on libasmrun.a
(and not stdlib.cmxa
).
As for Mirage, a differentiation (whether it is ocaml-solo5 or ocaml) via Sys.something
is not used in the Mirage ecosystem. The only (important) differentiation is found mainly in the C stubs and during compilation (and it is currently managed by dune
) because it is really in these C files that ocaml-solo5 produces different object files.
More generally, we know when we want to obtain a unikernel in advance — specifically before building it. Having the possibility of knowing dynamically whether or not we are in a unikernel can open the door to a whole host of possibilities that we might regret.
Dear all, thank you @shym for your work on that update :)
I don't know what I did wrong, I currently have pins on:
The issue seems to be mirage-xen compilation related and I'm not familiar with ocamlfind to check what is expected of my code :) |
@palainp: thank you for testing that PR! I don’t really know why the problem was hiding on my machine. Anyway, I’ve reverted that change and added a small test in CI to make sure that |
Before we merge and release this, we need a release of solo5 with Solo5/solo5#590 included. |
Hmmhmm, I currently have this error on my machine:
I can not understand it now but I will try to figure out where is the error (note that I was able to delete the boostrap patch on myself and compile |
I looked at this error for a while and it seems to be related to my installation of OCaml by Archlinux. It seems that the version for Archlinux has been “slightly” modified. The checksum of stdlib.cmi is therefore different from the one produced by ocaml-solo5, hence the above error. So I uninstalled OCaml (via pacman) and reinstalled OPAM as well as a new switch OCaml 5.3.0 whose sources are indeed the same as the one used by ocaml-solo5 and I no longer get the error. Not sure if it's related to this PR but the error is still strange. Despite this point, I agree with this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this PR, however I've tested only on linux, so it's important to wait for Solo5/solo5#590 to be merged and solo5 released for CI to be happy with freeBSD.
Should we also wait for ocaml/ocamlfind#99 to be merged and released (and threads
removed again)?
I would not say so, we can keep using the same workaround we’ve been using for a long time, and drop it if/when upstream is fixed. |
This is really weird.
|
Thank you all for your comments. As the error is gone at @dinosaure , and it seems the only ci blocker is removed in current HEAD, rebasing should be enough? |
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 (merged upstream) (7 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` This makes it possible to find the OCaml-provided libraries, such as `compiler-libs`
I rebased it, but it is still waiting for a release of Solo5 to support FreeBSD, so that the TMP commit can be dropped. |
Now solo5 0.9.1 is released and merged in opam-repository, I think I can drop the last commit to trigger a CI test, is that ok for you @shym ? |
Do you understand the CI error on FreeBSD? Is the solo5.0.9.1 package too fresh to have been visible during that run, maybe? |
to me it looks like there's still somwtiing pinning solo5 to your branch. maybe the caching is bad?
|
I agree the issue is likely due to the pin still present, I tried to trigger CI again, but I can see the pin is still present :( |
My proposal: remove the cache stuff in .cirrus.yml. I don't know much about that caching (not sure who proposed it) -- but better have a correct CI than one with a bad caching ;) -- alternatively debug the caching... |
a3c787f
to
15b119a
Compare
So I made things worse by playing with the cache :( I'm going to look for and read some docs :) |
It seems to be not related with me fiddling with cache (ocaml/setup-ocaml#943). So I'll re-remove the cache part later when that issue will be solved. |
\o/ CI takes longer but is green now :) |
It seems that the Archlinux version compile with |
Oh sorry, I merged to fast, I thought it was OK. Do you want to fix that in a new PR and merge before a release? |
It's ok but I think it arises the question of the reproducibility expected by |
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 mainMakefile
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):
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 tonolibc
asecure_getenv
returning"d=1"
for theOCAMLRUNPARAM
value. But that value is then parsed by OCaml usingsscanf
, which is not provided innolibc
. I settled to keep that simple patch, at least for now, rather than come up with asscanf
(do we want to provide a hard-coded version that would work only for that single use case or a real implementation?).Commit overview
crossopt
andinstallcross
rulesqsort
andlongjmp
solo5.conf
to support OCaml-provided librariespath
Makefile
)