Building a crosscompiling toolchain with gcc3
This document is out of date. See kegel.com/crosstool for
my latest attempt. (Some of the ppc405 stuff on this page may still be useful, though.)
We looked, but could find no fully debugged script to build a complete
toolchain (binutils, gcc3, and glibc) for crosscompiling for SH4, PPC405, and PPC750 targets.
So we wrote one, with lots of help from
Bill Gatliff's documentation.
Here's roughly how build-all.sh works. (We have full kernel sources around, so we lazily
use them rather than extracting just the kernel headers. Apologies.)
- Configure a kernel for the arch; install the kernel headers
- Build and install binutils
- Build and install a bootstrap gcc (consisting only of the gcc compiler)
- Using the new bootstrap compiler, build and install glibc
- Using the new glibc, build and install a complete gcc (gcc,g++,etc.)
With minor differences (see the script) the above works for SH4. For PPC,
there are a few additional hoops to jump through:
- Configure a kernel for the arch; install the kernel headers
- Build and install binutils
- Install the glibc headers
- Generate and install glibc's gnu/stubs.h
- Build and install a bootstrap gcc (consisting only of the gcc compiler)
- Using the new bootstrap compiler, build and install glibc
- Using the new glibc, build and install a complete gcc (gcc,g++,etc.)
Source
The script and associated files are available as the tarball xgcc3.tar.gz,
or as individual files:
Usage
./build-all.sh (sh4|ppc405|ppc750)
The script assumes that the source tarballs are in ~/cross_tars/
It installs the compiler into /opt/xgcc3; modify TOPPREFIX if desired.
It assumes that you have a complete kernel source tarball; see
fetch*.sh for how to grab the kernel sources we have been using.
Example for ppc405:
# Unpack
tar -xzvf xgcc3.tar.gz
cd xgcc3
# Download source tarballs
mkdir ~/cross_tars
cd ~/cross_tars
sh ~/xgcc3/download.sh
sh ~/xgcc3/fetch-linux-ppc.sh
# Make a place for the results
sudo mkdir /opt/xgcc3
sudo chown $USER.$USER /opt/xgcc3
# Build
cd ~/xgcc3
sh build-all.sh ppc405
# Enjoy
/opt/xgcc3/ppc405/bin/powerpc-linux-gcc hello.c
Known issues
- This does not yet include the workaround
for ppc405 erratum 77.
- 'strings ld.so.1' shows
/opt/xgcc3/ppc405/lib/
/opt/xgcc3/ppc405/etc/ld.so.cache
instad of the expected
/lib/
/etc/ld.so.cache
- 'strings' on every shared library in /lib shows
/opt/xgcc3/ppc405/lib/ld.so.1
instead of the expected
/lib/ld.so.1
- 'strings libc.a' shows
/opt/xgcc3/ppc405/lib/gconv
...
instead of the expected
[/usr]/lib/gconv
...
Links
See also My notes on remote testing of gcc
Some general discussion about the toolchain:
Changelog
- 3 July 2002: add patch to fix setjmp on ppc405
- 7 July 2002: link to remote gcc regression testing page
- 20 July 2002: link to ppc405 erratum 77 workaround
Authors
Dimi Shahbaz, dshahbaz@dimator.org,
Dan Kegel, dank@kegel.com,
Ixia Communications