2009年3月31日火曜日

Linux で apt-cross

とりあえず VMWare に Debian をインストール。特に悩むところは無いはず。

http://cdimage.debian.org/debian-cd/5.0.0/i386/iso-cd/debian-500-i386-netinst.iso

# export LANG=C
# export LC_ALL=C
# export LANGUAGE=English
# apt-get update
# apt-get install apt-cross
# apt-cross -a arm -S stable -m http://ftp.jp.debian.org/debian/ --update
# apt-cross -a arm -S stable -m http://ftp.jp.debian.org/debian/ --install gcc gcc-4.3 libgcc1 cpp cpp-4.3 gcc-4.3-base libgomp1 libc6-dev

apt-cross は依存関係解決してくれないらしいので、全て手打ちする。(参考

後は普通に binutils と gcc の ARM 版のインストール。

# apt-get build-dep gcc-4.3

一応 arm-gcc-cross とか gcc-4.3-arm-cross が apt にあるけど、どうなんだろうな…

追記

CodeSourcery から持ってくるのが一番楽。

qemu memo 2009年4月7日 kernel 2.6.29 と差し替えてみる

2009年3月30日月曜日

MinGW runtime の再構築

ビルドディレクトリ内で

mingwrt-3.15.1-mingw32-src.tar.gz



w32api-3.12-mingw32-src.tar.gz

を展開して、w32api-3.12-mingw32/include ディレクトリを一つ持ち上げる (同一階層に持ってくる)。

次に同 include を mingwrt-3.15.1-mingw32 の中にコピー。

後は mingwrt-3.15.1-mingw32 内のソースに適切な変更を施した後、

./configure --prefix=/c/MinGW

して make ; make install すれば MinGW ランタイムを再構築できる。

もっとちゃんとしたやり方があるのかもしれないけど、とりあえずこれでビルドは通る。

2009年3月25日水曜日

ffixed option

ソースを変えなくても、オプションで特定のレジスタを使わないコードを出せるらしい。

(via https://www.codeblog.org/blog/kkojima/20070330.html)

例えば r12 を使わないコードを出すときには

$ sh-elf-gcc.exe -ffixed-r12 ...

ちょっと修正

GCJ 限定らしい余計な opution を削った。

$ ../../gcc-4.4-20090313/configure --prefix=/c/msys/1.0/home/aloha/work/gcc/sh --with-as=/c/msys/1.0/home/aloha/work/gcc/sh/sh-elf/bin/as.exe --with-gnu-as --with-ld=/c/msys/1.0/home/aloha/work/gcc/sh/sh-elf/bin/ld.exe --with-gnu-ld --with-ar=/c/msys/1.0/home/aloha/work/gcc/sh/sh-elf/bin/ar.exe --with-gnu-ar --with-gmp=/usr/local/ --with-mpfr=/usr/local --without-newlib --without-headers --enable-languages=c,c++ --disable-shared --disable-multilib --disable-nls --disable-threads --disable-libstdc --disable-libstdcxx --disable-libstdcxx-v3 --disable-libssp --disable-libstdcxx-pch --disable-bootstrap --without-included-gettext --target=sh-elf --enable-checking=rtl

あと RTL をチェックしとかないと非常に厳しい。

2009年3月23日月曜日

sh 版のビルド

例のごとく configure を自分のためにメモ(もともとこのブログ自体がメモだけど…)。
$ ../../binutils-2.19/configure --prefix=/c/msys/1.0/home/aloha/work/gcc/sh/ --target=sh-elf --with-sysroot=/c/msys/1.0/home/aloha/work/gcc/sh/root

途中で MinGW の texinfo (?) が古いのでエラーになる。けど、無視してインストール (make -i install)。
$ ../../gcc-4.4-20090313/configure --prefix=/c/msys/1.0/home/aloha/work/gcc/sh --with-as=/c/msys/1.0/home/aloha/work/gcc/sh/sh-elf/bin/as.exe --with-gnu-as --with-ld=/c/msys/1.0/home/aloha/work/gcc/sh/sh-elf/bin/ld.exe --with-gnu-ld --with-ar=/c/msys/1.0/home/aloha/work/gcc/sh/sh-elf/bin/ar.exe --with-gnu-ar --with-gmp=/usr/local/ --with-mpfr=/usr/local --without-newlib --enable-languages=c,c++ --disable-shared --disable-multilib --disable-nls --disable-threads --disable-libstdc --disable-libstdcxx --disable-libssp --disable-libstdcxx-pch --disable-bootstrap --disable-win32-registry --without-included-gettext --enable-hash-synchronization --without-x --target=sh-elf

こっちも、なぜか disable-listdcxx してるのに、stdc++ を configure しに行ってエラーになってしまう。しかし、gcc のバイナリ自体はできているので、無視してインストール(今回は独自のライブラリを使うので libgcc libc libstdc++ はいらない)

gcc 4.4 からは libssp も MinGW で通るとは思うけど、習慣で disable にしてしまった。

2009年3月19日木曜日

masm option

gcc の全オプションは gcc -v --help で出る。

ATT syntax を Intel に変える、-masm=intel なんていうオプションがあったのか…

2009年3月18日水曜日

fixed_regs

例えば PIC のための GOT ebx 相対など、レジスタに特定の役割を与えるために、他の用途には使わせたくない場合がある。

そういう時は、fixed_regs[] のレジスタ番号番目の要素に 1 を入れる。
各バックエンドの override_options() などでやると良い。


if (flag_xxx) {
call_used_regs[BX_REG] = fixed_regs[BX_REG] = 1;
}


ちなみに、call_used_regs[] にも 1 をセットしておかないと、reginfo.c の gcc_assert() で落ちるので注意。