export target=arm-elf
export tools=$HOME/Dev_UW/EmbSys/Tools
export prefix=$tools/$target
export PATH=$prefix/bin:$PATH
cd $tools
mkdir Sources
cd Sources
$ curl -O ftp://gcc.gnu.org/pub/binutils/releases/binutils-2.20.tar.bz2
$ curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.5.1/gcc-core-4.5.1.tar.bz2
$ curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.5.1/gcc-g++-4.5.1.tar.bz2
$ curl -O ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
$ curl -O ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
$ curl -O ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
$ curl -O ftp://sourceware.org/pub/gdb/releases/gdb-7.2.tar.bz2
$ curl -O ftp://sources.redhat.com/pub/newlib/newlib-1.18.0.tar.gz
$ tar -xjf binutils-2.20.tar.bz2
$ tar -xjf gcc-core-4.5.1.tar.bz2
$ tar -xjf gcc-g++-4.5.1.tar.bz2
$ tar -xjf gmp-4.3.2.tar.bz2
$ tar -xjf mpc-0.8.1.tar.gz
$ tar -xjf mpfr-2.4.2.tar.bz2
$ tar -xjf gdb-7.2.tar.bz2
$ tar -xzf newlib-1.18.0.tar.gz
GNU binutils is a collection of binary tools, which needs to be build first. As with all parts of the toolchain, we create a specific build directory inside the package’s directory.
$ cd $tools/Sources/binutils-2.18
$ mkdir build-$target
$ cd build-$target/
$ ../configure --target=$target --prefix=$prefix --enable-interwork --enable-multilib \
--disable-nls --disable-shared --disable-threads --with-gcc --with-gnu-as --with-gnu-ld
$ make
$ sudo make install
$ cd ../..
To check the ARM variant.
$ arm-elf-as --version
The ARM compiler build is a two pass build. First we build just gcc using the headers from newlib. That gives us an arm-elf compiler. We then build newlib with the arm-elf compiler, which will give us c runtime binaries built for ARM. Then we can build the rest of the gcc sources using the ARM runtime binaries.
The GCC build requires gmp, mpc, mpfr. The easiest way to add them to the build is to move their source distributions into the gcc tree. The build also requires newlib.
Moving the required libraries into gcc-4.5.1 and renaming them:
$ cd $tools/Sources
mv gmp-4.3.2 gcc-4.5.1/gmp
mv mpc-0.8.1 gcc-4.5.1/mpc
mv mpfr-2.4.2 gcc-4.5.1/mpfr
Renaming newlib:
mv newlib-1.18.0 newlib
GNU Multiple Precision library. Download, uncompress, and copy it into the top level of the gcc directory as gmp. Or use –with-gmp, –with-gmp-lib and –with-gmp-include configure options with gcc.
C library for multiple-precision floating-point computations. Download, uncompress, and copy it into the top level of the gcc directory as mpfr. Or use –with-mpfr, –with-mpfr-lib and –with-mpfr-include configure options with gcc.
C library for the arithmetic of complex numbers. Download, uncompress, and copy it into the top level of the gcc directory as mpfr. Or use –with-mpc, –with-mpc-lib and –with-mpc-include configure options with gcc.
C runtime library. Download, uncompress and use –with-headers to set the path to its includes in the configure options with gcc.
cd $tools/gcc-4.5.1
mddir build-$target
cd build-$target
../configure --target=$target --prefix=$prefix \
--disable-nls --disable-shared --disable-threads \
--with-gcc --with-gnu-ld --with-gnu-as --with-dwarf2 \
--enable-languages=c,c++ --enable-interwork \
--enable-multilib --with-newlib \
--with-headers=../../newlib/newlib/libc/include \
--disable-libssp --disable-libstdcxx-pch \
--disable-libmudflap --disable-libgomp -v
First just build gcc itself. That will give us an arm compiler which we will use to build the runtime. Then with a built runtime we can rebuild all of the sources in gcc.
make all-gcc
make install-gcc
$ cd $tools/newlib
$ mkdir build-$target
$ cd build-$target/
$ ../configure --target=$target --prefix=$prefix --enable-interwork --enable-multilib
$ make
$ sudo make install
$ cd ../..
Build the gdb debugger.
$ cd $tools/gdb-7.2
$ mkdir build-$target
$ cd build-$target/
$ ../configure --target=$target --prefix=$prefix --disable-nls
$ sudo make install
$ cd ../..
In an additional step we may strip the installed binaries to save disk space and decrease load times.
$ sudo strip $prefix/bin/*
$ sudo strip $prefix/$target/bin/*
$ sudo strip $prefix/libexec/gcc/$target/4.2.2/*