6.10. GCC-4.8.3

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.3 branch by the GCC developers:

patch -Np1 -i ../gcc-4.8.3-branch_update-1.patch

Make a couple of essential adjustments to GCC's specs to ensure GCC uses our build environment:

patch -Np1 -i ../gcc-4.8.3-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:

sed -i 's@\./fixinc\.sh@-c true@' 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:

../gcc-4.8.3/configure --prefix=/tools \
    --libdir=/tools/lib64 --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --target=${CLFS_TARGET} --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 \
    --with-system-zlib --with-native-system-header-dir=/tools/include \
    --disable-libssp --enable-libstdcxx-time --enable-checking=release

The meaning of the new configure option:

--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

Install the libiberty header file that is needed by some packages:

cp -v ../gcc-4.8.3/include/libiberty.h /tools/include

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