Build gcc for ARM Cortex processor

I have lately built several versions of the Linux GCC tool chain for the ARM Cortex processor. But the generated tools do not work properly with floating point, issuing errors about floating point inconsistencies. One option is of course to download a free version of a commercial tool, like the one from http://www.codesourcery.com/sgpp. But I didn’t want to give up on this. Today I gave it a new try using the script by Uwe Hermann http://www.hermann-uwe.de /blog/building-an-arm-cross-toolchain\ -with-binutils-gcc-newlib-and-gdb-from-source with options from esden: http://www.esden.net/blog/2009/02/26/how-to-build-arm-gnu-gcc-\
toolchain-for-mac-os-x/
The resulting script file:

#!/bin/sh# Written by Uwe Hermann, released as public domain.

TARGET=arm-none-eabi    # Or: TARGET=arm-none-eabi
PREFIX=/opt/arm-cortex # Install location of your final toolchain
PARALLEL="-j 2"    # Or: PARALLEL=""

BINUTILS=binutils-2.19.1
GCC=gcc-4.3.3
NEWLIB=newlib-1.17.0
GDB=gdb-6.8

export PATH="$PATH:$PREFIX/bin"

mkdir build

wget -c http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2
tar xfvj $BINUTILS.tar.bz2
cd build
../$BINUTILS/configure --target=$TARGET --prefix=$PREFIX --enable-interwork \
--enable-multilib --with-gnu-as --with-gnu-ld --disable-nlsmake $PARALLEL
make install
cd ..
rm -rf build/*

wget -c ftp://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.bz2
tar xfvj $GCC.tar.bz2
cd build
../$GCC/configure --with-libiconv-prefix=/opt/local --target=$TARGET --prefix=$PREFIX \
--enable-interwork --enable-multilib --enable-languages="c" --with-newlib \
--without-headers --disable-shared --with-gnu-as --with-gnu-ld --with-gmp=/opt/local \
--with-mpfr=/opt/local
make $PARALLEL all-gccmake install-gcc
cd ..
rm -rf build/*

wget -c ftp://sources.redhat.com/pub/newlib/$NEWLIB.tar.gz
tar xfvz $NEWLIB.tar.gz
cd build
../$NEWLIB/configure --target=$TARGET --prefix=$PREFIX --enable-interwork \
--enable-multilib  --with-gnu-as --with-gnu-ld --disable-nlsmake $PARALLEL
make install
cd ..
rm -rf build/*

# Yes, you need to build gcc again!
cd build
../$GCC/configure --with-libiconv-prefix=/opt/local --target=$TARGET \
--prefix=$PREFIX --enable-interwork --enable-multilib --enable-languages="c" \
--with-newlib --disable-shared --with-gnu-as --with-gnu-ld--with-gmp=/opt/local \
--with-mpfr=/opt/localmake $PARALLEL
make install
cd ..
rm -rf build/*

Before running this script you may

sudo mkdir /opt/arm-cortex
sudo mkdir /opt/local
sudo chmod a+rwx /opt/arm-cortex
sudo chmod a+rwx /opt/local

Then the tools will be installed while running the script as a common user. After installation you may of course chmod the directories and files recurcively to reasonable values. Now I can compile the Luminary Stellaris source code without any error message.

1 Response to “Build gcc for ARM Cortex processor”


  • Thanks for this – came in very handy to help me start working with Stellaris on Ubuntu.

Leave a Reply