7.12. GCC-4.1.1 - Cross Compiler Final

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

7.12.1. Installation of GCC Cross Compiler

To make sure that a couple of tools use the proper syntax, apply the following patch:

patch -Np1 -i ../gcc-4.1.1-posix-1.patch

The following patch is needed for GCC to build against uClibc:

patch -Np1 -i ../gcc-4.1.1-uclibc-1.patch

The following patch fixes the searching of multilib dirs for specs file.The patch standardizes the gcc drivers path iteration functions, ensuring multilib directories are searched in the correct order. This fixes various issues, most noticably with libtool on multilib systems:

patch -Np1 -i ../gcc-4.1.1-PR20425-1.patch

The following patch ensures that gcc does not search the /usr directory for libgcc_s.so when cross-compiling:

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

../gcc-4.1.1/configure --prefix=${CLFS}/cross-tools \
    --host=${CLFS_HOST} --target=${CLFS_TARGET} --disable-multilib \
    --with-sysroot=${CLFS} --disable-nls --enable-shared \
    --enable-languages=c --enable-__cxa_atexit \
    --enable-c99 --enable-long-long --enable-threads=posix

The meaning of the new configure options:

--enable-languages=c

This option ensures that only the C compiler is built. If the C++ compiler is needed, use --enable-languages=c,c++

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

Install the package:

make install

7.12.2. Contents of GCC

Installed programs: c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov
Installed libraries: libgcc.a, libgcc_eh.a, libgcc_s.so, libmudflap.[a,so], libmudflapth.[a,so], libstdc++.[a,so], and libsupc++.a

Short Descriptions

cc

The C compiler

cpp

The C preprocessor; it is used by the compiler to expand the #include, #define, and similar statements in the source files

c++

The C++ compiler

g++

The C++ compiler

gcc

The C compiler

gccbug

A shell script used to help create useful bug reports

gcov

A coverage testing tool; it is used to analyze programs to determine where optimizations will have the most effect

libgcc

Contains run-time support for gcc

libmudflap

The libmudflap libraries are used by GCC for instrumenting pointer and array dereferencing operations.

libstdc++

The standard C++ library

libsupc++

Provides supporting routines for the C++ programming language