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