5.5. GCC-4.5.1 - Pass 1

The GCC package contains the GNU compiler collection, which includes the C and C++ compilers.

Approximate build time: 5.0 SBU
Required disk space: 809 MB

5.5.1. Installation of Cross GCC

GCC now requires the GMP, MPFR and MPC packages. As these packages may not be included in your host distribution, they will be built with GCC:

tar -jxf ../mpfr-3.0.0.tar.bz2
mv -v mpfr-3.0.0 mpfr
tar -jxf ../gmp-5.0.1.tar.bz2
mv -v gmp-5.0.1 gmp
tar -zxf ../mpc-0.8.2.tar.gz
mv -v mpc-0.8.2 mpc

The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory:

mkdir -v ../gcc-build
cd ../gcc-build

Prepare GCC for compilation:

../gcc-4.5.1/configure \
    --target=$LFS_TGT --prefix=/tools \
    --disable-nls --disable-shared --disable-multilib \
    --disable-decimal-float --disable-threads \
    --disable-libmudflap --disable-libssp \
    --disable-libgomp --enable-languages=c \
    --with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs \
    --without-ppl --without-cloog

The meaning of the configure options:


This switch forces GCC to link its internal libraries statically. We do this to avoid possible issues with the host system.

--disable-decimal-float, --disable-threads, --disable-libmudflap, --disable-libssp, --disable-libgomp

These switches disable support for the decimal floating point extension, threading, libmudflap, libssp and libgomp respectively. These features will fail to compile when building a cross-compiler and are not necessary for the task of cross-compiling the temporary libc.


On x86_64, LFS does not yet support a multilib configuration. This switch is harmless for x86.


This option ensures that only the C compiler is built. This is the only language needed now.


This option tells GCC where the GMP headers are located.


This option tells GCC where the GMP library is located.

--without-ppl, --without-cloog

These switches prevent GCC from building against the PPL and CLooG libraries which may be present on the host system, but will not be available in the chroot environment.

Compile GCC by running:


Compilation is now complete. At this point, the test suite would normally be run, but, as mentioned before, the test suite framework is not in place yet. The benefits of running the tests at this point are minimal since the programs from this first pass will soon be replaced.

Install the package:

make install

Using --disable-shared means that the libgcc_eh.a file isn't created and installed. The Glibc package depends on this library as it uses -lgcc_eh within its build system. This dependency can be satisfied by creating a symlink to libgcc.a, since that file will end up containing the objects normally contained in libgcc_eh.a:

ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \
    sed 's/libgcc/&_eh/'`

Details on this package are located in Section 6.16.2, “Contents of GCC.”