6.10. GCC-4.8.1

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

6.10.1. Installation of GCC

The following patch contains a number of updates to the 4.8.1 branch by the GCC developers:

patch -Np1 -i ../gcc-4.8.1-branch_update-3.patch

Make a couple of essential adjustments to the specs file to ensure GCC uses our build environment:

patch -Np1 -i ../gcc-4.8.1-pure64_specs-1.patch

Change the StartFile Spec so that GCC looks in /tools:

echo -en '\n#undef STANDARD_STARTFILE_PREFIX_1\n#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\n' >> gcc/config/rs6000/sysv4.h
echo -en '\n#undef STANDARD_STARTFILE_PREFIX_2\n#define STANDARD_STARTFILE_PREFIX_2 ""\n' >> gcc/config/rs6000/sysv4.h

Apply a sed subsitution that will suppress the execution of the fixincludes script:

cp -v gcc/Makefile.in{,.orig}
sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in

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

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

Before starting to build GCC, remember to unset any environment variables that override the default optimization flags.

Prepare GCC for compilation:

CC="${CC} ${BUILD64}" CXX="${CXX} ${BUILD64}" \
    ../gcc-4.8.1/configure --prefix=/tools --disable-multilib \
    --build=${CLFS_HOST} --host=${CLFS_TARGET} --target=${CLFS_TARGET} \
    --libexecdir=/tools/lib --with-local-prefix=/tools --enable-long-long \
    --enable-c99 --enable-shared --enable-threads=posix --disable-nls \
    --enable-__cxa_atexit --enable-languages=c,c++ --disable-libstdcxx-pch \
    --enable-cloog-backend=isl --with-gmp=/tools --with-mpfr=/tools \
    --with-mpc=/tools --with-isl=/tools --disable-isl-version-check \
    --with-cloog=/tools --with-system-zlib \
    --with-native-system-header-dir=/tools/include --enable-checking=release \
    --enable-libstdcxx-time

The meaning of the new configure options:

CXX="${CXX} ${BUILD64}"

This forces the C++ compiler to use our 64 Bit flags.

--disable-libstdcxx-pch

Do not build the pre-compiled header (PCH) for libstdc++. It takes up a lot of space, and we have no use for it.

The following will prevent GCC from looking in the wrong directories for headers and libraries:

cp -v Makefile{,.orig}
sed "/^HOST_\(GMP\|ISL\|CLOOG\)\(LIBS\|INC\)/s:/tools:/cross-tools:g" \
    Makefile.orig > Makefile

Compile the package:

make AS_FOR_TARGET="${AS}" \
    LD_FOR_TARGET="${LD}"

Install the package:

make install

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