Cross GCC for Renesas RX

embedded_c embedded_cxx renesas_rx

I've just succeeded in compiling cross compilation environment for RX on OSX (10.8.5). The codingcipher's great posts gave me a lot of helpful info.

Hope this post helps developers who are going to build RX cross compiler.

KPIT GNU Tools

First of all, you need to get KPIT GNU Tools from the site. You are required to sign up the site in order to download the tools.

The sign up process may take a couple of hours to be completed as KPIT guys verifies the sign up.

Installing GCC 4.8.2 on OSX

In order to compile KPIT GNU Tools, I used the latest GCC as the XCode bundled GCC is too old and no longer maintained.

In this step, I was going with MacPorts.

sudo port selfupdate

Install GCC 4.8.2 with +universal. The option is required in order to allow gcc to compile with 32bit libraries.

sudo port install gcc48 +universal

Building gcc requires GMP, MPFR and MPC.

sudo port install gmp mpfr libmpc

FYI: Here is a list of installed packages on my machine:

  • gmp @5.1.2
  • mpfr @3.1.1-p2
  • libmpc @1.0.1
  • gcc48 @4.8.2
  • libgcc @4.8.2

Directory Structure

rx-elf
  `- src
  |    `- binutils-2.23.1
  |    `- gcc-4.7.3
  |    `- newlib-2.0.0
  |    `- gdb-7.5
  |- build
  |    `- binutils
  |    `- gcc
  |    `- newlib
  |    `- gdb
   `- prefix

Local Variables

Where the toolchain is placed (you can modify $HOME/Documents/Dev):

PREFIX=$HOME/Documents/Dev/rx-elf/prefix

Where the downloaded source codes are placed (you can modify $HOME/Downloads):

DOWNLOADS=$HOME/Downloads

MThe target is Renesas RX:

TARGET=rx-elf

Where GMP/MPFR/MPC are installed (MacPorts install them to /opt/local):

GMP=/opt/local
MPFR=/opt/local
MPC=/opt/local

Building Steps

Creating directories and unarchive source codes.

mkdir -p $HOME/Documents/Dev/rx-elf
mkdir src build prefix
cd src
tar jxf $DOWNLOADS/newlib-2.0.0_rx_v13.01.tar.bz2
tar jxf $DOWNLOADS/binutils-2.23.1_rx_v13.01.tar.bz2
tar jxf $DOWNLOADS/gcc-4.7.3_rx_v13.01.tar.bz2
tar jxf $DOWNLOADS/gdb-7.5_rx_v13.01.tar.bz2
cd ../build
mkdir binutils gcc newlib gdb

Building binutils. You need to add the binutils binaries path to PATH.

cd binutils
../../src/binutils-2.23.1/configure --target=$TARGET --prefix=$PREFIX --disable-werror
make
make install
export PATH=$PREFIX/bin:$PATH

First trial for gcc building.

cd ../gcc
../../src/gcc-4.7.3/configure --enable-languages=c,c++ --target=$TARGET --with-newlib \
--prefix=$PREFIX --disable-libstdcxx-pch  --disable-multilib --with-newlib --disable-nls \
--disable-libgfortran --with-gmp=$GMP --with-mpfr=$MPFR --with-mpc=$MPC CC=gcc

CC=gcc is required as newlib tries to use rx-elf-cc to compile sources though it is missing.

make

Here, you'll get errors as follows (showing last 4 lines).

(snip)
checking for stdalign.h... no
checking for the value of EOF... configure: error: computing EOF failed
make[1]: *** [configure-target-libstdc++-v3] Error 1
make: *** [all] Error 2

However, ignore here and go next.

make install

Again, you'll get errors like this.

(snip)
make[2]: *** No rule to make target `install'.  Stop.
make[1]: *** [install-target-libstdc++-v3] Error 2
make: *** [install] Error 2

You can ignore them.

Building newlib.

cd ../newlib
../../src/newlib-2.0.0/configure --enable-newlib-hw-fp --target=$TARGET --prefix=$PREFIX CC=gcc
make
make install

Now return to gcc and the make commands will be successful this time.

cd ../gcc
make
make install

Finally, building gdb. This is not mandatory so you can skip it.

cd ../gdb
../../src/gdb-7.5/configure --target=$TARGET --prefix=$PREFIX --disable-werror
make
make install

comments powered by Disqus