Details on this package are located in Section 10.23.2, “Contents of GCC.”
The GCC package contains the GNU compiler collection, which includes the C and C++ compilers.
The following patch contains a number of updates to the 4.6.0 branch by the GCC developers:
patch -Np1 -i ../gcc-4.6.0-branch_update-1.patch
Make a couple of essential adjustments to the specs
file to ensure GCC uses our build
environment:
patch -Np1 -i ../gcc-4.6.0-specs-1.patch
Change the StartFile Spec and Standard Include Dir so that GCC
looks in /tools
:
echo -en '#undef STANDARD_INCLUDE_DIR\n#define STANDARD_INCLUDE_DIR "/tools/include/"\n\n' >> gcc/config/linux.h echo -en '\n#undef STANDARD_STARTFILE_PREFIX_1\n#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\n' >> gcc/config/linux.h echo -en '\n#undef STANDARD_STARTFILE_PREFIX_2\n#define STANDARD_STARTFILE_PREFIX_2 ""\n' >> gcc/config/linux.h
Also, we need to set the directory searched by the fixincludes process for system headers, so it won't look at the host's headers:
cp -v gcc/Makefile.in{,.orig} sed -e 's@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g' \ 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.6.0/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 \ --enable-__cxa_atexit --disable-nls --enable-languages=c,c++ \ --disable-libstdcxx-pch
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\|PPL\|CLOOG\)\(LIBS\|INC\)/s:-[IL]/\(lib\|include\)::" \ 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.23.2, “Contents of GCC.”