Compiling for a different OS?

Hi all,

I’ve been playing around with porting OCaml to a new platform and have been running into some trouble while trying to compile the runtime. It seems like right now the process works something like this:

  1. build runtime/ocamlrun for host system on build system
  2. use runtime/ocamlrun on build system to bootstrap stdlib

However, this means that if the host system and build system are different platforms, the 2nd step will fail, as the runtime/ocamlrun binary will target the wrong platform:

make[1]: Entering directory '/home/ohadrau/projects/serenity/Ports/ocaml/ocaml-4.13.1/stdlib'
../runtime/ocamlrun ../boot/ocamlc -use-prims ../runtime/primitives -strict-sequence -absname -w +a-4-9-41-42-44-45-48-70 -g -warn-error +A -bin-annot -nostdlib -principal -safe-string -strict-formats  -nopervasives -c camlinternalFormatBasics.mli
make[1]: ../runtime/ocamlrun: Command not found
make[1]: *** [Makefile:216: camlinternalFormatBasics.cmi] Error 127
make[1]: Leaving directory '/home/ohadrau/projects/serenity/Ports/ocaml/ocaml-4.13.1/stdlib

Is this pretty much the expected behavior? Or has anyone managed to build the system for a different platform? I haven’t been able to find much discussion about cross-compiling the compiler (everything that comes up seems to be related to building a cross-compiler, which it seems could probably be skipped by only building the stdlib within the host system), but apologies if this has already been answered elsewhere

Thanks,
Ohad

1 Like

I use this patch on 4.12, the problem is that when cross compiling some rules are not prepared.

I would also recommend to look on other files in this folder.

2 Likes

Thanks Eduardo! This is awesome, exactly what I was looking for :slight_smile: