Building Tools
Contents |
This page describes how to build the RTEMS toolchain from sources. Some of the commands need to be tailored for your development host. These directions assume that you already have installed some of the prerequisite tools necessary to compile GCC from source, including gcc for your host. If you have not then building from source will die, but hopefully it will give you some hints about what you need to install. NOTE: the version of the tools to install depend on the target.
Start with a directory rtems/. Under that, create two directories: archive and tools.
Tools needed
You will need to download the tarballs of the RTEMS Build Toolset which includes the following:
- Binutils
- GCC (gcc-core)
- GCC (gcc-g++)
- GDB
- Newlib
- GMP (Multi-precision arithmetic library)
- MPC (Multi-precision complex floating-point library)
- MPFR (Multi-precision floating-point computation library)
You can find the above mentioned tarballs in http://www.rtems.org/ftp/pub/rtems/SOURCES/4.11/ and you should select the most recent versions for each. Save these in the archive directory. Once you're done with the downloading, the directory format should look like:
~$ find . ./archive ./archive/binutils-x.yy.tar.bz2 ./archive/binutils-x.yy-rtems4.11-YYYYMMDD.diff ./archive/gcc-x.y.z.tar.xz ./archive/gcc-x.y.z-rtems4.11-YYYYMMDD.diff ./archive/gdb-x.y.tar.bz2 ./archive/gdb-x.y-rtems4.11-YYYYMMDD.diff ./archive/newlib-x.yy.z.tar.gz ./archive/newlib-x.yy.z-rtems4.11-YYYYMMDD.diff ./tools
Unpack archives
Change directory to the tools directory.
~/tools$ tar xf ../archive/binutils*.tar.* ~/tools$ tar xf ../archive/gcc*.tar.* ~/tools$ tar xf ../archive/newlib*.tar.* ~/tools$ tar xf ../archive/gdb*.tar.*
Apply tool patches
The patches can be downloaded from http://www.rtems.org/ftp/pub/rtems/SOURCES/4.11/ for 4.11 version. You should find the most recent patches for each of the following:
binutils-x.yy.z-rtems4.11-YYYYMMDD.diff gcc-x.y.z-rtems4.11-YYYYMMDD.diff newlib-x.yy.z-rtems4.11-YYYYMMDD.diff
Make sure you check the modified date and pick up the most recent diff file.
Apply the patches, make sure you only have one binutils.diff, gcc.diff, and newlib.diff in the directory
~/tools$ cd binutils-x.yy/ ~/tools/binutils-x.yy$ cat ../../archive/binutils*.diff | patch -p1 --dry-run # optional ~/tools/binutils-x.yy$ cat ../../archive/binutils*.diff | patch -p1 # required ~/tools/binutils-x.yy$ cd ../gcc-x.y.z/ ~/tools/gcc-x.y.z$ cat ../../archive/gcc*.diff | patch -p1 --dry-run # optional ~/tools/gcc-x.y.z$ cat ../../archive/gcc*.diff | patch -p1 # required ~/tools/gcc-x.y.z$ cd ../newlib-x.yy.z/ ~/tools/newlib-x.y.z$ cat ../../archive/newlib*.diff | patch -p1 --dry-run # optional ~/tools/newlib-x.y.z$ cat ../../archive/newlib*.diff | patch -p1 # required ~/tools/newlib-x.y.z$ cd ../gdb-x.y ~/tools/gdb-x.y$ cat ../../archive/gdb*.diff | patch -p1 --dry-run # optional ~/tools/gdb-x.y$ cat ../../archive/gdb*.diff | patch -p1 # required ~/tools/gdb-x.y$ cd ..
At every step check for any errors.
configure and build binutils
See the SupportedCPUs page for the target mnemonics. The following uses ${TARGET}, which you can set by exporting a shell variable, for example
$ export TARGET=powerpc-rtems4.11
NOTE: if your shell doesn't support 'export', put powerpc-rtems4.11 (or m68k-rtems4.11, etc.) in instead of ${TARGET} when following these directions.
The usual prefix for RTEMS installations is --prefix=/opt/rtems-4.11
~/tools$ mkdir b-binutils
~/tools/binutils-x.yy$ cd b-binutils
~/tools/binutils-x.yy$ ../binutils-x.yy/configure --target=${TARGET} --prefix=/opt/rtems-4.11
~/tools/binutils-x.yy$ gmake all
~/tools/binutils-x.yy$ make info
~/tools/binutils-x.yy$ sudo gmake install
~/tools/binutils-x.yy$ cd ..
Now, set your path to include the just-built executables so that GCC will find them when compiling.
$ export PATH=/opt/rtems-4.11/bin:${PATH}
configure and build gcc
To build a usable GCC, you need a standard C library. RTEMS uses newlib (as opposed to glibc, or uclibc). Newlib is also packaged with libgloss, which RTEMS does not use, so symbolically link to the newlib directory in newlib-x.yy.z into gcc.
~/tools/b-binutils$ cd gcc-x.y.z/
~/tools/gcc-x.y.z$ ln -s ../newlibx.yy.z/newlib .
~/tools/gcc-x.y.z$ cd ..
~/tools$ mkdir b-gcc
~/tools$ cd b-gcc/
~/tools/b-gcc$ ../gcc-x.y.z/configure \
--target=${TARGET} \
--with-gnu-as --with-newlib \
--verbose \
--enable-threads \
--enable-languages="c,c++" \
--prefix=/opt/rtems-4.11
# Note: for FreeBSD it may be necessary to use --with-gmp=/usr/local
~/tools/b-gcc$ gmake all
~/tools/b-gcc$ gmake info
~/tools/b-gcc$ sudo gmake install
~/tools/b-gcc$ cd ..
configure and build gdb (optional)
For some configurations, it is necessary to specify extra options to configure to enable and configure option components such as a processor simulator. The following is a list of configurations for which there are extra options:
1. powerpc-rtems4.10
--enable-sim --enable-sim-powerpc --enable-sim-timebase --enable-sim-hardware
2. sparc-rtems4.10
--enable-sim
~/tools$ mkdir b-gdb
~/tools$ cd b-gdb/
~/tools/b-gdb$ ../gdb-x.y/configure \
--target=${TARGET} \
--prefix=/opt/rtems-4.11
~/tools/b-gdb$ gmake all
~/tools/b-gdb$ gmake info
~/tools/b-gdb$ sudo gmake install
~/tools/b-gdb$ cd ..
Done
Additional References
http://www.rtems.org/onlinedocs/releases/rtemsdocs-4.10.1/share/rtems/html/started/started00030.html http://wiki.osdev.org/GCC_Cross-Compiler