If you google around, there are some guides on building gcc for RX, but none of them is really concise. So here you go.
With this method I was able to compile a toolchain for RX on Mac OS 10.8.2.
This post for Linux on the Renesas forums basically includes everything mentioned here, but with a lot of overhead and not very well formatted, however head there if you want some more explanations on the options used. Also thanks to Andy K. who helped me troubleshooting.
Download and extract the following sources. (In brackets is the version I used for this, other versions will probably work as well.)
For every tool, create a build directory named rx-xxx
. After that you should have a directory structure like this:
~/Desktop/rx-elf/
binutils-x.x.x/
gcc-x.x.x/
gmp-x.x.x/
mpc-x.x/
mpfr-x.x.x/
newlib-x.x.x/
rx-binutils/
rx-gcc/
rx-gmp/
rx-mpc/
rx-mpfr/
rx-newlib/
- For
$MYPREFIX
I used/usr/local/rx-elf
, but use whatever suits yourself. This is where the finished builds will be installed. - I use
make -j4
instead of a simplemake
to speed up making on a multicore / hyperthreaded CPU (which most Macs have). - If you don't have
gcc
to start with, check out this guide on installing gcc on Mac OS.
cd rx-binutils
../binutils-x.x.x/configure --prefix=$MYPREFIX --target=rx-elf
make -j4
make install
cd rx-gmp
../gmp-x.x.x/configure --prefix=$MYPREFIX --disable-werror
make
make install
cd rx-mpfr
../mpfr-x.x.x/configure --disable-shared --with-gmp=$MYPREFIX --prefix=$MYPREFIX
make
make install
cd rx-mpc
../mpc-x.x.x/configure --disable-shared --with-gmp=$MYPREFIX --with-mpfr=$MYPREFIX --prefix=$MYPREFIX
make
make install
cd rx-gcc
../gcc-x.x.x/configure --prefix=$MYPREFIX --target=rx-elf --enable-languages=c,c++ --with-newlib --with-gmp=$MYPREFIX --with-mpfr=$MYPREFIX --with-mpc=$MYPREFIX
make -j4
make install
Make will stop with an error at some point, this is expected as we haven't built newlib yet.
For subsequent Makes we need parts already built, so if your $MYPREFIX isn't inside your $PATH, you should do something like this now:
export PATH = $MYPREFIX:$PATH
(e.g. export PATH = /usr/local/rx-elf:$PATH)
You might need to apply this patch to newlib before building. For me the patch didn't work out of the box, so I just edited the mentioned file manually. It's only one line that's changed anyway.
After that, do:
cd rx-newlib
../newlib-x.x/configure --prefix=$MYPREFIX --target=rx-elf --enable-languages=c,c++ --with-newlib
make -j4
make install
The guide mentioned at the top just tells to re-start making of gcc, however this didn't work for me. I started building gcc from scratch, so:
rm -rf rx-gcc
mkdir rx-gcc; cd rx-gcc
../gcc-x.x.x/configure --prefix=$MYPREFIX --target=rx-elf --enable-languages=c,c++ --with-newlib --with-gmp=$MYPREFIX --with-mpfr=$MYPREFIX --with-mpc=$MYPREFIX
make -j4
make install
And that's it! Sometimes make
would fail for me at some point, but work as expected if started again.
If you happen to have the GR-Sakura board, head over to Andy's repo for some test code and Makefile.
If you experienced any difficulties, please tell me so I can amend this guide.