2008年12月6日土曜日

mips-unknown-elf gcc with newlib

以前は mips-linux-elf で作ったので、linux に依存するヘッダを要求されてコケた。

linux kernel をビルドすることに拘らなければ、mips-unknown-elf で普通に通った。

newlib-1.16.0 を展開して、gcc-4.3.2/ 以下に newlib-1.6.0/newlib と newlib-1.6.0/libgloss へのシンボリックリンクを張る。

binutils -> gcc -> newlib の順に、以下のように configure ; make ; make install する (別途 build-*** のようなディレクトリを掘って、そこで行う)。

途中で makeinfo がどうこうというエラーが出たら、make -i で無視してビルドを続行する。
$ ../binutils-2.19/configure --prefix=/usr/local/mips --target=mipsel-unknown-elf --disable-nls --without-included-gette
xt

$ ../gcc-4.3.2/configure --with-gmp=/usr/local --with-mpfr=/usr/local --enable-languages=c,c++ --disable-nls --disable-w
in32-registry --disable-shared --without-included-gettext --disable-libssp --prefix=/usr/local/mips/ --target=mipsel-unk
nown-elf --disable-multilib --without-fp --disable-libmudflap --disable-libstdcxx-pch --with-newlib --with-headers=/home
/aloha/work/mips/build/gcc-4.3.2/newlib/libc/include/

$ ../newlib-1.16.0/configure --target=mipsel-unknown-elf --prefix=/usr/loca/mips

(newlib のビルドは gcc と同時に行われるから不要かもしれない。未確認)

できた gcc で、-EB オプションを付けると
$ /usr/local/mips/bin/mipsel-unknown-elf-gcc.exe -EB test.c
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crti.o: compiled for a little endian system and target is big endian
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crti.o: endianness incompatible with that of the selected emulation
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: failed to merge target specific data of file c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crti.o
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crtbegin.o: compiled for a little endian system and target is big endian
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crtbegin.o: endianness incompatible with that of the selected emulation
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: failed to merge target specific data of file c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crtbegin.o
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crtend.o: compiled for a little endian system and target is big endian
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crtend.o: endianness incompatible with that of the selected emulation
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: failed to merge target specific data of file c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crtend.o
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crtn.o: compiled for a little endian system and target is big endian
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crtn.o: endianness incompatible with that of the selected emulation
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: failed to merge target specific data of file c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/crtn.o
c:/msys/1.0/local/mips/bin/../lib/gcc/mipsel-unknown-elf/4.3.2/../../../../mipsel-unknown-elf/bin/ld.exe: warning: cannot find entry symbol _start; defaulting to 0000000000400050
collect2: ld returned 1 exit status

エラーになってしまう (最後の警告は、crt0.o と ld script を用意してないから当たり前)

これを両方サポートできるようにするために、enable-targets とかでなんとかできるかと思ったけど、結局上手く行かなかった。

0 件のコメント: