When I first started to build my own cross-compiler and my own toolchain, I didn’t think that it was so delicate. It took me almost two weeks to have it working, always fighting quite cryptical errors that could be solved with very unevident switches. Lots of thanks go to Simon Richter and Rob Landley for their help, among many others. I wouldn’t have done it without them.
What you need:
- A C compiler (gcc is a good idea)
- Source for gcc, binutils, uclibc (or any other standard C library, such as glibc, eglibc or dietlibc) and linux headers
Steps:
- Build binutils
- Build a first stage GCC (bootstrap compiler), without any dependency on the standard C library. You need the standard C library to build the compiler, but you cannot build the C library without it. It’s the new-age version of the tradictional chicken-and-egg problem.
- Obtain the operating system headers
- Build uclibc with the bootstrap compiler
- Build the final GCC
Links:
- EGLIBC mailing lists: Cross-Compiling EGLIBC, by Jim Blandy
- IBM developerWorks: 17-page tutorial on building a cross compiler for Linux
- GCC Wiki: Building Cross Toolchains with gcc
- Firmware Linux, by Rob Landley
- Buildroot: set of Makefiles and patches that makes it easy generate a cross-compilation toolchain and root filesystem
- OS Dev: GCC Cross-Compiler
- Building the AVR32 Linux Toolchain
- Linux from scratch
You can download my script for building the compiler if you want. Feedback is welcome.

Leave a Reply