在找到目标机器的generate the fitting configuration files的方法之后,交叉编译器本身仍然必须构建。如果主机和目标系统差异太大,使用1 1/2内部版本described here(以及更多详细信息,here)的方法似乎不起作用。下面是构建脚本(可以用$ svn cat svn://svn.psellos.com/trunk/ocamlxarm/3.1/xarm-build
获得)的改变部分如何构建一个OCaml交叉编译器
# 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
}
编译卡在STDLIB子文件夹,其中上调用约定断言失败。
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
,甚至走到这一步,amsrun/Makefile文件不得不修改为使用交叉编译工具链,以及HAS_STACK_OVERFLOW_DETECTION
不得不因为 amsrun/signals_asm.c从配置/ SH删除否则无法编译。
那么有没有一种方法可以使这项工作更好地适应(并且可以使用OCaml的4.00.0版本)?
我相信Ocaml列表或论坛http://caml.inria.fr/resources/forums.en.html是一个更好的地方要问。 –
我不知道你的目标是什么样的,但我怀疑xarm-build脚本实际上非常接近。它适用于从英特尔上的OS X到ARM上的iOS(类似系统,但非常不同的CPU)的交叉编译。 (免责声明:我写了xarm-build。)但是Basile是对的,你可能在OCaml邮件列表上得到更好的答案。有许多小细节必须完全正确。 –
@JeffreyScofield其(Linux,i386) - >(Linux,PPC)。这些平台不应该太差,但似乎目标文件/可执行文件格式略有不同。无论如何,我会问OCAML家伙。谢谢。 –