If you wish to compile the CS toolchain of version 2008q3 on OS X (Lion in my case, but should work on other versions), please do follow these instructions.
Firstly download the source tarball from Mentor site.
This comes with a particularly useless build script: arm-2008q3-66-arm-none-eabi.sh
I have originally looked at J Snyder's makefile, but it did not seem to work out of the box, so I spent a day through trials and errors. I shall say a very big thanks to J Snyder for all the configuration options, however his build didn't work for the 2008q3 release that I needed. I guess if the reader came across these notes, they must have a reason for needing the 2008q3 release sepcifically.
The source distribution comes with all neccessary components, namelly:
arm-2008q3-66-arm-none-eabi/libiconv-2008q3-66.tar.bz2 arm-2008q3-66-arm-none-eabi/gdb-2008q3-66.tar.bz2 arm-2008q3-66-arm-none-eabi/gcc-2008q3-66.tar.bz2 arm-2008q3-66-arm-none-eabi/coreutils-2008q3-66.tar.bz2 arm-2008q3-66-arm-none-eabi/gnu-2008q3-66-arm-none-eabi.txt arm-2008q3-66-arm-none-eabi/arm-2008q3-66-arm-none-eabi.sh arm-2008q3-66-arm-none-eabi/mpfr-2008q3-66.tar.bz2 arm-2008q3-66-arm-none-eabi/gmp-2008q3-66.tar.bz2 arm-2008q3-66-arm-none-eabi/newlib-2008q3-66.tar.bz2 arm-2008q3-66-arm-none-eabi/make-2008q3-66.tar.bz2 arm-2008q3-66-arm-none-eabi/zlib-2008q3-66.tar.bz2 arm-2008q3-66-arm-none-eabi/binutils-2008q3-66.tar.bz2 arm-2008q3-66-arm-none-eabi/expat-2008q3-66.tar.bz2
It is best if you unpack the archives into
$INSTALL_PREFIX first, in my case:
setenv INSTALL_PREFIX /opt/devel/tools/cctc/vendor/cs/arm-2008q3 mkdir -p $INSTALL_PREFIX
I have had
gmp installed in
/opt/local and even trying to build
it from source was giving me a problem with
-m32 flag when I atemped to set
CFLAGS explicitly, it picked it up but still failed so I gave up and used
the working version I already had.
First step is to build binutils
cd build/binutils/ ../../binutils-*/configure --prefix=$INSTALL_PREFIX \ --target=arm-none-eabi --disable-nls --disable-werror make -j5 make install
The only little problem I've had was with compiling PDF documentation, which
I guess should be optional but on my system
autoconf seems to have detected
LaTeX installed, hence it attempted to make the PDFs but kept failing on
libiberty.pdf, however it had still written the file and hence second run
make install did the job.
Next, compile GCC without C++ support
The first stage compile passes just fine, provided you told it where to find
the dependencies, i.e.
cd build/gcc/ ../../source/gcc-*/configure \ --prefix=$INSTALL_PREFIX --target=arm-none-eabi --enable-languages="c" \ --without-gnu-ld --with-gnu-as --with-newlib --disable-nls --disable-libssp \ --with-newlib --without-headers --disable-shared --disable-threads \ --disable-libmudflap --disable-libgomp --disable-libstdcxx-pch \ --disable-libunwind-exceptions --disable-libffi \ --enable-extra-sgxxlite-multilibs --with-libiconv-prefix=/usr/ \ --with-gmp=/opt/local/usr/ --with-mpfr=/opt/local/usr/ make -j5 make install
In my case it did compile PDFs again, though I wish I could disable it somehow.
And again, I got an error on
libiberty.pdf, same thing - just
make install again.
Also, you can see that it has
--enable-extra-sgxxlite-multilibs, which is
quite likelly something that CS has given us ...
Now, compile Newlib
The only extra step here was to:
cd $INSTALL_PREFIX/bin/ ln -s arm-none-eabi-gcc arm-none-eabi-cc set path=($INSTALL_PREFIX/bin/ $path)
I suppose there is a way of fixing it by passing a paramer or whatever, but I couldn't bother since it works just fine this way.
If you use Bourne shell:
Done the above, you should be able to do:
cd build/newlib/ ../../source/newlib-*/configure --prefix=$INSTALL_PREFIX --target=arm-none-eabi \ --disable-newlib-supplied-syscalls --disable-libgloss --disable-nls --disable-shared env CFLAGS_FOR_TARGET="-ffunction-sections -fdata-sections -fomit-frame-pointer \ -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -Os -D__BUFSIZ__=256" \ make -j5 && make install
Nearly there, GCC with C++, featuring a fix-up
You will most likelly get this error:
ld: duplicate symbol _init_inline_once in libbackend.a(tree-inline.o) and tree-inline.o collect2: ld returned 1 exit status make: *** [cc1plus-dummy] Error 1 make: *** [all-stage2-gcc] Error 2 make: *** [stage2-bubble] Error 2 make: *** [all] Error 2
To fix it, just quickly edit
gcc-4.3/gcc/cp/Make-lang.in and on line 76
tree-inline.o because it is indeed already archived in
hence not required. This took a little while to figure, just because there are
quite a few layers of
autotools stuff, but it always helps to read error message
literarly, with no presumptions!
So now we can finally do it:
cd build/gcc/ ../../source/gcc-*/configure \ --prefix=$INSTALL_PREFIX --target=arm-none-eabi --enable-languages="c++" \ --without-gnu-ld --with-gnu-as --with-newlib --disable-nls --disable-libssp \ --with-newlib --without-headers --disable-shared --disable-threads \ --disable-libmudflap --disable-libgomp --disable-libstdcxx-pch \ --disable-libunwind-exceptions --disable-libffi \ --enable-extra-sgxxlite-multilibs --with-libiconv-prefix=/usr/ \ --with-gmp=/opt/local/usr/ --with-mpfr=/opt/local/usr/ make -j5 make install
Now, you will most likelly require GDB
cd build/gdb/ ../../source/gdb-*/configure --prefix=$INSTALL_PREFIX \ --target=arm-none-eabi --disable-werror && make -j5 && make install
The annoying LaTeX error still comes-up and make me think very hard why all of
these GNU packages come with their own copy of
I could have written this in a makefile or a shell script, but I have had experience using somebody else's makefile/script and these tend to fail on some oddly set-up systems (where my set-ups usually fall). So I opted to make this a human readable step-by setp how-to instead.