5.5. GCC-4.3.2 - Pass 1

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

Approximate build time: 22 SBU
Required disk space: 1.1 GB

5.5.1. Installation of GCC

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

tar -jxf ../mpfr-2.3.2.tar.bz2
mv mpfr-2.3.2 mpfr
tar -jxf ../gmp-4.2.4.tar.bz2
mv gmp-4.2.4 gmp

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:

CC="gcc -B/usr/bin/" ../gcc-4.3.2/configure --prefix=/tools \
    --with-local-prefix=/tools --disable-nls --disable-shared --disable-libssp \
    --enable-languages=c

The meaning of the configure options:

CC="gcc -B/usr/bin/"

This forces gcc to prefer the linker from the host in /usr/bin. This is necessary on some hosts where the new ld built in the previous section is not compatible with the host's gcc.

--with-local-prefix=/tools

The purpose of this switch is to remove /usr/local/include from gcc's include search path. This is not absolutely essential, however, it helps to minimize the influence of the host system.

--disable-shared

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

--disable-libssp

This switch prevents a conflict with older versions of glibc which can cause the build to fail.

--enable-languages=c

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

The following command will compile GCC not once, but several times. It uses the programs compiled in a first round to compile itself a second time, and then again a third time. It then compares these second and third compiles to make sure it can reproduce itself flawlessly. This is called “bootstrapping”. Building GCC in this way ensures that it was compiled correctly and is now the default configuration for the released package. Continue with compiling by running:

make

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. We can satisfy that dependency 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 `gcc -print-libgcc-file-name | \
    sed 's/libgcc/&_eh/'`

As a finishing touch, create a symlink. Many programs and scripts run cc instead of gcc, which is used to keep programs generic and therefore usable on all kinds of UNIX systems where the GNU C compiler is not always installed. Running cc leaves the system administrator free to decide which C compiler to install:

ln -vs gcc /tools/bin/cc

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