Details on this package are located in Section 6.14.2, “Contents of GCC.”
Approximate build time: 11.0 SBU
Required disk space: 274 MB
GCC installation depends on: Bash, Binutils, Coreutils, Diffutils, Findutils, Gawk, Gettext, Glibc, Grep, Make, Perl, Sed, and Texinfo
This package is known to have issues when its default optimization flags (including the -march and -mcpu options) are changed. If any environment variables that override default optimizations have been defined, such as CFLAGS and CXXFLAGS, unset them when building GCC.
The tools required to test GCC and Binutils—Tcl, Expect and DejaGNU—are installed now. GCC and Binutils can now be rebuilt, linking them against the new Glibc and testing them properly (if running the test suites in this chapter). Please note that these test suites are highly dependent on properly functioning PTYs which are provided by the host. PTYs are most commonly implemented via the devpts file system. Check to see if the host system is set up correctly in this regard by performing a quick test:
expect -c "spawn ls"
The response might be:
The system has no more ptys. Ask your system administrator to create more.
If the above message is received, the host does not have its PTYs set up properly. In this case, there is no point in running the test suites for GCC and Binutils until this issue is resolved. Please consult the LFS Wiki at http://wiki.linuxfromscratch.org/ for more information on how to get PTYs working.
Because the C and the C++ compilers will be built, unpack both the core and the g++ tarballs (as well as test suite, if you want to run the tests). By unpacking them in the working directory, they will all unfold into a single gcc-3.4.1/ subdirectory.
First correct a known problem and make an essential adjustment:
patch -Np1 -i ../gcc-3.4.1-no_fixincludes-1.patch patch -Np1 -i ../gcc-3.4.1-specs-1.patch
The first patch disables the GCC fixincludes script. This was briefly mentioned earlier, but a more in-depth explanation of the fixincludes process is warranted here. Under normal circumstances, the GCC fixincludes script scans the system for header files that need to be fixed. It might find that some Glibc header files on the host system need to be fixed, and will fix them and put them in the GCC private include directory. In Chapter 6, after the newer Glibc has been installed, this private include directory will be searched before the system include directory. This may result in GCC finding the fixed headers from the host system, which most likely will not match the Glibc version used for the LFS system.
The second patch changes GCC's default location of the dynamic linker (typically ld-linux.so.2). It also removes /usr/include from GCC's include search path. Patching now rather than adjusting the specs file after installation ensures that the new dynamic linker is used during the actual build of GCC. That is, all of the final (and temporary) binaries created during the build will link against the new Glibc.
The above patches are critical in ensuring a successful overall build. Do not forget to apply them.
Create a separate build directory again:
mkdir ../gcc-build cd ../gcc-build
Before starting to build GCC, remember to unset any environment variables that override the default optimization flags.
Now prepare GCC for compilation:
../gcc-3.4.1/configure --prefix=/tools \ --libexecdir=/tools/lib --with-local-prefix=/tools \ --enable-clocale=gnu --enable-shared \ --enable-threads=posix --enable-__cxa_atexit \ --enable-languages=c,c++ --disable-libstdcxx-pch
The meaning of the new configure options:
This option ensures the correct locale model is selected for the C++ libraries under all circumstances. If the configure script finds the de_DE locale installed, it will select the correct gnu locale model. However, if the de_DE locale is not installed, there is the risk of building Application Binary Interface (ABI)-incompatible C++ libraries because the incorrect generic locale model may be selected.
This enables C++ exception handling for multi-threaded code.
This option allows use of __cxa_atexit, rather than atexit, to register C++ destructors for local statics and global objects. This option is essential for fully standards-compliant handling of destructors. It also effects the C++ ABI, and therefore results in C++ shared libraries and C++ programs that are interoperable with other Linux distributions.
This option ensures that both the C and C++ compilers are built.
Do not build the pre-compiled header (PCH) for libstdc++. It takes up a lot of space, and we have no use for it.
Compile the package:
make
There is no need to use the bootstrap target now because the compiler being used to compile this GCC was built from the exact same version of the GCC sources used earlier.
Compilation is now complete. As previously mentioned, running the test suites for the temporary tools compiled in this chapter is not mandatory. To run the GCC test suite anyway, use the following command:
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-3.4.1/contrib/test_summary
For only the summaries, pipe the output through grep -A7 Summ.
Results can be compared to those posted to the gcc-testresults mailing list to see similar configurations to the one being built. For an example of how current GCC-3.4.1 should look on i686-pc-linux-gnu, see http://gcc.gnu.org/ml/gcc-testresults/2004-07/msg00179.html.
A few unexpected failures cannot always be avoided. The GCC developers are usually aware of these issues, but have not resolved them yet. Unless the test results are vastly different from those at the above URL, it is safe to continue.
Install the package:
make install
At this point it is strongly recommended to repeat the sanity check we performed earlier in this chapter. Refer back to Section 5.9, “Adjusting the Toolchain,” and repeat the test compilation. If the result is wrong, the most likely reason is that the GCC Specs patch was not properly applied.
Details on this package are located in Section 6.14.2, “Contents of GCC.”