How to build the RX Toolchain under Ubuntu 14.04
Steps for building the RX Toolchain under a fresh Ubuntu 14.04 installation:
This applies to the RX toolchain v15.02
- Run the followings commands before you start:
sudo apt-get install build-essential sudo apt-get update sudo apt-get upgrade sudo apt-get install flex bison texinfo libncurses5-dev
1) Create a new folder for the toolchain
$ mkdir RX-Toolchain
2) Change the current directory to RX-Toolchain
$ cd RX-Toolchain
3) Create 3 new folders : source, build, prefix
$ mkdir source $ mkdir build $ mkdir prefix
4) Download the source codes for Binutils-RX_V15.02, Newlib-RX_V15.02, GCC-RX_V15.02, GDB-RX_V15.01 from :
-GDB: https://gcc-renesas.com/downloads/d.php?f=rx/gdb/15.01/gdb-7.8.2_rx_v15.01.tar.bz2
-Binutils: https://gcc-renesas.com/downloads/d.php?f=rx/binutils/15.02/binutils-2.24_rx_v15.02.tar.bz2
-Newlib: https://gcc-renesas.com/downloads/d.php?f=rx/newlib/15.02/newlib-2.2.0_rx_v15.02.tar.bz2
-GCC: https://gcc-renesas.com/downloads/d.php?f=rx/gcc/15.02/gcc-4.8.4_rx_v15.02.tar.bz2
5) Copy the archive in the source folder that you previously created:
$ cp /home/<username>/Downloads/gdb-7.8.2_rx_v15.01.tar.bz2 source $ cp /home/<username>/Downloads/binutils-2.24_rx_v15.02.tar.bz2 source $ cp /home/<username>/Downloads/newlib-2.2.0_rx_v15.02.tar.bz2 source $ cp /home/<username>/Downloads/gcc-4.8.4_rx_v15.02.tar.bz2 source
- Assuming that Downloads is you default download folder.If not you have to put the path to the location where the files were downloaded.
6) Change the current directory and extract the archives:
$ cd source $ tar -jxvf gdb-7.8.2_rx_v15.01.tar.bz2 $ tar -jxvf binutils-2.24_rx_v15.02.tar.bz2 $ tar -jxvf newlib-2.2.0_rx_v15.02.tar.bz2 $ tar -jxvf gcc-4.8.4_rx_v15.02.tar.bz2
7) INSTALL BINUTILS-RX_V15.02
a) Create a new folder for binutils and change the current directory to it:
$ cd ../build $ mkdir binutils $ cd binutils
b) Build and make:
- Pay attention please: after you begin to run the next command you maybe will get an error when you build Newlib (in the bottom of the page when you run sudo make) as:
https://gcc-renesas.com/wiki/index.php?title=File:Newlib_error.jpg
To solve this you will have to run the next command without prefix ($ /home/<username>/RX-Toolchain/source/binutils-2.24/configure --target=rx-elf --enable-maintainer-mode --disable-werror).
$ /home/<username>/RX-Toolchain/source/binutils-2.24/configure --target=rx-elf --prefix=/home/<username>/RX-Toolchain/prefix/ --enable-maintainer-mode --disable-werror $ make $ make install
If you get a permission denied error try
$ sudo make $ sudo make install
c) Return to the build directory
$ cd ..
d) Export path
$ export PATH="/home/<username>/RX-Toolchain/prefix/bin:$PATH"
8) INSTALL GCC-RX-V15.02
a) Change the current directory to GCC source folder and run the following command :
$ cd ../source/gcc-4.8.4 $ ./contrib/download_prerequisites
If for some reason MPC,MPFR and GMP is not downloaded automatically when running the command ./contrib/download_prerequisites you have to download them manually and move the packages into GCC source folder. To do that follow the steps, and then continue from b):
- Download the source code for GMP,MPFR,MPC:
https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2
ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.2.tar.gz
http://www.mpfr.org/mpfr-current/mpfr-3.1.4.tar.bz2
- Copy the packages into GCC source folder
$ cd .. $ cp ~/Downloads/gmp-6.1.0.tar.bz2 gcc-4.8.4 $ cp ~/Downloads/mpfr-3.1.4.tar.bz2 gcc-4.8.4 $ cp ~/Downloads/mpc-1.0.2.tar.gz gcc-4.8.4
- Extract the packages :
$ cd gcc-4.8.4 $ tar -jxvf gmp-6.1.0.tar.bz2 $ tar -jxvf mpfr-3.1.4.tar.bz2 $ tar -zxvf mpc-1.0.2.tar.gz
- Rename GMP,MPFR,MPC folders
$ mv gmp-6.1.0 gmp $ mv mpfr-3.1.4 mpfr $ mv mpc-1.0.2 mpc
b) Return to the build directory:
$ cd ../../build
c) Create a new folder for gcc and change the current directory to it:
$ mkdir gcc $ cd gcc
d) Build and make:
- Pay attention please: after you begin to run the next command you maybe will get an error when you build Newlib (in the bottom of the page when you run sudo make) as:
https://gcc-renesas.com/wiki/index.php?title=File:Newlib_error.jpg
To solve this you will have to run the next command without prefix ($ /home/<username>/RX-Toolchain/source/gcc-4.8.4/configure --target=rx-elf --enable-languages=c,c++ --disable-shared --with-newlib --enable-lto --enable-gold --disable-libstdcxx-pch --with-pkgversion=GCC_Build_1.02).
$ /home/<username>/RX-Toolchain/source/gcc-4.8.4/configure --target=rx-elf --prefix=/home/<username>/RX-Toolchain/prefix/ --enable-languages=c,c++ --disable-shared --with-newlib --enable-lto --enable-gold --disable-libstdcxx-pch --with-pkgversion=GCC_Build_1.02 $ sudo make all-gcc $ sudo make install-gcc
If you get a permission denied error try
$ sudo make all-gcc $ sudo make install-gcc
e) Return to the build directory
$ cd ..
f) Export path
$ export PATH="/home/<username>/RX-Toolchain/prefix/bin:$PATH"
9) INSTALL Newlib-RX_V15.02
OBS: Build Newlib only after you built Binutils and GCC.
a) Create a new folder for newlib and change the current directory to it:
$ mkdir newlib $ cd newlib
b) Build and make :
- Pay attention please: after you begin to run the next command you maybe will get an error when you build Newlib (at this section when you run sudo make) as:
https://gcc-renesas.com/wiki/index.php?title=File:Newlib_error.jpg
To solve this you will have to run the next command without prefix ($ /home/<username>/RX-Toolchain/source/newlib-2.2.0/configure --target=rx-elf):
$ /home/<username>/RX-Toolchain/source/newlib-2.2.0/configure --target=rx-elf --prefix=/home/<username>/RX-Toolchain/prefix/ $ make $ make install
If you get a permission denied error try
$ sudo make $ sudo make install
10) INSTALL GDB-RX_V15.01 OBS : You need GCC-4.9+ for the compilation to be successful.
To install gcc-4.9.1 follow the steps from the wiki:
https://cyberthorstudios.com/wiki/index.php?title=Build_GCC-4.9.1_under_Ubuntu_14.04
You will have to apply 2 patches and change the permissions for two files for the compilation to work.Follow the next steps to do that:
a) Run the following commands:
$ cd $ cd RX-Toolchain/source/gdb-7.8.2 $ sudo chmod a+x -R configure $ sudo chmod a+x -R mkinstalldirs $ cd gdb $ sudo chmod a+x -R observer.sh
b) Download the patches:
[c_exp_128bit_.patch[1]]
[c_exp_128bit_1050_updated_.patch[2]]
c) Apply the patches:
$ patch -R < /home/<username>/Downloads/c_exp_128bit_.patch $ patch < /home/<username>/Downloads/c_exp_128bit_1050_updated_.patch
- Assuming that Downloads is your default download folder.If not your path will change and instead of /home/<username>/Downloads you have to put the path to the folder where the patches were downloaded.
d) Return to source folder
$ cd ../..
e) Change the current directory to build and create a new folder for gdb:
$ cd ../build $ mkdir gdb
f) Change the current directory to the gdb folder that you previously created:
$ cd gdb
g) Build and make:
- Pay attention please: after you begin to run the next command you maybe will get an error when you build Newlib (in the bottom of the page when you run sudo make) as:
https://gcc-renesas.com/wiki/index.php?title=File:Newlib_error.jpg
To solve this you will have to run the next command without prefix ($ /home/<username>/RX-Toolchain/source/gdb-7.8.2/configure --target=rx-elf):
$ /home/<username>/RX-Toolchain/source/gdb-7.8.2/configure --target=rx-elf --prefix=/home/<username>/RX-Toolchain/prefix/ $ sudo make $ sudo make install
h) Return to the build directory
$ cd ..
11) Build final GCC
a) Change the current directory to gcc:
$ cd gcc
b) Build :
$ make $ make install
If you get a permission denied error try
$ sudo make $ sudo make install
OBSERVATIONS:
- /home/<username>/gcc/gcc-4.8.4 is the path to your gcc folder;
- if you save your gcc folder(the one in which you copy the archive) in another location than the default one your path will change;
- the configure command must end with gcc-version/configure;
- /home/<username>/newlib/newlib-2.2.0 is the path to your newlib folder;
- if you save your newlib folder(the one in which you copy the archive) in another location than the default one your path will change;
- the configure command must end with newlib-version/configure;
- /home/<username>/binutils/binutils-2.24 is the path to your configure file. binutils-2.24 is the folder that was created after extracting the package.If your folder has a different name your path will become: /home/<username>/binutils/folderName;
- If you save your binutils folder(the one in which you copy the archive) in another location than the default one your path will change;
- /home/<username>/rx/gdb-7.8.2 is the path to your rx folder;
- if you save your rx folder(the one in which you copy the archive) in another location than the default one your path will change;
- the configure command must end with rx-version/configure;
If one of this errors occurs :
1./usr/local/bin/ld - this linker was not configured to use sysroots collect2: error: ld returned 1 exit status 2.configure: error: '/home/<username>/gdb/build' : configure: error: C compiler cannot create executables
You will have to remove ld file from /usr/local/bin following the steps and then configure and make again:
1. $ cd /usr/local/bin 2. $ rm -f ld 3. $ cd /home/<username>/RX-Toolchain/build