LinuxGizmos.com Sponsor ads:

Building a gcc / glibc cross-toolchain for use in embedded systems development used to be a scary prospect, requiring iron will, days if not weeks of effort, lots of Unix and Gnu lore, and sometimes willingness to take dodgy shortcuts. This is a problem not only for individual users, but also for the gcc project as a whole, since the gcc team href=”http://gcc.gnu.org/ml/gcc/2003-07/msg01325.html”>relies on users to test upcoming releases of gcc, and the difficulty of building the toolchain for embedded targets restricted the number of people able to help with the testing.

At Ixia, I had been maintaining a toolchain by starting with a commercial free embedded linux toolchain, and overlaying it with newer versions compiled from scratch as needed to fix problems. This became harder to maintain as time went on.

After some months of frustration, it became clear we needed an easy way to build and test gcc/glibc cross-toolchains from scratch. Looking around, I realized that Bill Gatliff's crossgcc FAQ and build script, what most of the community used to build cross-compilers, was almost what I needed, so I rolled up my sleeves and:

made darn sure it worked properly for ppc and gcc-2.95

removed newlib support so I could focus on glibc more easily

updated it to handle gcc-3.2.x, gcc-3.3.x, and gcc-3.4.x, since I wasn't sure which of those I would need

enhanced it to automatically download the source tarballs and apply the minimal set of patches needed to successfully build

enhanced it to support all CPU types supported by glibc, since that was easy and was a good test of the script

added support for running the gcc and glibc regression test suites, since at Ixia we need regression tests for everything we ship

added support for building userspace (for now, just busybox) with the new toolchain (see –builduserspace option to all.sh) so you can test even if you don't have userspace apps compatible with the new toolchain

I call my updated script and associated patches 'crosstool'. It's fairly easy to use and can be run unattended as part of an automatic build process, and should go a long way towards making it easier for the average developer to get started with gcc cross-compilers and help test new releases of gcc.

The gcc-3.3.1/glibc-2.3.2 toolchains it generates for ppc405 and ppc750 pass nearly all gcc, glibc, and binutils regression tests.

About the authorDan Kegel is a software engineer currently helping develop network test equipment at Ixia. He has been programming since 1978, and mentoring intern programmers since 1994. He served on the JSR-51 committee which helped add nonblocking I/O and file locking to the Java platform. His web site “The C10K Problem“ is well-known among a small circle of internet server programmers, and his essay “The Case for Linux in Universities“ has been translated into Spanish, Hindi, and Telugu. He maintains lalugs.org as a service to the Los Angeles Linux community. He thanks his wife Liz Fuller for her support and patience during his periodic save-the-world quests, Ixia for supporting this work, Bill Gatliff for the original script, and Kaz Kojima and Daniel Jacobowitz for supplying patches on the spot to solve various problems.