After finding a way to generate the fitting configuration files for the target machine, the cross compiler itself must still be built. The approach using the 1 1/2 build described here (and, with more details, here) does not seem to work if the host and target systems differ too much. Here is the changed part of the build script (which can be obtained with $ svn cat svn://svn.psellos.com/trunk/ocamlxarm/3.1/xarm-build
)
# Small steps
config1 () {
# Configure for building bytecode interpreter to run on Intel OS X.
# But specify * architecture for assembly and partial link.
echo 'xarm-build: ----- configure phase 1 -----'
./configure \
-prefix "" \
-no-curses \
-no-tk \
-no-graph \
-as "" \
-aspp ""\
-partialld ""
# Post-modify config/Makefile to select the * back end for
# ocamlopt (to generate * assembly code).
$SED -i'.bak'\
-e '1i\# modified by xarm-build for OCamlXARM' \
-e 's/^ARCH[ ]*=.*/ARCH=/' \
-e 's/^MODEL[ ]*=.*/MODEL=/' \
config/Makefile
#-e 's/^SYSTEM[ ]*=.*/SYSTEM=/' \
$SED -i'.bak'\
-e '1i\/* modified by xarm-build for OCamlXARM*/' \
-e 's/^#define[ ][ ]*HAS_STACK_OVERFLOW_DETECTION.*$//' \
config/s.h
# Post-modify utils/config.ml to tell ocamlopt to create *
# binaries for itself. Also tell ocamlc and ocamlopt to use *
# architecture when compiling C files.
make utils/config.ml
$SED -i'.bak'\
-e 's#let[ ][ ]*mkexe[ ]*=.*#let mkexe ="'"$CC"'"#' \
-e 's#let[ ][ ]*bytecomp_c_compiler[ ]*=.*#let bytecomp_c_compiler ="'"$CC"'"#' \
-e 's#let[ ][ ]*native_c_compiler[ ]*=.*#let native_c_compiler ="'"$CC"'"#' \
utils/config.ml
}
build1 () {
# Don't assemble asmrun/*.S for Phase 1 build. Modify Makefile
# temporarily to disable. Be really sure to put back for Phase 2.
echo 'xarm-build: ----- build phase 1 -----'
trap 'mv -f asmrun/Makefile.aside asmrun/Makefile' EXIT
mv -f asmrun/Makefile asmrun/Makefile.aside
$SED -e '/^[ ]*ASMOBJS[ ]*=/s/^/#/' \
-e 's#^include[ ][ ]*../config/Makefile#include ../config/Target/Makefile#' \
asmrun/Makefile.aside > asmrun/Makefile
make world && make opt
mv -f asmrun/Makefile.aside asmrun/Makefile
trap - EXIT
}
The compilation gets stuck in the stdlib subfolder, where an assertion on calling conventions fails.
let loc_external_arguments =
match Config.system with
| "rhapsody" -> poweropen_external_conventions 0 7 100 112
| "elf" | "bsd" -> calling_conventions 0 7 100 107 outgoing 8
| _ -> assert false
To even get to this point, amsrun/Makefile had to be modified to use the cross compile toolchain, and the HAS_STACK_OVERFLOW_DETECTION
had to be removed from config/s.h since amsrun/signals_asm.c could not be compiled otherwise.
So is there a way to make this work, or are other approaches in this manner better suited (and work with the 4.00.0 release of OCaml)?