[opam-devel] [MirageOS-devel] Cross-compiling OCaml, Mirage OS for rumprun, OPAM integration

Martin Lucina martin at lucina.net
Tue May 19 15:12:51 BST 2015

Hi Thomas,

On Tuesday, 19.05.2015 at 12:49, Thomas Gazagnaire wrote:
> Lwt's discover.ml is unfortunately known to be very ad hoc and often breaks so I am not very surprised. Usually patches to fix it sent upstream are kindly accepted (until someone be brave enough to completely rewrite that file). In the meantime, maybe passing `-use-pthread false` to discover.ml using `./configure --disable-pthread` could help.

I can't disable pthread since that would leave it with no threading engine
at all. As I wrote in my reply to Peter, I'll try and hack around the
problem, or just abuse --enable-android-target for now.

> > This is expected; the rumprun toolchain does not support dynamic linking
> > and I have configured the ocaml-rumprun compiler with -no-shared-libs. Is
> > there some way to tell OASIS to not expect any shared libraries to be
> > built?
> This is tricky, it requires a mix of ocamlbuild, oasis and oasis hackery. I found http://komar.bitcheese.net/en/howto_link_c_lib_statically_with_ocaml_app which might help.

The problem is not telling the OCaml compiler not to build shared
libraries, the cross compiler already knows not to do that. It's telling
OASIS about the fact that the OCaml compiler it's using will not build
shared libraries.

> Where did you see these options? I've seen commits in OCaml trunk to have
> a better support for cross compilation, not totally sure what it the
> status of it though. Also, Andy Ray (in /cc) also started a similar
> effort to cross-compile ocaml to FPGA. I really hope all of this would
> converge, and that we can add the proper support for it in opam at one
> pont.

They are mentioned in the INSTALL file as early as OCaml 4.02.01, however
as Peter confirmed they don't actually work without extra patches. What
I've done is run OCaml configure on a NetBSD box and then hand-edited the
result, and patched the 4.02.01 compiler with Peter's cross-compiling patch

In theory PR#6266 (https://github.com/ocaml/ocaml/commit/c1e26ad14aec62cefe3d5fb24cf8702caa39db2b) might fix these options to let me run OCaml configure directly against the rumprun cross compiler but I've not tried yet.

> Sorry to not be able to help much, but I think the topic is quite important one but very hard as it will need to be address problems in in the whole toolchain: ocaml, ocamlfind, ocamlbuild, oasis, opam, ... 

No problem, thanks for your input. I'm sure with enough persistence we'll
get there.


More information about the opam-devel mailing list