2012-05-06 :-)
_ [h8300-elf][gcc][クロスコンパイラ][クロスコンパイル][cross compile]h8300-elf なクロスコンパイラ gcc 4.7.0 を作る
pkgsrc に h8300-hms ならあるんだが elf はないのでがんばる。
pkgsrc/cross/h8300-hms-gcc/
binutils とライブラリをインストールして gcc をインストールして newlib をインストールする。
環境
- NetBSD/i386 5.99.58 (VMWare)
( っていくつだっけ )
ライブラリをインストールする
gcc が必要としているライブラリ群をインストールする。pkgsrc があるので使う。pkgsrc が無い場合は気合いでがんばる。
- GMP→pkgsrc/devel/gmp
- MPFR→pkgsrc/math/mpfr
- MPC→pkgsrc/math/mpcomplex
- PPL→pkgsrc/math/ppl
- cloog-ppl→pkgsrc-wip/cloog
binutils をインストール
http://ftp.gnu.org/gnu/binutils/ からダウンロードして展開してディレクトリ作って configure してビルド。
% wget http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.gz % tar xzf binutils-2.22.tar.gz % cd binutils-2.22 % mkdir build % mkdir -p /usr/local/cross % ../configure --build=i386-netbsd --target=h8300-elf --disable-nls --prefix=/usr/local/cross % gmake % gmake install
newlib 準備だけ
ftp://sources.redhat.com/pub/newlib/index.html からダウンロードして展開だけしておく。
% wget ftp://sources.redhat.com/pub/newlib/newlib-1.20.0.tar.gz % tar xzf newlib-1.20.0.tar.gz
gcc インストール
% wget ftp://ftp.dti.ad.jp/pub/lang/gcc/releases/gcc-4.7.0/gcc-4.7.0.tar.gz % tar xzf gcc-4.7.0.tar.gz % cd gcc-4.7.0 % mkdir build % cd build
gcc が bash 前提なので SHELL に設定しておく。PATH はたぶん /usr/local/cross/bin だけでいい。pkgsrc でインストールしたライブラリ群は /usr/pkg/lib にインストールされるので設定しておく。
% export SHELL=/usr/pkg/bin/bash % export PATH=$PATH:/usr/local/cross/h8300-elf/bin:/usr/local/cross/bin % export LD_LIBRARY_PATH=/usr/pkg/lib
% ../configure \ --build=i386-pc-netbsd \ --target=h8300-elf \ --prefix=/usr/local/cross \ --with-gmp=/usr/pkg \ --with-mpfr=/usr/pkg \ --with-mpc=/usr/pkg \ --with-ppl=/usr/pkg \ --with-cloog=/usr/pkg \ --enable-cloog-backend=isl \ --enable-languages=c \ --disable-nls \ --disable-threads \ --disable-shared \ --disable-decimal-float \ --disable-libmudflap \ --disable-libssp \ --disable-libgomp \ --disable-libquadmath \ --with-newlib \ --with-headers=/home/rin/usr/local/newlib-1.20.0/newlib/libc/include
% gmake % gmake install
gcc の make でエラーになった場合
ググっただけなのでこれが正しいのかどうか知らね分かんね。
cannot compute suffix of object files: cannot compile
xgcc (GCC) 4.7.0 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. configure:3418: $? = 0 configure:3407: /home/rin/usr/local/gcc-4.7.0/build/./gcc/xgcc -B/home/rin/usr/local/gcc-4.7.0/build/./gcc/ -B/usr/local/h8300-elf/bin/ -B/usr/local/h8300-elf/lib/ -isystem /usr/local/h8300-elf/include -isystem /usr/local/h8300-elf/sys-include -v >&5 Reading specs from /home/rin/usr/local/gcc-4.7.0/build/./gcc/specs COLLECT_GCC=/home/rin/usr/local/gcc-4.7.0/build/./gcc/xgcc COLLECT_LTO_WRAPPER=/home/rin/usr/local/gcc-4.7.0/build/./gcc/lto-wrapper Target: h8300-elf Configured with: ../configure --target=h8300-elf --enable-cloog-backend=isl --disable-nls --disable-threads --disable-shared --enable-languages=c --with-gmp=/usr/pkg --with-mpfr=/usr/pkg --with-mpc=/usr/pkg --with-ppl=/usr/pkg --with-cloog=/usr/pkg --disable- libssp Thread model: single gcc version 4.7.0 (GCC) configure:3418: $? = 0 configure:3407: /home/rin/usr/local/gcc-4.7.0/build/./gcc/xgcc -B/home/rin/usr/local/gcc-4.7.0/build/./gcc/ -B/usr/local/h8300-elf/bin/ -B/usr/local/h8300-elf/lib/ -isystem /usr/local/h8300-elf/include -isystem /usr/local/h8300-elf/sys-include -V >&5 xgcc: error: unrecognized command line option '-V' xgcc: fatal error: no input files compilation terminated. configure:3418: $? = 1 configure:3407: /home/rin/usr/local/gcc-4.7.0/build/./gcc/xgcc -B/home/rin/usr/local/gcc-4.7.0/build/./gcc/ -B/usr/local/h8300-elf/bin/ -B/usr/local/h8300-elf/lib/ -isystem /usr/local/h8300-elf/include -isystem /usr/local/h8300-elf/sys-include -qversion >& 5 xgcc: error: unrecognized command line option '-qversion' xgcc: fatal error: no input files compilation terminated. configure:3418: $? = 1 configure:3434: /home/rin/usr/local/gcc-4.7.0/build/./gcc/xgcc -B/home/rin/usr/local/gcc-4.7.0/build/./gcc/ -B/usr/local/h8300-elf/bin/ -B/usr/local/h8300-elf/lib/ -isystem /usr/local/h8300-elf/include -isystem /usr/local/h8300-elf/sys-include -o conftest -g -O2 conftest.c >&5 Shared object "libcloog-isl.so.1" not found configure:3437: $? = 1 configure:3625: checking for suffix of object files configure:3647: /home/rin/usr/local/gcc-4.7.0/build/./gcc/xgcc -B/home/rin/usr/local/gcc-4.7.0/build/./gcc/ -B/usr/local/h8300-elf/bin/ -B/usr/local/h8300-elf/lib/ -isystem /usr/local/h8300-elf/include -isystem /usr/local/h8300-elf/sys-include -c -g -O2 c onftest.c >&5 Shared object "libcloog-isl.so.1" not found configure:3651: $? = 1 configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "GNU C Runtime Library" | #define PACKAGE_TARNAME "libgcc" | #define PACKAGE_VERSION "1.0" | #define PACKAGE_STRING "GNU C Runtime Library 1.0" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "http://www.gnu.org/software/libgcc/" | /* end confdefs.h. */ | | int | main () | { | | ; | return 0; | } configure:3665: error: in `/home/rin/usr/local/gcc-4.7.0/build/h8300-elf/libgcc': configure:3667: error: cannot compute suffix of object files: cannot compile See `config.log' for more details.
→ binutils をインストールしてない or mpfr へのパスが通ってない。LD_LIBRARY_PATH に設定する
stdio.h: No such file or directory
In file included from ../../../../libgcc/libgcc2.c:29:0: ../../../../libgcc/../gcc/tsystem.h:88:19: fatal error: stdio.h: No such file or directory compilation terminated. gmake[4]: *** [_muldi3.o] エラー 1 gmake[4]: ディレクトリ `/home/rin/usr/local/gcc-4.7.0/build/h8300-elf/h8300h/libgcc' から出ます gmake[3]: *** [multi-do] エラー 1 gmake[3]: ディレクトリ `/home/rin/usr/local/gcc-4.7.0/build/h8300-elf/libgcc' から出ま す gmake[2]: *** [all-multi] エラー 2 gmake[2]: ディレクトリ `/home/rin/usr/local/gcc-4.7.0/build/h8300-elf/libgcc' から出ま す gmake[1]: *** [all-target-libgcc] エラー 2 gmake[1]: ディレクトリ `/home/rin/usr/local/gcc-4.7.0/build' から出ます gmake: *** [all] エラー 2
→ 然るべきパーミッションにする or rootで作業
newlib インストール
% cd newlib-1.20.0 % mkdir build % cd build % ../configure \ --build=i386-pc-netbsd \ --target=h8300-elf \ --prefix=/usr/local/cross % gmake % gmake install
参考
[ツッコミを入れる]