-
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
Some tweaks to be able to use ocaml-solo5 with miou #144
Conversation
We discussed this PR at the MirageOS bi-weekly meeting. The first commit is really fine, please open a separate PR and we can merge that immediately. The second commit, we like the idea very much. But we are unsure. Especially about safety: how can we assure that C stubs compiled for the host system are not linked into the unikernel? How does this work in respect to cross-compilation? Focusing on the first question, we could look into installed META files whether they link archives, or have a flag in opam files when they don't include C stubs (rather hard, since that'd need to be done across the opam-repository). |
If we stay within the environment of the From a strictly Mirage user point of view, this shouldn't change anything. However, if you want to compile a unikernel outside the framework offered by the From my point of view, being able to compile a unikernel using the libraries available in OPAM is a case that remains, in view of the design decisions that have been made since MirageOS 4, at the margin. It's also a case that's under-documented (if at all). The risk of linking archives that have been compiled with the host toolchain is therefore essentially for expert use. |
That sounds good. Thanks for your explanation. I'd suggest to test (or someone with ocamlfind/dune expertise jumps in) that this is really the case, and if the answer is yes - let's merge and release! :) |
To elaborate a bit on the question of safety, even if I now understand that this is meant to be “Cool if that works for simple cases”:
|
Extra note for the context I have in mind: I’ve heard vaguely about some preliminary work to teach the OCaml compiler to detect incompatibilities between .cmxa when they were built with inconsistent ( |
This type of package, in this case, could not be used because It is obvious that libraries such as However, if we consider what is specific and what is available, it is clear that, prior to this patch, we are forbidding ourselves from using the vast majority of libraries because some of them (and they can be counted on the fingers of one hand) require to be fully compiled with the Solo5 toolchain. We also have to admit that these issues are more related to the question of cross-compiling with OCaml than with the ecosystem as it is evolving. It's also an issue that's broader than MirageOS (we can take the example of Melange which, as far as What is certain is that compiling libraries such as
In this case, I just specified, when compiling
Sorry, but I'm not aware of any such proposal, but if it's in the pipeline, it could indeed be interesting. |
I found the following discussion: ocaml/ocaml#13423 (comment) -- and I think for us this is not really relevant, since we build the compiler with the same configure options as the one in the switch (that's why we depend on ocaml-option-no-flat-float-array etc.). So, my assumption is that the OCaml compilation results in the exact same artifact using ocaml-solo5's compiler or the switch compiler. There may be differences for e.g. fmt and other buenzli libraries -- since with the current mirage approach using duniverse/ocaml-monorepo, we use some overlays https://github.com/dune-universe/opam-overlays/ that have (a) eventually a different version than the main opam repository packages and (b) arbitrary patches influencing the build system (e.g. "use dune" -- where using dune may have an effect on which compilation flags are used, and thus the OCaml compiler may behave differently). TL;DR: I appreciate the possibility to use the switch-installed opam packages, and at the same time understand safety concerns (link C code compiled for host instead of unikernel). As far as I understand, within this repository we can't fully solve the safety issues. We have to rely on users of this repository to avoid that (as it is done nowadays using mirage & opam-monorepo). Any other tooling on top of ocaml-solo5 will need to take these safety considerations as well. |
@shym (or anyone else): I'll merge and cut a release unless you've concerns. |
No longer from me, thanks! |
The first commit is just about a
STUB_IGNORE
. Miou allocates aStdlib.Condition.t
but it does not use it (it does not usepthread_cond_wait
). However, OCaml try to delete the value (because it is unused) withpthread_cond_destroy
.The second commit is probably more controversial and difficult to explain if we take into account the history of how to build an unikernel with
dune
but my experiments show that it's probably the best to actually be able to compile a really simple unikernel withoutopam monorepo
. We must ensure that this commit does not breakmirage-skeleton
but it should not. A nice try will be thecrypto
unikernel to see if we bring correctly the archive ofmirage-crypto
compiled by dune (and not the archive available via opam).