在找到为目标机器生成合适的配置文件的方法之后,仍然必须构建交叉编译器本身。如果主机和目标系统差异太大,使用此处描述的 1 1/2 构建的方法(以及更多详细信息,请参见此处)似乎不起作用。这是构建脚本的更改部分(可以通过 获取$ 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
}
编译卡在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
必须从config/sh中删除,因为否则无法编译amsrun/signals_asm.c 。
那么有没有办法使这项工作,或者以这种方式的其他方法更适合(并与 OCaml 的 4.00.0 版本一起使用)?