ねるWiki:ねる Linux Zaurus 等の arm-linux なアーキテクチャ用の Gauche を cross compile してみました。 コンパイル環境 Mac OS X, Target SL-C700 でしか試していませんが、他でも同様だと思います。
./configure --host=arm-linux --enable-multibyte=utf-8 --enable-threads=pthreads make GOSH=/usr/local/bin/gosh mkdir tmp make prefix=$PWD/tmp install GOSH=/usr/local/bin/gosh -k
./tmp 以下にできたファイルたちを tar でかためて、Linux Zaurus にコピーして /usr/local に展開しましょう。
--enable-threads=pthreads はつけないとリンク時に sem_* が無いといわれるので付けてます。あと、--host=arm-linux はおかしいのですけどそうしないと cross compiler を使ってくれなかったのでそうしてます。もしかしたら、./configure のまえに CC=arm-linux-gcc とか書いてもいいかもしれません。
union ieee_double { double d; struct { unsigned long mant0:20; unsigned int exp:11; unsigned int sign:1; unsigned long mant1:32; } components; };もしこれが当たっている場合、ext/binary.cのScm_ReadBinaryDoubleとScm_WriteBinaryDoubleにも修正が必要かもしれません。 -- hirofummy
あとは qtopia extention が欲しいですね。
以下の作業を行うことで、Gauche-0.8.3をSL-C760でセルフコンパイルすることに成功(make checkをpass)しました。 使用した開発環境はdev_img-1.5です。-- hirofummy(2004/12/15 04:45:31 PST)
ieee_doubleの定義を以下のものに置き換える。(src/number.c)
union ieee_double { double d; struct { unsigned long mant0:20; unsigned int exp:11; unsigned int sign:1; unsigned long mant1:32; } components; };
以下の様なマクロを定義し、Scm_ReadBinaryDouble/Scm_WriteBinaryDoubleのSWAP8();をSWAPD();に置き換える。(ext/binary/binary.c)
#define SWAPD() ? do { char z; ? CSWAP(v.buf, z, 0, 3); ? CSWAP(v.buf, z, 1, 2); ? CSWAP(v.buf, z, 4, 7); ? CSWAP(v.buf, z, 5, 6); ? } while (0)
s8unboxの戻り値の型をcharからsigned charに書き換える。(ext/uvector/uvectorP.h)
- static inline char s8unbox(ScmObj obj, int clamp) + static inline signed char s8unbox(ScmObj obj, int clamp)
ext/uvector/uvector.cを最適化なしでコンパイルする。
gcc -DHAVE_CONFIG_H -I. -I../../src -I../../gc/include -g -fPIC -fomit-frame-pointer -c uvector.c
zaurus% ./config.guess armv5tel-unknown-linux-gnu
Shiro (2005/02/02 04:06:34 PST): 上に挙げられた変更を取り込んだバージョンを作ってみました。 targetがarmv*にマッチすれば上記のようなコードが使われます。 ARM環境をお持ちの方、試して報告して頂けるとうれしいです。 http://practical-scheme.net/vault/Gauche-0.8.3-p1.tgz
ただ、「uvector.cを最適化無しでコンパイルする」のはやっていません。 具体的にどういう問題が出るのか教えて下さい。
それからdoubleのbinary I/Oについては、endian引数の指定によってpure big endian かpure little endianに変換しているので、ARMネイティブでの入出力の 方法が今のところありません (デフォルトだとpure little endianになる)。 他のプログラムでダンプしたdoubleのバイナリデータを読みたい時なんかに 問題になるかもしれません。
$ /mnt/gauche/bin/gosh -V Gauche scheme interpreter, version 0.8.3 [utf-8,pthreads] $ /mnt/gauche/bin/gosh gosh> (* 1.3 2.3) Segmentation fault # 入れ替えた後 $ /mnt/gauche/bin/gosh gosh> (* 1.3 2.3) 2.9899999999999998
Shiro(2005/02/02 14:53:23 PST): 了解。直したのを同じ名前でアップロードしてあります。 他に引っかかったところはありませんか。テストは全部通りました?
ねるWiki:ねる (2005/02/02 17:07:50 PST) テストやってみました。failしたものだけ列挙しておきます。cross環境でテストするのは結構たいへんですね...
Testing system ... failed. discrepancies found. Errors are: test access: expects (#t #t #f #t) => got (#t #t #t #t) test access: expects (#t #t #f #f) => got (#t #t #t #f) test access: expects (#t #f #f #f) => got (#t #t #t #f) Testing uniform vector and array ... failed. discrepancies found. Errors are: test f32vector-dot(#f32(32767 32767 32767 32767 32767), #f32(32767 32767 32767 32767 32767)): expects 5.368381445e9 => got 5.36838144e9 test f32vector-dot(#f32(214748368 214748368 214748368 214748368 214748368), #f32(214748368 214748368 214748368 214748368 214748368)): expects 2.3058430779331712e17 => got 2.3058431724224512e17 test f32vector-dot(#f32(32767 -32767 32767 -32767 32767), #f32(32767 -32767 32767 -32767 32767)): expects 5.368381445e9 => got 5.36838144e9 make[2]: Leaving directory `/mnt/gauche/src/Gauche-0.8.3-p1/ext/uvector'
Shiro(2005/02/02 18:03:30 PST): f32vectorでこけるのはFPUレジスタ周辺の 問題かな。たぶん最下位ビットで誤差が出てるんだと思う。 とりあえずは使えそうですね。
hirofummy: すみません。説明不足でした。uvector.cの最適化を外したのはねるさんと同じfailが出ていたからで、単にmake checkを通すためだけです。Gauche-0.8.3-p1を前回報告したときと同じ環境でセルフコンパイルしましたが、uvectorについてねるさんと全く同じfailが出た以外は問題ありませんでした。(make checkでそれ以外のfailはありませんでした。)
zaurus% gosh -V Gauche scheme interpreter, version 0.8.3-p1 [euc-jp]
Shiro(2005/02/02 22:40:13 PST): 了解。これだけのためにuvector.cの最適化を切るのは 勿体ない気がするので、まっとうなアタックルートはoveroptimizationになってる 箇所を見付けてoptimizerを欺くことだと思います。ただこれは手元に環境が無いと 難しいので、機会があればということで。