[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
[3be4d97] | 6 | <sect1 id="ch-tools-gcc-pass2">
|
---|
[673b0d8] | 7 | <title>GCC-&gcc-version; - Pass 2</title>
|
---|
| 8 | <?dbhtml filename="gcc-pass2.html"?>
|
---|
[bc82645e] | 9 |
|
---|
[673b0d8] | 10 | <indexterm zone="ch-tools-gcc-pass2">
|
---|
| 11 | <primary sortas="a-GCC">GCC</primary>
|
---|
| 12 | <secondary>tools, pass 2</secondary></indexterm>
|
---|
[bc82645e] | 13 |
|
---|
[673b0d8] | 14 | <screen>&buildtime; 11.0 SBU
|
---|
| 15 | &diskspace; 274 MB</screen>
|
---|
[73aedd1d] | 16 |
|
---|
| 17 |
|
---|
| 18 | <sect2>
|
---|
| 19 | <title>Re-installation of GCC</title>
|
---|
| 20 |
|
---|
[ede9b9b] | 21 | <para>The tools required to test GCC and Binutils are installed now: Tcl,
|
---|
| 22 | Expect and DejaGnu. Therefore we can now rebuild GCC and Binutils, linking
|
---|
| 23 | them against the new Glibc, and test them properly (if running the test suites
|
---|
| 24 | in this chapter). One thing to note, however, is that these test suites are
|
---|
| 25 | highly dependent on properly functioning pseudo terminals (PTYs) which are
|
---|
| 26 | provided by your host. These days, PTYs are most commonly implemented via the
|
---|
[443cace] | 27 | <emphasis>devpts</emphasis> file system. You can quickly check if your host
|
---|
| 28 | system is set up correctly in this regard by performing a simple test:</para>
|
---|
[73aedd1d] | 29 |
|
---|
| 30 | <screen><userinput>expect -c "spawn ls"</userinput></screen>
|
---|
| 31 |
|
---|
[ede9b9b] | 32 | <para>The response might be:</para>
|
---|
[73aedd1d] | 33 |
|
---|
| 34 | <blockquote><screen>The system has no more ptys. Ask your system administrator to create more.</screen></blockquote>
|
---|
| 35 |
|
---|
[ede9b9b] | 36 | <para>If you receive the above message, your host doesn't have its PTYs set up
|
---|
| 37 | properly. In this case there is no point in running the test suites for GCC
|
---|
| 38 | and Binutils until you are able to resolve the issue. You can consult the LFS
|
---|
| 39 | Wiki at <ulink url="&wiki-root;"/> for more information on how to get PTYs
|
---|
[daaa0941] | 40 | working.</para>
|
---|
[73aedd1d] | 41 |
|
---|
[37dcf2a] | 42 | <para>This time we will build both the C and the C++ compilers, so you'll have
|
---|
[ede9b9b] | 43 | to unpack both the core and the g++ tarballs (and testsuite too, if you want to
|
---|
| 44 | run the tests). Unpacking them in your working directory, they will all unfold
|
---|
[673b0d8] | 45 | into a single <filename>gcc-&gcc-version;/</filename> subdirectory.</para>
|
---|
[73aedd1d] | 46 |
|
---|
[ede9b9b] | 47 | <para>First correct a problem and make an essential adjustment:</para>
|
---|
[73aedd1d] | 48 |
|
---|
[673b0d8] | 49 | <screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-no_fixincludes-1.patch
|
---|
| 50 | patch -Np1 -i ../gcc-&gcc-version;-specs-1.patch</userinput></screen>
|
---|
| 51 |
|
---|
| 52 | <para>The first patch disables the GCC <quote>fixincludes</quote> script. We
|
---|
| 53 | mentioned this briefly earlier, but a slightly more in-depth explanation of
|
---|
| 54 | the fixincludes process is warranted here. Under normal circumstances, the GCC
|
---|
| 55 | fixincludes script scans your system for header files that need to be fixed. It
|
---|
| 56 | might find that some Glibc header files on your host system need to be fixed,
|
---|
| 57 | fix them and put them in the GCC private include directory. Then, later on in
|
---|
| 58 | <xref linkend="chapter-building-system"/>, after we've installed the newer
|
---|
| 59 | Glibc, this private include directory would be searched before the system
|
---|
| 60 | include directory, resulting in GCC finding the fixed headers from the host
|
---|
| 61 | system, which would most likely not match the Glibc version actually used for
|
---|
| 62 | the LFS system.</para>
|
---|
[73aedd1d] | 63 |
|
---|
[ede9b9b] | 64 | <para>The second patch changes GCC's default location of the dynamic linker
|
---|
[73aedd1d] | 65 | (typically <filename>ld-linux.so.2</filename>). It also removes
|
---|
| 66 | <filename class="directory">/usr/include</filename> from GCC's include search
|
---|
| 67 | path. Patching now rather than adjusting the specs file after installation
|
---|
| 68 | ensures that our new dynamic linker gets used during the actual build of GCC.
|
---|
| 69 | That is, all the final (and temporary) binaries created during the build will
|
---|
| 70 | link against the new Glibc.</para>
|
---|
| 71 |
|
---|
[f4993cf] | 72 | <important><para>The above patches are <emphasis>critical</emphasis> in ensuring
|
---|
| 73 | a successful overall build. Do not forget to apply them.</para></important>
|
---|
[73aedd1d] | 74 |
|
---|
| 75 | <para>Create a separate build directory again:</para>
|
---|
| 76 |
|
---|
| 77 | <screen><userinput>mkdir ../gcc-build
|
---|
| 78 | cd ../gcc-build</userinput></screen>
|
---|
| 79 |
|
---|
| 80 | <para>Before starting to build GCC, remember to unset any environment
|
---|
| 81 | variables that override the default optimization flags.</para>
|
---|
| 82 |
|
---|
[d27a27b] | 83 | <para>Now prepare GCC for compilation:</para>
|
---|
[73aedd1d] | 84 |
|
---|
[673b0d8] | 85 | <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
|
---|
| 86 | --with-local-prefix=/tools \
|
---|
| 87 | --enable-clocale=gnu --enable-shared \
|
---|
| 88 | --enable-threads=posix --enable-__cxa_atexit \
|
---|
| 89 | --enable-languages=c,c++</userinput></screen>
|
---|
[73aedd1d] | 90 |
|
---|
| 91 | <para>The meaning of the new configure options:</para>
|
---|
| 92 |
|
---|
| 93 | <itemizedlist>
|
---|
[ede9b9b] | 94 | <listitem><para><userinput>--enable-clocale=gnu</userinput>: This option
|
---|
| 95 | ensures the correct locale model is selected for the C++ libraries under all
|
---|
| 96 | circumstances. If the configure script finds the <emphasis>de_DE</emphasis>
|
---|
| 97 | locale installed, it will select the correct <emphasis>gnu</emphasis> locale
|
---|
| 98 | model. However, people who don't install the <emphasis>de_DE</emphasis> locale
|
---|
| 99 | would run the risk of building ABI incompatible C++ libraries due to the wrong
|
---|
| 100 | <emphasis>generic</emphasis> locale model being selected.</para></listitem>
|
---|
| 101 |
|
---|
[73aedd1d] | 102 | <listitem><para><userinput>--enable-threads=posix</userinput>: This enables
|
---|
| 103 | C++ exception handling for multi-threaded code.</para></listitem>
|
---|
| 104 |
|
---|
| 105 | <listitem><para><userinput>--enable-__cxa_atexit</userinput>: This option
|
---|
| 106 | allows use of __cxa_atexit, rather than atexit, to register C++ destructors for
|
---|
| 107 | local statics and global objects and is essential for fully standards-compliant
|
---|
| 108 | handling of destructors. It also affects the C++ ABI and therefore results in
|
---|
| 109 | C++ shared libraries and C++ programs that are interoperable with other Linux
|
---|
| 110 | distributions.</para></listitem>
|
---|
| 111 |
|
---|
[ede9b9b] | 112 | <listitem><para><userinput>--enable-languages=c,c++</userinput>: This option
|
---|
| 113 | ensures that both the C and C++ compilers are built.</para></listitem>
|
---|
[73aedd1d] | 114 | </itemizedlist>
|
---|
| 115 |
|
---|
| 116 | <para>Compile the package:</para>
|
---|
| 117 |
|
---|
| 118 | <screen><userinput>make</userinput></screen>
|
---|
| 119 |
|
---|
[90e3cb3] | 120 | <para>There is no need to use the <emphasis>bootstrap</emphasis> target now,
|
---|
[73aedd1d] | 121 | as the compiler we're using to compile this GCC was built from the exact same
|
---|
| 122 | version of the GCC sources we used earlier.</para>
|
---|
| 123 |
|
---|
[ede9b9b] | 124 | <para>Compilation is now complete. As mentioned earlier, we don't recommend
|
---|
[443cace] | 125 | running the test suites for the temporary tools here in this chapter. If you
|
---|
| 126 | still want to run the GCC test suite anyway, the following command will do
|
---|
| 127 | so:</para>
|
---|
[73aedd1d] | 128 |
|
---|
| 129 | <screen><userinput>make -k check</userinput></screen>
|
---|
| 130 |
|
---|
[90e3cb3] | 131 | <para>The <emphasis>-k</emphasis> flag is used to make the test suite run
|
---|
[73aedd1d] | 132 | through to completion and not stop at the first failure. The GCC test suite is
|
---|
| 133 | very comprehensive and is almost guaranteed to generate a few failures. To get
|
---|
| 134 | a summary of the test suite results, run this:</para>
|
---|
| 135 |
|
---|
[673b0d8] | 136 | <screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
|
---|
[e8692c5e] | 137 |
|
---|
| 138 | <para>(For just the summaries, pipe the output through
|
---|
| 139 | <userinput>grep -A7 Summ</userinput>.)</para>
|
---|
[73aedd1d] | 140 |
|
---|
| 141 | <para>You can compare your results to those posted to the gcc-testresults
|
---|
| 142 | mailing list for similar configurations to your own. For an example of how
|
---|
| 143 | current GCC-&gcc-version; should look on i686-pc-linux-gnu, see
|
---|
[e5888f5] | 144 | <ulink url="http://gcc.gnu.org/ml/gcc-testresults/2004-01/msg00826.html"/>.</para>
|
---|
[73aedd1d] | 145 |
|
---|
| 146 | <para>Note that the results contain:</para>
|
---|
| 147 |
|
---|
| 148 | <screen>* 1 XPASS (unexpected pass) for g++
|
---|
[bc827b39] | 149 | * 1 FAIL (unexpected failure) for gcc
|
---|
[e5888f5] | 150 | * 24 XPASS's for libstdc++</screen>
|
---|
[73aedd1d] | 151 |
|
---|
| 152 | <para>The unexpected pass for g++ is due to the use of
|
---|
[90e3cb3] | 153 | <emphasis>--enable-__cxa_atexit</emphasis>. Apparently not all platforms
|
---|
[673b0d8] | 154 | supported by GCC have support for <quote>__cxa_atexit</quote> in their C
|
---|
| 155 | libraries, so this test is not always expected to pass.</para>
|
---|
[73aedd1d] | 156 |
|
---|
[e5888f5] | 157 | <para>The 24 unexpected passes for libstdc++ are due to the use of
|
---|
[ede9b9b] | 158 | <emphasis>--enable-clocale=gnu</emphasis>. This option, which is the correct
|
---|
| 159 | choice on Glibc-based systems of versions 2.2.5 and above, enables in the GNU C
|
---|
| 160 | library a locale support that is superior to the otherwise selected
|
---|
| 161 | <emphasis>generic</emphasis> model (which may be applicable if for instance you
|
---|
| 162 | were using Newlibc, Sun-libc or whatever other libc). The libstdc++ test suite
|
---|
| 163 | is apparently expecting the <emphasis>generic</emphasis> model, hence those
|
---|
| 164 | tests are not always expected to pass.</para>
|
---|
| 165 |
|
---|
| 166 | <para>Having a few unexpected failures often cannot be avoided. The GCC
|
---|
| 167 | developers are usually aware of these, but haven't yet gotten around to fixing
|
---|
[673b0d8] | 168 | them. One particular case in point is the filebuf_members test in the C++
|
---|
| 169 | standard library testsuite. This test has been observed to fail in some
|
---|
| 170 | situations, but succeeed in others. In short, unless your results are vastly
|
---|
| 171 | different from those at the above URL, it is safe to continue.</para>
|
---|
[73aedd1d] | 172 |
|
---|
[17476c5] | 173 | <para>And finally install the package:</para>
|
---|
[73aedd1d] | 174 |
|
---|
| 175 | <screen><userinput>make install</userinput></screen>
|
---|
| 176 |
|
---|
| 177 | <note><para>At this point it is strongly recommended to repeat the sanity check
|
---|
[a0b689e] | 178 | we performed earlier in this chapter. Refer back to
|
---|
[ede9b9b] | 179 | <xref linkend="ch-tools-adjusting"/> and repeat the little test compilation. If
|
---|
| 180 | the result is wrong, then most likely you forgot to apply the above mentioned
|
---|
| 181 | GCC Specs patch.</para></note>
|
---|
[73aedd1d] | 182 |
|
---|
| 183 | </sect2>
|
---|
[bc82645e] | 184 |
|
---|
[673b0d8] | 185 | <sect2><title> </title><para> </para>
|
---|
[5888299] | 186 | <para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
|
---|
[673b0d8] | 187 | <para> </para></sect2>
|
---|
[5888299] | 188 |
|
---|
[bc82645e] | 189 | </sect1>
|
---|