GCC
You are about to over-write your currently installed GCC. If you have ANY doubts that this may fail. Do not continue. Also, Do not continue with make install unless you are 100% confident that your build was successful!
Download Source: | http://ftp.gnu.org/gnu/gcc/gcc-4.2.2/gcc-4.2.2.tar.bz2 |
---|---|
Download Patch: | http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/gcc-4.2.2-PR20425-1.patch |
An Ada compiler is not built on this page.
Contents
Introduction to GCC
The GCC package contains GNU compilers. This package is useful for compiling programs written in C, C++, Fortran, Java, Objective C and Ada. Also included is GNU Treelang. Treelang is a sample language, useful only to help people understand how to implement a new language front end to GCC. It is not a useful language in itself other than as an example or basis for building a new language. Therefore only language developers are likely to have an interest in it.
Note: The Fortran compiler included with the GCC-4.x package now aims to be conformant with the Fortran 95 standard, not the Fortran 77 standard as all previous versions of GCC have been. Please note the following paragraph copied directly from the GCC-4.0.3 gfortran man page.
“Gfortran is not yet a fully conformant Fortran 95 compiler. It can generate code for most constructs and expressions, but work remains to be done. In particular, there are known deficiencies with ENTRY, NAMELIST, and sophisticated use of MODULES, POINTERS and DERIVED TYPES. For those whose Fortran codes conform to either the Fortran 77 standard or the GNU Fortran 77 language, we recommend to use g77 from GCC 3.4.x”
(Non-Multilib) Instructions to install the 3.4.6 version of the Fortran compiler can be found on the BLFS Wiki.
Dependencies
Recommended
Optional (Required to Build the Fortran Compiler)
Optional (Java's Classpath Library Can Use)
Non-Multilib
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.2.2-PR20425-1.patch
On a Pure64 system, apply the following patch:
patch -Np1 -i ../gcc-4.2.2-pure64-1.patch
Apply a sed substitution that will suppress the installation of libiberty.a. The version of libiberty.a that was provided by Binutils during the initial CLFS build will be retained:
sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/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
Configure gcc, adding the additional language support you require to the --enable-languages= switch. Note: This configuration does not include all supported languages.
../gcc-4.2.2/configure --prefix=/usr --libdir=/usr/lib \ --libexecdir=/usr/lib --enable-shared --enable-threads=posix \ --enable-__cxa_atexit --enable-c99 --enable-long-long \ --enable-clocale=gnu --disable-libstdcxx-pch --disable-multilib \ --enable-languages=c,c++,objc,f95,java
Compile gcc:
make bootstrap
The gcc test suite is vitally, critically important. Do not skip it under any circumstances. The GCC test suite is very comprehensive and is almost guaranteed to generate a few failures. Test the results, but don't stop at errors:
make -k check
To see the results of the the test suite, issue the following command:
../gcc-4.2.2/contrib/test_summary
- For only the summaries, pipe the output through grep -A7 Summ.
At this time only proceed if you are 100% positive that you have built a sane compiler.
As the root user, install the collection of compilers:
make install && ln -sfv ../usr/bin/cpp /lib && ln -sfv gcc /usr/bin/cc && chown -Rv root:root /usr/lib/gcc/$(gcc -dumpmachine)/4.2.2/include &&
If you included Java as one of the languages, create the following symlink:
ln -sfv `find /usr/lib/gcc -name ffitarget.h` /usr/include
Multilib
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.2.2-PR20425-1.patch
Suppress the installation of libiberty.a. The version of libiberty.a provided by Binutils will be used instead:
sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
Create the Build Directory:
mkdir -v ../gcc-build && cd ../gcc-build
Configure GCC:
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH64}" && ../gcc-4.2.2/configure --prefix=/usr --libdir=/usr/lib64 \ --libexecdir=/usr/lib64 --enable-shraed --enable-threads=posix \ --enable-__cxa_atexit --enable-c99 --enable-long-long \ --enable-clocale=gnu --disable-libstdcxx-pch --enable-multilib \ --enable-languages=c,c++,objc,f95,java,treelang
Compile GCC:
make bootstrap && unset PKG_CONFIG_PATH
Test the results, but do not stop at errors:
make -k check
The -k flag is used to make the test suite run through to completion and not stop at the first failure. The GCC test suite is very comprehensive and is almost guaranteed to generate a few failures. To receive a summary of the test suite results, run:
../gcc-4.2.2/contrib/test_summary
- For only the summaries, pipe the output through grep -A7 Summ.
At this time only proceed if you are 100% positive that you have built a sane compiler.
Install GCC:
make install && ln -sfv ../usr/bin/cpp /lib && ln -sfv gcc /usr/bin/cc && chown -Rv root:root /usr/lib64/gcc/$(gcc -dumpmachine)/4.2.2/include && chown -Rv root:root /usr/lib64/gcc/$(gcc -dumpmachine)/4.2.2/ada{lib,include}
The libffi interface header is installed in a location where other packages will not be able to find it. If you included Java as one of the installed languages, create a symbolic link in /usr/include to remedy this:
ln -sfv `find /usr/lib64/gcc -name ffitarget.h` /usr/include