5.12. GCC-4.4.1 - Cross Compiler Final

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

5.12.1. Installation of GCC Cross Compiler

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

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

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:

AR=ar LDFLAGS="-Wl,-rpath,${CLFS}/cross-tools/lib" \
    ../gcc-4.4.1/configure --prefix=${CLFS}/cross-tools \
    --build=${CLFS_HOST} --host=${CLFS_HOST} --target=${CLFS_TARGET} \
    --disable-multilib --with-sysroot=${CLFS} --disable-nls \
    --enable-shared --enable-languages=c,c++ --enable-__cxa_atexit \
    --with-mpfr=${CLFS}/cross-tools --with-gmp=${CLFS}/cross-tools \
    --with-ppl=${CLFS}/cross-tools --with-cloog=${CLFS}/cross-tools \
    --enable-c99 --enable-long-long --enable-threads=posix

The meaning of the new configure options:

--enable-languages=c,c++

This option ensures that only the C and C++ compilers are built.

--enable-__cxa_atexit

This option allows use of __cxa_atexit, rather than atexit, to register C++ destructors for local statics and global objects and is essential for fully standards-compliant handling of destructors. It also affects the C++ ABI and therefore results in C++ shared libraries and C++ programs that are interoperable with other Linux distributions.

--enable-c99

Enable C99 support for C programs.

--enable-long-long

Enables long long support in the compiler.

--enable-threads=posix

This enables C++ exception handling for multi-threaded code.

Continue with compiling the package:

make AS_FOR_TARGET="${CLFS_TARGET}-as" \
    LD_FOR_TARGET="${CLFS_TARGET}-ld"

Install the package:

make install

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