在找到目標機器的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傢伙。謝謝。 –