Building Toolchain

From wikiPodLinux

These are instructions for building the 3.4.3 Toolchain from source code. It has been tried on Cygwin though there is no guarantee that it will work. The toolchain compiling process is a very long one and prone to problems. It is recommended that you instead use pre-built toolchains unless you have a good reason to. If you want to build the 2.95.3 toolchain, old instructions can be found here. Keep in mind that the toolchain is being built for your computer and thus you should have gcc and a good development environment installed. At the moment, only the C and C++ languages are supported; if you manage to successfully build gcc with other languages enabled, please update this page with instructions.


Table of contents


Downloading source code

To build the toolchain, there is a long list of files that you will need to download (and thus a lot of free space on your hard-drive). All these files need to be placed into one convenient directory (e.g. ~/toolchain). The files needed and their download locations are as followed:

http://so2.sys-techs.com/ipod/
  • build-uclinux-tools.sh
http://so2.sys-techs.com/ipod/toolchain/linux-x86/
  • libintl.a
http://ftp.gnu.org/gnu/gcc/gcc-3.4.3/
  • gcc-3.4.3.tar.bz2
http://www.uclinux.org/pub/uClinux/m68k-elf-tools/gcc-3/uclinux-tools-20050221/
  • binutils-2.15.94.0.1.tar.bz2
  • build-uclinux-tools.sh
  • elf2flt-20041205.tar.bz2
  • elf2flt-cygwin.patch
  • gcc-3.4.0-m68k_save_reg-id_shared_library.patch
  • gcc-3.4.0-t-uclinux-elf.patch
  • gcc-3.4.1-addsi3_5200.patch
  • gcc-3.4.3-arm-deflibspec.patch
  • gcc-3.4.3-arm-multilib.patch
  • gcc-3.4.3.tar.bz2
  • gdb-5.3.tar.bz2
  • gdb-5.3-cygwin-ncurses.patch
  • genromfs-0.5.1.tar.gz
  • genromfs-0.5.1-cygwin-020605.patch
  • m68k-bdm-1.3.1.tar.bz2
  • uClibc-0.9.26-arm.config
  • uClibc-0.9.26-exec_alloc.patch
  • uClibc-0.9.26-isabus.patch
  • uClibc-0.9.26-m68k.config
  • uClibc-0.9.26-ptrace-lvalue.patch
  • uClibc-0.9.26-syscalls-inline.patch
  • uClibc-0.9.26.tar.bz2
  • uClibc-arm.patch


Building the toolchain

The script used to build the toolchain is the 'build-uclinux-tools.sh' script. By default, compiled files get saved to '/usr/local/arm-uclinux-tools' (if you want to have the toolchain installed elsewhere, edit the 'PREFIX=' line of the script). Toolchain building is a long and tedious task that could take over half an hour depending on your computer. Luckily, the toolchain is built in "stages" and you can continue progress throughout these stages.


1. Building the Kernel.

Building the toolchain requires quite a few header files from the kernel. As a result, before you build the toolchain you must also build the 2.4 kernel. Follow the instructions for Kernel Building up til the 'make dep' step. In the directory containing all the downloaded files, make a folder named "uclinux" and place the kernel's "2.4.24" folder in the "uclinux" folder.


2. Start the compiling script.

'cd' to the directory containing the downloaded files and type:
./build-uclinux-tools.sh continue
Assuming you're not missing any files (for which you will be notified if you are), the script will extract the downloaded archives and do the patching as the build process goes along, which it will for a long long time.


3. Fixing gdb.

Assuming that your development environment is using a somewhat recent 'gcc', your first build attempt will fail with a 'gdb/arm-tdep.c:2754: error: label at end of compound statement' error. Fixing this issue is just a few steps. With a text editor, open up 'gdb-5.3/gdb/alpha-tdep.c'. Search for the keyword "default:" and add a "break;" line to the end of all the "default:" cases without a "break;". Then type './build-uclinux-tools.sh continue' and watch it go again. Assuming you're still not missing any of the downloaded files and your compiling environment has all the libraries needed, you're free to leave your computer for half an hour or so to go drink tea, read a book, or play games (or just wait in front of your computer staring). If you're lucky, you will come back to see the wonderful phrase "Build successful !". If you browse to the '/usr/local/' directory, you will see the new directory '/usr/local/arm-uclinux-tools' (if you didn't alter the script) containing a 'arm-uclinux-elf' directory, a 'bin' directory, an 'include' directory, etc.


4. Test out the toolchain.

The first thing you need to do is make sure the toolchain binaries are accessible to the shell. Type:
export PATH=/usr/local/arm-uclinux-tools/bin:$PATH'
Remember that every time you open up a new shell/terminal/command prompt you will need to type that, so memorize it! To make sure you have the toolchain installed correctly, type 'arm-uclinux-elf-gcc --version'. If you followed through all these instructions properly, you should receive a nice printout telling you that the toolchain's version is 3.4.3.


Congratulations, you just compiled the 3.4.3 toolchain from scratch! But wait, there's still one last small thing you need to do...


Building libintl

You're done compiling the toolchain (phew!) but you're still missing one last thing: libintl (which is used by things like podzilla). You have two choices here: build libintl from source code or use a precompiled one (http://so2.sys-techs.com/ipod/toolchain/linux-x86/libintl.a). Lets assume you also decide to build it from scratch.


1. Download the source code.

Download and extract the latest gettext (http://www.gnu.org/software/gettext/) source code. At the time of writing this tutorial, gettext-0.17.tar.gz (ftp://mirrors.kernel.org/gnu/gettext/gettext-0.17.tar.gz) was used.


2. gettext-runtime only.

Rather than building all of gettext, we only want the libintl runtime library. 'cd' to the gettext's 'gettext-runtime' directory.


3. Export the path.

Like in the previous section, to use your newly compiled toolchain, type:
export PATH=/usr/local/arm-uclinux-tools/bin:$PATH


4. Configure and build.

To configure gettext-runtime for the iPod, type:
./configure CC=arm-uclinux-elf-gcc LDFLAGS=-elf2flt --host=arm-elf
To then build it, type:
make


5. Copying over libintl.a.

Building gettext-runtime is expected to fail partway. Lucky for us, libintl gets compiled before this failure. The compiled libintl library will be found in 'gettext-runtime/intl/.libs/libintl.a'. Copy that file to '/usr/local/arm-uclinux-tools/arm-uclinux-elf/lib/libintl.a'.


Congratulations! Now that you have an iPodLinux lean, mean, cross-compiling machine, it's time you get crackin'!


Thanks

  • courtc - Maintainer of the current Toolchains
  • Keripo - Writer of this tutorial/instructions page
  • uClinux Dev Team (http://www.uclinux.org/pub/uClinux/uclinux-elf-tools/gcc-3/) - Making gcc work for uClinux
  • GCC Dev Team (http://gcc.gnu.org/) - Making and maintaining the GNU Compiler Collection (gcc)
Navigation



  • Google Search (http://www.google.com/custom?sa=Google+Search&cof=S%3Ahttp%3A%2F%2Fwww.ipodlinux.org%3BVLC%3Apurple%3BAH%3Acenter%3BBGC%3Awhite%3BLH%3A141%3BLC%3Ablue%3BL%3Ahttp%3A%2F%2Fipodlinux.org%2Fstylesheets%2Fimages%2Fwiki.png%3BALC%3Ablue%3BLW%3A128%3BT%3Ablack%3BAWFID%3A70a74ab66f4d59ae%3B&domains=ipodlinux.org&sitesearch=ipodlinux.org)