This tutorial is based on a German article. Please note, that I had to install various packages on my Ubuntu workstation.
sudo apt-get install texi2html make-doc texinfo bison flex byacc libgmpada1-dev gnat-4.4 gnat-4.4-base libgmpada1 libgnat-4.4 libgnatprj4.4 libgnatvsn4.4 sudo apt-get install libmpfr-dev libmpc-dev libgmp3-dev libgmpxx4ldbl libmpc2
Get the latest binutils (password is anoncvs)
cd ~/repo/binutils
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils
Compile binutils
cd ~/repo/binutils/src
./configure --prefix=/usr/local/toolchain --target=arm-elf
make all
sudo make install
I ran into some errors “XY has changed since the previous run:” and was not able to fix it. Neither make clean nor make distclean were of any help. However, a clean checkout from the CVS did the trick. Looks like the Makefile is broken.
Get the latest gcc from the repository
cd ~/repo/gcc
svn checkout svn://gcc.gnu.org/svn/gcc/trunk
Get the latest newlib (password is anoncvs)
cd ~/repo/newlib
cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src login
cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src co newlib
Lets’ compile a bootstrap gcc. Please mind, we actually do not compile gcc within the src or trunk folder. It does not seem to like it.
cd ~/repo/gcc/trunk
ln -s ~/repo/newlib/src/newlib newlib
ln -s ~/repo/newlib/src/libgloss libgloss
mkdir -p ~/repo/gcc/build
cd ~/repo/gcc/build
../trunk/configure --target=arm-elf --enable-languages=c --disable-nls --disable-shared --disable-threads --with-newlib --prefix=/usr/local/toolchain --with-gnu-as --with-gnu-ld --disable-multilib --disable-libssp --disable-libmudflap --disable-libgomp --with-dwarf2 --with-newlib -v --disable-werror --with-cpu=cortex-m3 --with-tune=cortex-m3 --with-mode=thumb --enable-target-optspace --with-float=soft --enable-languages=c,c++ --without-headers --with-local-prefix=/usr/local/toolchain/arm-elf
make all-gcc
Go get a coffe… it will take some time. Afterwards, install gcc within the toolchain folder.
sudo make install-gcc
export PATH=$PATH:/usr/local/toolchain/bin
gcc-arm-elf --version
You hopefully got the version displayed. Let’s compile newlib
cd ~/repo/newlib/src
./configure --with-newlib --disable-newlib-io-float --disable-newlib-supplied-syscalls --prefix=/usr/local/toolchain --target=arm-elf
make all
sudo PATH=$PATH:/usr/local/toolchain/bin make install
Finally go back to gcc and continue make
cd ~/repo/gcc/build
make all
sudo make install
I ran into troubles during “make all”. The gcc trunk does have an issue with lib1funcs.asm which breaks the build process. However, the mail archive on gcc and the gcc bugzilla led me to the right patch
http://www.mail-archive.com/gcc-bugs@gcc.gnu.org/msg288759.html
http://gcc.gnu.org/bugzilla/attachment.cgi?id=21475&action=view
Hope, this would be of help for some other embedded freaks