Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

Install runtime headers for mirage-xen. #102

Merged
merged 1 commit into from Oct 12, 2014
Merged

Install runtime headers for mirage-xen. #102

merged 1 commit into from Oct 12, 2014

Conversation

jamesjb
Copy link
Contributor

@jamesjb jamesjb commented Sep 12, 2014

Now that Mirage contains only a very minimal libc, I'd like to suggest we install the headers for those libc functions and the OCaml runtime somewhere where C stubs can find it.

C code is going to be linked against the functions regardless---given that, it seems prudent to allow them to have access to their headers as well. Otherwise, libraries will need to include their own libc definitions which may be incompatible or clash with those defined by the Mirage runtime.

This patch installs runtime headers into $(OPAM_PREFIX)/include/mirage-xen, alongside the minios headers. With this change, I've successfully built an add-on module to mirage that exposes additional hypercalls via OCaml.

- Provides C code with headers that match the minimal libc
  and OCaml functions they will be linked against.
@samoht
Copy link
Member

samoht commented Sep 12, 2014

With this change, I've successfully built an add-on module to mirage that exposes additional hypercalls via OCaml.

Do you have an example code doing that somewhere?

@jamesjb
Copy link
Contributor Author

jamesjb commented Sep 12, 2014

The XSM bindings are in this repository (still very much a work in progress):

https://github.com/GaloisInc/mirage-flask-xen

@avsm
Copy link
Member

avsm commented Sep 13, 2014

We should definitely do this; however, shouldn't the headers be installed from https://github.com/mirage/mirage-xen-minios instead?

For instance, the hardcoding of machine/math.h pointing to x86/math.h in this repo makes me suspicious that the headers are slightly out of sync already, if they are being used. We also need to get this working for the installation of gmp for nocrypto, so holding this open while I reinstall my Cubieboard to check out what's happening with the ARM headers.

@hannesm
Copy link
Member

hannesm commented Sep 13, 2014

now that I'm back in berlin, expect my changes/way to get gmp, nocrypto, tls to work on my cubieboard later today!

@avsm
Copy link
Member

avsm commented Sep 13, 2014

great! dont forget to opam remote add mirage-dev git://github.com/mirage/mirage-dev to grab the latest sources

@jamesjb
Copy link
Contributor Author

jamesjb commented Sep 15, 2014

We should definitely do this; however, shouldn't the headers be installed from https://github.com/mirage/mirage-xen-minios instead?

Those are installed as well. It turns out (at least in my case where I'm writing C stubs that call Xen hypercalls) that you need both sets of headers. My experience using only the minios headers was that I couldn't compile the OCaml headers due to missing includes (like string.h).

Also, without installing mirage-xen's headers, aren't we getting the OCaml headers from the host compiler rather than the target?

@avsm
Copy link
Member

avsm commented Sep 15, 2014

Yeah, these the mirage-xen headers are extracted from the original merged minios headers. So we do need to have a minimal set to provide the bridge between minios and libc (for instance, we grab printf from musl-libc, and could do a similar job for string.h). There's no issue with target/host, since OCaml doesn't do cross-compilation :) Luckily, the code ocamlopt produces is quite independent since all C symbols are resolved at link time and are explicitly specified in the external call.

@avsm
Copy link
Member

avsm commented Sep 15, 2014

@talex5 is on vacation for a couple of weeks btw, so if this one isn't too urgent it would be good to wait for him to come back to comment on the thread too, so we can make sure this one's done properly.

@talex5
Copy link
Contributor

talex5 commented Oct 1, 2014

Seems reasonable to me (except it looks like it installs the whole of runtime/ocaml, rather than just the headers).

@avsm avsm merged commit 6a76a14 into mirage:master Oct 12, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants