-
Notifications
You must be signed in to change notification settings - Fork 263
Use Dune instead of OCamlbuild to build unikernels #969
Copy link
Copy link
Closed
Description
I used several unikernel samples to explore what are the problems blocking the Dune transition. I've taken them from mirage-skeleton. After identifying problems and workarounds, I managed to build entirely with Dune + ld/pkg-config the following unikernels with unix, xen and hvt target: DNS, http_fetch, echo_server. I'm aware this does not cover everything but it's a good start.
Used features of OCamlbuild that aren't implemented in Dune:
-dontlink <pkg>used forunix,threads,strandnum. This removes these packages from the final linking step, thus allowing to link on non-Unix targets.- Predicates is sometimes used for library selection.
- Use of
-output-objin conjunction with..._linkoptsin META files to link C stubs and custom OCaml runtime.
Workaround to each problem
- Explore the dependency graph to figure out which packages have unneeded dependencies and update them accordingly. Use OCaml 4.07 and Stdlib.Bigarray in order not to depend on the legacy
bigarraywhich includes undefined stubs on xen/freestanding. - Use virtual libraries and implementations. To not break everything, it's possible to keep the library name
packageas the default implementation and make it depend on the virtual librarypackage-virtual. This way the update is transparent for users of the package and the ones that want to use the virtual library feature just have to change theirpackagedependency into apackage-virtualdependency. - Dune uses
-output-complete-objto build object files. This also links C stubs and runtime. Therefore we don't have to care about C stubs anywore as they are automatically linked along with used libraries. No need for..._linkoptsflags in META. For the custom runtime,ocamlopthas a-runtime-variantoption to choose a custom runtime library to link.
Packages to update
- ocplib-endian, mirage-fs-lwt, mirage-console-lwt, xen-evtchn, sexplib, tcpip, asn1-combinators, mirage-entropy
- mirage-entropy, zarith + dependencies (asn1-combinators, nocrypto)
- mirage-xen-ocaml, ocaml-freestanding: just need to add a symlink from
lib...asmrun.ato ocaml runtime directory so that ocaml finds the runtime variants. I've already modified these packages locally to make my experiments so it's not that hard to make these changes.
Issues and comments
- Duniverse forks may have already fixed some of these packages.
- The uses of virtual libraries disable cross-module optimisation such as inlining. We have to be careful with that.
How do you feel about this ? How should we proceed to update packages ? Am I missing something ? Feel free to comment !
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels