Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocaml cross-compilation and bootable image
[ 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: ocaml cross-compilation and bootable image
> I'm running ocamlopt on an Alpha (Linux) but need to generate i386
> binary executables.
> Has anyone done this?  Any hints on how to do it?

I never tried to set up a full cross-compiler, but it should not be
hard.  You need to run the configure script, then edit the generated
file config/Makefile and change the following variables:

ARCH=<your target architecture, e.g. i386>
SYSTEM=<your target OS (for choosing calling conventions, etc), e.g. linux_elf>
NATIVECC=<your cross C compiler, e.g. myarch-gcc>
NATIVECCCOMPOPTS=<whatever options you need at compile-time>
NATIVECCLINKOPTS=<whatever options you need at link-time>
ASPP=<your cross assembler with preprocessing, e.g. myarch-gcc>
ASPPFLAGS=-c -DSYS_$(SYSTEM) <extra options if needed>

Finally, the name of the assembler called to assemble the output of
ocamlopt is (unfortunately) hard-wired in asmcomp/<arch>/,
function assemble_file, so you may need to change that file.
Or just play with $PATH until "as" refers to your cross-assembler.

There's also a hard-wired call to "ar" in utils/ that may need
to be changed.

Good luck,

- Xavier Leroy