inhabitedtype / bigstringaf

Bigstring intrinsics and fast blits based on memcpy/memmove
Other
37 stars 15 forks source link

Compatibility with mirage+dune #37

Closed dinosaure closed 5 years ago

dinosaure commented 5 years ago

/cc @TheLortex

A long time ago, we asked to put two sub-packages:

See #12, #13, #21 and #22.

It's an old trick to give to C stubs right flags to be linked then with the final unikernel with ocamlbuild and ocamlfind. @TheLortex did a huge work on Mirage to be able to compile an unikernel with dune. You can see a precise report here.

The goal of this PR is to move furthermore about compatibility of some packages and what mirage will be.

By the :standard expansion in the dune file, mirage is able to give to bigstringaf right flags to compile C stubs (in this case bigstringaf_stubs). By this way, bigstringaf.freestanding and bigstringaf.xen is not needed anymore - this PR does not delete them to keep a compatibility.

Another point, and it's the real purpose of this PR, is to replace Bigarray module by Stdlib.Bigarray (only available on ocaml.4.7.0 and upper) or Bigarray_compat (a package available here where the Bigarray module at top differs. Bigarray_compat wants to provide only what is needed by bigstringaf without map_file function for any version of OCaml.

To prepare then, the big move of Mirage to the dune build-system, this PR is required - currently compilation was tested locally. If you are interested by the process, I can explain it.

EDIT: GitHub was not happy about my last PR and did not integrate my last commit.

seliopou commented 5 years ago

This PR doesn't actually add the :standard token to the c_flags stanza. Isn't that necessary to make the xen and freestanding packages unnecessary?

dinosaure commented 5 years ago

Ah yes, I missed it. It's done.

seliopou commented 5 years ago

The :standard flags should be included for sure, so I put that change into a separate PR and will merge/release shortly.

I don't understand the purpose of the bigarray compatibility library. Presumably mirage will still work with OCaml versions before 4.07 that link in the Bigarray module, so what would stop Ocaml version after 4.07 that link in the Bigarray module from working as well?

TheLortex commented 5 years ago

We're currently switching the build system of mirage, from ocamlbuild to dune. The problem with the bigarray library is that it has a dependency on unix. This is problematic because we don't want to implement unix in the mirage case. ocamlbuild solved that problem by having a -dontlink unix option which just ignores the package dependency at link time. Dune don't allow that so we're currently chasing down unwanted unix dependencies.

After 4.07, using Stdlib.Bigarray instead of Bigarray allows to get rid of the unix dependency. That's why I created bigarray-compat: which is Stdlib.Bigarray when possible with a fallback to Bigarray. It allows:

seliopou commented 5 years ago

Sorry, I forgot about this. I'll do a release shortly.

-Spiros E.