MirageOS 4.0 Beta Release

On behalf of the Mirage team, I am delighted to announce the beta release of MirageOS 4.0!

MirageOS is a library operating system that constructs unikernels for secure, high-performance network applications across a variety of hypervisor and embedded platforms. For example, OCaml code can be developed on a standard OS, such as Linux or macOS, and then compiled into a fully standalone, specialised unikernel that runs under a Xen or KVM hypervisor. The MirageOS project also supplies several protocol and storage implementations written in pure OCaml, ranging from TCP/IP to TLS to a full Git-like storage stack.

The beta of the MirageOS 4.00 release contains:

  • mirage.4.0.0~beta: the CLI tool;
  • ocaml-freestanding.0.7.0: a libc-free OCaml runtime;
  • and solo5.0.7.0: a cross-compiler for OCaml.

They are all available in opam by using:

opam install 'mirage>=4.0'

Note: you need to explicitly add the mirage>=4.0 version here, otherwise opam will select the latest 3.* stable release. For a good experience, check that at least version 4.0.0~beta3 is installed.

New Features

This new release of MirageOS adds systematic support for cross-compilation to all supported unikernel targets. This means that libraries that use C stubs (like Base, for example) can now seamlessly have those stubs cross-compiled to the desired target. Previous releases of MirageOS required specific support to accomplish this by adding the stubs to a central package.

MirageOS implements cross-compilation using Dune Workspaces, which can take a whole collection of OCaml code (including all transitive dependencies) and compile it with a given set of C and OCaml compiler flags. This workflow also unlocks support for familiar IDE tools (such as ocaml-lsp-server and Merlin) while developing unikernels in OCaml. It makes day-to-day coding much faster because builds are decoupled from configuration and package updates. This means that live-builds, such as Dune’s watch mode, now work fine even for exotic build targets!

A complete list of features can be found on the MirageOS 4 release page.

Cross-Compilation and Dune Overlays

This release introduces a significant change in the way MirageOS projects are compiled based on Dune Workspaces. This required implementing a new developer experience for Opam users in order to simplify cross-compilation of large OCaml projects.

That new tool, called opam-monorepo (née duniverse), separates package management from building the resulting source code. It is an Opam plugin that:

  • creates a lock file for the project dependencies
  • downloads and extracts the dependency sources locally
  • sets up a Dune Workspace so that dune build builds everything in one go.


opam-monorepo is already available in Opam and can be used on many projects which use dune as a build system. However, as we don’t expect the complete set of OCaml dependencies to use dune, we MirageOS maintainers are committed to maintaining patches to build the most common dependencies with dune. These packages are hosted in a separate dune-universe/mirage-opam-overlays repository, which can be used by opam-monorepo and is enabled by default when using the Mirage CLI tool.

Next Steps

Your feedback on this beta release is very much appreciated. You can follow the tutorials on Mirage 4 | MirageOS. Issues are very welcome on Issues · mirage/mirage · GitHub, or come find us on Matrix in the MirageOS channel: #mirageos:matrix.org.

The final release will happen in about a month. This release will incorporate your early feedback. It will also ensure the existing MirageOS ecosystem is compatible with MirageOS 4 by reducing the overlay packages to the bare minimum. We also plan to write more on opam-monorepo and all the new things MirageOS 4.0 will bring.


Thanks for https://github.com/mirage/opam-overlays! I’ve been using it for cross-compilation using Dune workspaces as well; exactly what is needed to simplify cross-compiling. (The significant difference is I’m using Opam pre-build-commands to inject a Dune workspace into each Opam package, rather than a single Dune workspace ala opam-monorepo. Regardless, the key thing was to let Dune deal with the cross-compiling, which is why your opam-overlays repository is very appreciated!)

Do you think some of these overlay patches will be upstreamed? I realize some package maintainers prefer non-Dune build systems, but I suspect others will accept the Dune-ification of their projects.

1 Like

Glad to hear that you found this helpful! The overlay repository that you are pointing out is now part (and maintained) of the complete opam-monorepo overlay: GitHub - dune-universe/opam-overlays: An opam remote with the various Dune modified repositories in this org. We would be delighted to get those patches upstreamed when they get ready; some still need a few changes, such as embedding the right version field in the dune-project files. Another route is to work with upstream to generate the dune file during the release process (to make sure they stay in sync with what is released). Meanwhile, we are committed to maintaining these patches.

The other mirage-specific patches are stored on GitHub - dune-universe/mirage-opam-overlays: An opam-repository with patches to upstream packages for cross-compilation with opam-monorepo and fix x-compilation issues. So far, it’s only zarith as we want to link it with a custom gmp object file, properly cross-compiled. However, we suspect “normal” users would instead link with their system gmp, so it’s unclear if this will ever get upstreamed.

In both cases, once we are happy with the quality of these overlays, we want to discuss with upstream to find the right way to reduce the need for these overlays.