H8 gnu toolchain

RenesasのH8という古いCPUのプログラムをメンテしようと思ったら、開発ツール(gcc)が新しいWindowsやLinuxの環境で動かず、改めてコンパイルしなおすハメになりました。あまりに大変だったので、手順について書いておきます。

この手順は、Webで同じように苦労されている方々の情報を集約して最終的にうまくいったものですが、他の方も同様に苦労されてその結果を書かれていると思うので、なぜ、他の方の手順を真似たらそのままうまくいかないのかは謎ですが、微妙な違いで失敗するのかも・・・

1. 作成したものと環境
h8300-hms tool chain
binutils-2.16.1
gcc, g++ 4.4.6
newlib-2.0.0
Scientific linux 6.4 on Oracle VM VirtualBox

2. 参考
http://www.soramimi.jp/h8300gcc/index.html (soramimi)
http://whotookspaz.org/~anmaster/lego/rcx-toolchain-guide/guide.html (whotookspaz.org)

3. 下準備
soramimi に書かれているとおり、最近のgccをコンパイルするには、gmp, mpfr, mpc が必要なので、コンパイルしておきます。

cd gmp-5.1.2
mkdir build
cd build
../configure –prefix=/usr/local –disable-shared
make
make install
cd ../../

cd mpfr-3.1.2
mkdir build
cd build
../configure –prefix=/usr/local –disable-shared –with-gmp=/usr/local
make
make install
cd ../../

cd mpc-1.0.1
mkdir build
cd build
../configure –prefix=/usr/local –with-gmp=/usr/local –with-mpfr=/usr/local
make
make install
cd ../../

4. binutils 2.16.1 のコンパイル。

tar jxf binutils-2.16.1.tar.bz2
export LANG=C
whotookspaz.org の参考のところに置いてあるパッチ(binutils-overflow.patch)を当てます。
(See http://sourceware.org/ml/binutils-cvs/2005-03/msg00144.html)とのこと。

cd binutils-2.16.1/
patch -p1 < ../patches/binutils-overflow.patch mkdir build cd build/ ../configure --prefix=$HOME/local --target=h8300-hms --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --disable-nls make make install cd ../.. 5. gccのコンパイル。 C++を使いたいので、そのようにコンパイルします。 cd gcc-4.4.6 mkdir build cd build export PATH=$HOME/local/bin:$PATH ../configure --prefix=$HOME/local --target=h8300-hms --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --with-newlib --with-headers=../../newlib-2.0.0/newlib/libc/include --enable-languages=c,c++ --enable-long-long --disable-shared --disable-libada --disable-libssp --disable-nls --enable-obsolete make make install ですが、そのままですと、 libiberty/strsignal.c でpsignal()が重複しているというエラーがでますので、psignal()の関数をコメントアウトしました。 また、C++のコンパイル中に、 error: no matching function for call to 'min(size_t&, int&)' というようなエラーがでますので、 libstdc++-v3/include/std/bitset に下記のようなパッチを手動であてました。 --- libstdc++-v3/./include/std/bitset.org 2009-06-23 11:48:50.000000000 -0700 +++ libstdc++-v3/./include/std/bitset 2009-06-23 11:49:58.000000000 -0700 @@ -1228,7 +1228,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GL size_t __pos, size_t __n, _CharT __zero, _CharT __one) { reset(); - const size_t __nbits = std::min(_Nb, std::min(__n, __len - __pos)); + const size_t __tmp = __len - __pos; + const size_t __nbits = std::min(_Nb, std::min(__n, __tmp)); for (size_t __i = __nbits; __i > 0; –__i)
{
const _CharT __c = __s[__pos + __nbits – __i];

6. newlib のコンパイル。
cd newlib-2.0.0/
mkdir build
cd build/
../configure –prefix=$HOME/local –target=h8300-hms
make
make install

configure で–disable-sharedしないといけないかもしれませんがとりあえず。

以上。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)