Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Building a cross-compiling ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: Building a cross-compiling ocaml
> I am trying to get ocaml to produce code that can be linked against
> the libc of a different operating system (the University of Utah's
> OSKit project, for those who may know it).  The key facts are:
>   - The target architecture is the same, so all the normal build tools
>     and commands work; I just need to add some compile-time and
>     link-time options so gcc will use the proper header files and
>     libraries.
>   - I'm using a different libc than the native (Linux) one, so the
>     ocamlrun produced in this manner cannot be run locally.  In other
>     words, the normal build process gives me a broken ocamlc.

Right.  You need a native ocamlrun to run ocamlc, not the
cross-compiled ocamlrun.

The easiest solution is as follows:
- leave the sources in byterun/ unchanged, so that the normal build
  procedure of ocaml will work;
- make a copy of byterun/ in, say, byterun.cross;
- modify the sources and Makefile in byterun.cross so that they can be
  cross-compiled and produce an ocamlrun for your target OS;
- use byterun.cross/ocamlrun to run OCaml bytecode executables
  on the target OS.

> My understanding is that bytecode files are entirely
> system-independent

They are almost entirely system-independent.  For instance, if the
target system has different ASCII codes for '\n' and '\r' than the
native system, text I/O will look funny.  (This is the case if you
cross-compile between MacOS on the one side, and Unix or Windows on
the other side.)  This is the only system dependence that I can
remember right now.

- Xavier Leroy