Pitfalls while building gcc as a cross compiler

June 8, 2013

Rather than clutter my notes about "how to build gcc as a cross compiler" with all the false starts and weird issues I have had to deal with, I am sequestering them here.

I am building on a Fedora 18 linux system running on an x86_64 processor with gcc 4.7.2 as the native compiler.

Try just building gcc-3.4.6

The current instructions for building gcc (which are not tagged as to which version they pertain to), make no mention of installing binutils first. So I give it a whirl just building gcc in the naive way that someone who was simply reading the documentation might try.
cd gcc-build
../gcc-3.4.6/configure --target=m68k-linux-elf --prefix=/opt/m68k
make
The build ends with a message I have seen before:
as: unrecognized option '-mc68020'
In general, the trouble is that the build is trying to use the new compiler to build some library routines. It is running the new compiler front end, but it is finding the native compiler backend. This is the kind of thing that --exec-prefix might fix once the proper binutils have been installed.

Try just building gcc-4.7.2

This one won't even get through the configure stage without help.
rm -rf gcc-build ; mkdir gcc-build
cd gcc-build
../gcc-3.4.6/configure --target=m68k-linux-elf --prefix=/opt/m68k
configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.
All of these are present on my system in the usual place (/usr/lib64) as libgmp.so, libmpfr.so, and libmpc.so. No telling what the problem is.
Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org