I need to build an OCaml cross-compiler. Sadly, it seems this is not supported out of the box and needs a little work, as described for an older version of the OCaml compiler.
My first question is: What is a nice way to generate the files config/m.h, config/s.h and config/Makefile?
I need to build an OCaml cross-compiler. Sadly, it seems this is not supported
Share
With a modified configure “chain” it is possible to generate the files.
Ocamls configure script assumes that it can compile and execute the results on the same run, which can be impossible in a cross compile environment.
Hence the configure procedure must be modified such that the results of the compilations (including the executables) are stored and can be used in a second run on the target machine. Here is the diff file showing the modification (~200 lines).
The configure script gets a new
-crossoption. Whenccis its argument, it only compiles, when it isrun, it only executes the compiled stuff. Intermediate results are stored in config/auto-aux/map_{hasgot,runtest}, mostly usingsetValueandgetValueExitfor retrieval, both defined in config/auto-aux/keyval.sh. If one supplies the cross toolchain data with-cc,-as,-aspp,-partialld,-libs,-dllibs,-dldefsthe Makefile should be usable. Finally the file
keyval.shwhose content is not in the diff:If
tkis used, one must modify config/auto-aux/runtest and replace0.0with its version number. Further, it may be necessary to modify the file config/auto-aux/solaris-ld if solaris is used as target or host machine.