2012-10-04 4 views

답변

1

"configure chain"을 사용하여 파일을 생성 할 수 있습니다. Ocamls configure 스크립트는 크로스 컴파일 환경에서 불가능할 수있는 동일한 실행에서 결과를 컴파일하고 실행할 수 있다고 가정합니다.
따라서 컴파일 결과 (실행 파일 포함)가 저장되고 대상 시스템에서 두 번째 실행에 사용될 수 있도록 구성 절차를 수정해야합니다. 다음은 수정본 (~ 200 줄)을 보여주는 diff 파일입니다.

diff -r -U 1 ocaml-4.00.0-orig/config/auto-aux/hasgot ocaml-4.00.0-cross/config/auto-aux/hasgot 
--- ocaml-4.00.0-orig/config/auto-aux/hasgot 
+++ ocaml-4.00.0-cross/config/auto-aux/hasgot 
@@ -15,2 +15,4 @@ 

+. ./keyval.sh 
+ 
opts="" 
@@ -36,7 +38,13 @@ 

+key="$cc $args" 
+getValueExit "$key" 
+ 
if test "$verbose" = yes; then 
    echo "hasgot $args: $cc $opts -o tst hasgot.c $libs" >&2 
- exec $cc $opts -o tst hasgot.c $libs > /dev/null 
+ `exec $cc $opts -o tst hasgot.c $libs > /dev/null` 
else 
- exec $cc $opts -o tst hasgot.c $libs > /dev/null 2>/dev/null 
+ `exec $cc $opts -o tst hasgot.c $libs > /dev/null 2>/dev/null` 
fi 
+res=$? 
+setValue "$key" "$res" 
+exit "$res" 
diff -r -U 1 ocaml-4.00.0-orig/config/auto-aux/hasgot2 ocaml-4.00.0-cross/config/auto-aux/hasgot2 
--- ocaml-4.00.0-orig/config/auto-aux/hasgot2 
+++ ocaml-4.00.0-cross/config/auto-aux/hasgot2 
@@ -15,2 +15,4 @@ 

+. ./keyval.sh 
+ 
opts="" 
@@ -36,7 +38,13 @@ 

+key="$cc $args" 
+getValueExit "$key" 
+ 
if test "$verbose" = yes; then 
    echo "hasgot2 $args: $cc $opts -o tst hasgot.c $libs" >&2 
- exec $cc $opts -o tst hasgot.c $libs > /dev/null 
+ `exec $cc $opts -o tst hasgot.c $libs > /dev/null` 
else 
- exec $cc $opts -o tst hasgot.c $libs > /dev/null 2>/dev/null 
+ `exec $cc $opts -o tst hasgot.c $libs > /dev/null 2>/dev/null` 
fi 
+res=$? 
+setValue "$key" "$res" 
+exit "$res" 
Only in ocaml-4.00.0-cross/config/auto-aux: keyval.sh 
diff -r -U 1 ocaml-4.00.0-orig/config/auto-aux/runtest ocaml-4.00.0-cross/config/auto-aux/runtest 
--- ocaml-4.00.0-orig/config/auto-aux/runtest 
+++ ocaml-4.00.0-cross/config/auto-aux/runtest 
@@ -17,6 +17,30 @@ 
echo "runtest: $cc -o tst $* $cclibs" >&2 
-$cc -o tst $* $cclibs || exit 100 
+stream=/dev/stderr 
else 
-$cc -o tst $* $cclibs 2> /dev/null || exit 100 
+stream=/dev/null 
+#$cc -o tst $* $cclibs 2> /dev/null || exit 100 
fi 
+ 
+key="$* $cclibs" 
+ 
+if test "$crossmode" = cross-cc; then 
+ i=`cat ./counter` 
+ $cc -o tst"$i" $* $cclibs 2> "$stream" || exit 100 
+ echo "$key"'%%#%%'tst"$i" >> ./map_runtest 
+ i=`expr $i + 1` 
+ echo "$i" > ./counter 
+ if test "$*" = sizes.c; then 
+  echo "4 4 4 2" 
+ fi 
+ if test `expr "$*" : '.*tclversion.c'` -ne 0; then 
+  echo "8.5" 
+ fi 
+ exit 0 
+fi 
+if test "$crossmode" = cross-run; then 
+ tst=`awk -v ccargs="$key" 'BEGIN {FS="%%#%%"} $1 == ccargs {print $2}' ./map_runtest` 
+ exec ./"$tst" 
+fi 
+ 
+$cc -o tst $* $cclibs 2> "$stream" || exit 100 
exec ./tst 
diff -r -U 1 ocaml-4.00.0-orig/config/auto-aux/tryassemble ocaml-4.00.0-cross/config/auto-aux/tryassemble 
--- ocaml-4.00.0-orig/config/auto-aux/tryassemble 
+++ ocaml-4.00.0-cross/config/auto-aux/tryassemble 
@@ -1,8 +1,16 @@ 
#!/bin/sh 
+ 
+. ./keyval.sh 
+ 
+key="$aspp $*" 
+getValueExit "$key" 
+ 
if test "$verbose" = yes; then 
echo "tryassemble: $aspp -o tst $*" >&2 
-$aspp -o tst $* || exit 100 
+`$aspp -o tst $* || exit 100` 
else 
-$aspp -o tst $* 2> /dev/null || exit 100 
+`$aspp -o tst $* 2> /dev/null || exit 100` 
fi 
+res=$? 
+setValue "$key" "$res" 

@@ -11,7 +19,14 @@ 
if test "$verbose" = yes; then 
+key="$as $*" 
+getValueExit "$key" 
echo "tryassemble: $as -o tst $*" >&2 
-$as -o tst $* || exit 100 
+`$as -o tst $* || exit 100` 
else 
-$as -o tst $* 2> /dev/null || exit 100 
+`$as -o tst $* 2> /dev/null || exit 100` 
fi 
+res=$? 
+setValue "$key" "$res" 
+exit $res 
+else 
+exit $res 
fi 
diff -r -U 1 ocaml-4.00.0-orig/config/auto-aux/trycompile ocaml-4.00.0-cross/config/auto-aux/trycompile 
--- ocaml-4.00.0-orig/config/auto-aux/trycompile 
+++ ocaml-4.00.0-cross/config/auto-aux/trycompile 
@@ -15,7 +15,15 @@ 

+. ./keyval.sh 
+ 
+key="$cc $* $cclibs" 
+getValueExit "$key" 
+ 
if test "$verbose" = yes; then 
echo "trycompile: $cc -o tst $* $cclibs" >&2 
-$cc -o tst $* $cclibs || exit 100 
+`$cc -o tst $* $cclibs || exit 100` 
else 
-$cc -o tst $* $cclibs 2> /dev/null || exit 100 
+`$cc -o tst $* $cclibs 2> /dev/null || exit 100` 
fi 
+res=$? 
+setValue "$key" "$res" 
+exit $res 
diff -r -U 1 ocaml-4.00.0-orig/configure ocaml-4.00.0-cross/configure 
--- ocaml-4.00.0-orig/configure 
+++ ocaml-4.00.0-cross/configure 
@@ -47,2 +47,3 @@ 
withcamlp4=camlp4 
+crossmode='' 

@@ -119,2 +120,4 @@ 
     withcamlp4="";; 
+ -cross|--cross) 
+  crossmode="$2"; shift;; 
    *) echo "Unknown option \"$1\"." 1>&2; exit 2;; 
@@ -158,2 +161,21 @@ 

+case "$crossmode" in 
+ cc) 
+  crossmode=cross-cc 
+  echo 0 > ./counter 
+  rm -f ./map_runtest ./map_hasgot 
+  touch ./map_runtest ./map_hasgot;; 
+ run) 
+  crossmode=cross-run 
+  if test ! -e ./map_runtest -o ! -e ./map_hasgot; then 
+   echo 'Run with -cross cc first' 
+   exit 2 
+  fi 
+  rm -f ./counter;; 
+ none) crossmode=none;; 
+ "") crossmode=none ;; 
+ *) 
+  echo 'Unknown crossmode'>&2 
+  exit 2;; 
+esac 
# Write options to Makefile 
@@ -350,3 +372,3 @@ 
cc="$bytecc -O $bytecclinkopts" 
-export cc cclibs verbose 
+export cc cclibs verbose crossmode 

@@ -1647,2 +1669,5 @@ 

+if test "$crossmode" = cross-run; then 
+ rm -f tst* ./map_runtest ./map_hasgot 
+fi 
# Print a summary 

구성 스크립트는 새로운 -cross 옵션을 갖습니다. cc이 인수 인 경우 컴파일 만되고 run 일 경우 컴파일 된 사항 만 실행됩니다. 중간 결과는 config/auto-aux/map_ {hasgot, runtest}에 저장되며 대부분 검색시 setValuegetValueExit을 사용하며 config/auto-aux/keyval.sh에 정의됩니다. 하나와 교차 툴체인 데이터를 제공하는 경우

-cc, -as, -aspp, -partialld, -libs, -dllibs, -dldefs

메이크 가능해야한다.마지막으로, 그 내용은 diff에없는 파일 keyval.sh는 : tk 사용

getValueExit() 
{ 
if test "$crossmode" = cross-run; then 
    res=`awk -v ccargs="$1" 'BEGIN {FS="%%#%%"} $1 == ccargs {print $2; exit}' ./map_hasgot` 
    exit "$res" 
fi 
} 

setValue() 
{ 
if test "$crossmode" = cross-cc; then 
    echo "$1"'%%#%%'"$2" >> ./map_hasgot 
fi 
} 

경우, 하나는 설정/자동 AUX/runtest을 수정하고 버전 번호와 0.0를 교체해야합니다. 또한 solaris가 대상 또는 호스트 시스템으로 사용되는 경우 파일 config/auto-aux/solaris-ld을 수정해야 할 수도 있습니다.

7

저는 OCaml 크로스 컴파일러를 몇 년 동안 제작 해 왔습니다. 내 웹 사이트 링크를 보려면 내 프로필을 참조하십시오. 내가하는 일은 컴파일러를 1 1/2 시간 만 빌드하는 것입니다. 처음으로 호스트에 대한 것입니다 (대상에 대한 일부 설정이 있음). 하반기 빌드는 대상에 대한 런타임을 빌드하는 것입니다.

OS X에서 ARM/iOS 로의 크로스 컴파일러 작성을위한 스크립트의 이름은 xarm-build입니다.

$ svn cat svn://svn.psellos.com/trunk/ocamlxarm/3.1/xarm-build 

면책 조항 : 당신은 서브 버전이있는 경우, 당신은 내 공개 저장소에서 사본을 얻을 수있는 지금,이 스크립트는 컴파일러의 바이트 코드 버전을 구축합니다. 즉, 컴파일러 자체는 OCaml 바이트 코드 실행 파일입니다. 그러나 타겟에 대한 원시 코드를 생성합니다.

이 방법을 사용하고 궁금한 점이 있으면 알려 주시기 바랍니다. 대상 시스템 인 경우

는, 특정 질문에 대한 답을 유닉스처럼 당신이 중요한 파일입니다 언급으로 config/s.h, config/m.hconfig/Makefile를 생성하는 대상에 configure 스크립트를 실행 시도 할 수 있습니다. 타겟에 대한 시뮬레이터가 있다면 시뮬레이터 내에서 configure을 실행할 수 있습니다. 이것이 iOS에서하는 것입니다. 그렇지 않으면 합당한 내용을 알아 내야합니다. (가능하면 대상과 비슷한 유닉스 계열 시스템에서 configure를 실행하십시오.)

+0

답변 해 주셔서 감사합니다. 나는 DiskStation에서 gkg가 제공하는 ipkg에 의해 제공되는 파일을 생성했습니다. ipkg은 대상 시스템에 가깝게 접근 할 수 있다고 가정합니다. 나는 또한 당신의 대본을 읽었고, 그것은 나를 조금 괴롭힌다. 첫 번째 간단한 관찰 : 두 개의 configure 호출에'-prefix $ XARMTARGET/v7'을 입력하여 4 줄을 절약 할 수 있습니다. 더욱, 나는 약간 압도된다. 이'ocamlopt'는'build1'에서 무엇입니까? ocaml을 올바른 툴체인 환경이 아닌 ARM에 컴파일합니까? 그리고 이것은'build2'로 수정 되었습니까? ARM 환경이 i386과 많이 다르지 않다는 사실을 암묵적으로 사용합니까? –

+0

타겟 코드를 생성하는 컴파일러를 빌드해야합니다. OCaml 프로그램이므로이 컴파일러는 호스트에서 작동하는 런타임 (특히 바이트 코드 인터프리터)이 필요합니다. 그러나 컴파일러에 의해 컴파일 된 프로그램을위한 런타임도 필요합니다. 이 런타임은 대상에서 작동합니다. 두 개의 런타임이 필요하므로 두 번 빌드해야합니다. (OCaml의 오래된 버전에서는'-prefix'가 나에게 도움이 안된다. 지금 작동하면 멋지다.) –

+0

configure 스크립트를 수정하여 두 번 실행하여 파일을 생성 할 수있다. 짧은 모양, 제발?). 몇 가지 질문이 있습니다. 스크립트의 두 번째 단계에서 Makefile에'RANLIB *','ARCMD' 및'MKLIB' 행을 사후 수정하지 않기 때문에 호스트에서만 사용됩니다 기계 (첫 단계)? 'utils/config.ml' 파일을 수정하려면 정확한 크로스 컴파일러 만 제공해야합니까? 두 번째 단계에서 올바른 환경이 제공되면 아무 것도 수정하면 안됩니까? (어쩌면 이번에는 새로운 질문을해야합니다.) –