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
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.
This article discusses one possible approach to solving this problem.
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
- documented how to run dejagnu regression tests remotely, since that's how to test gcc on a small embedded platform, and the dejanu documentation is misleading and incomplete
- documented how to set up a chroot jail that allows remote login, since a chroot jail is the easiest way to test alternate versions of glibc, and there weren't any good howto's on the subject
- 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 toolchain it generates for sh4 fails a noticable number of the glibc tests, but is far enough along that you can try it, if you're willing to look into the problems.
The gcc-3.4-20030813 snapshot toolchains for these processors fail with several internal compiler errors building the regression tests, which is not suprising given that gcc-3.4 is still in stage 2.
- crosstool-0.22.tar.gz (tarball)
- current version (individual files)
- crosstool-howto.html — read this first
- Test Summaries for various versions of gcc and glibc on ppc405, ppc750, and sh4
About the author
Dan 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.
Last Change 26 Aug 2003. The latest copy of this document can be found at kegel.com/crosstool. Copyright © 2003 Dan Kegel, with portions copyright by Ixia, 2003. All rights reserved. Reproduced by LinuxDevices.com with permission of the author. Crosstool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This article was originally published on LinuxDevices and has been donated to the open source community by QuinStreet Inc. Please visit LinuxToday.com for up-to-date news and articles about Linux and open source.