[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 |
|
---|
[6e41459] | 22 | <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
|
---|
| 23 |
|
---|
[9652249] | 24 | </sect2>
|
---|
| 25 |
|
---|
| 26 | <sect2 role="installation">
|
---|
[73aedd1d] | 27 | <title>Re-installation of GCC</title>
|
---|
| 28 |
|
---|
[24a08b9] | 29 | <para>This package is known to have issues when its default
|
---|
| 30 | optimization flags (including the <parameter>-march</parameter> and
|
---|
| 31 | <parameter>-mcpu</parameter> options) are changed. If any environment
|
---|
| 32 | variables that override default optimizations have been defined, such
|
---|
[e097438] | 33 | as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
|
---|
[24a08b9] | 34 | unset them when building GCC.</para>
|
---|
| 35 |
|
---|
[69993f4] | 36 | <para>The tools required to test GCC and Binutils—Tcl, Expect
|
---|
| 37 | and DejaGNU—are installed now. GCC and Binutils can now be
|
---|
| 38 | rebuilt, linking them against the new Glibc and testing them properly
|
---|
| 39 | (if running the test suites in this chapter). Please note that these
|
---|
| 40 | test suites are highly dependent on properly functioning PTYs which
|
---|
| 41 | are provided by the host. PTYs are most commonly implemented via the
|
---|
| 42 | <systemitem class="filesystem">devpts</systemitem> file system. Check
|
---|
| 43 | to see if the host system is set up correctly in this regard by
|
---|
| 44 | performing a quick test:</para>
|
---|
[73aedd1d] | 45 |
|
---|
| 46 | <screen><userinput>expect -c "spawn ls"</userinput></screen>
|
---|
| 47 |
|
---|
[ede9b9b] | 48 | <para>The response might be:</para>
|
---|
[73aedd1d] | 49 |
|
---|
[c863747] | 50 | <screen><computeroutput>The system has no more ptys.
|
---|
| 51 | Ask your system administrator to create more.</computeroutput></screen>
|
---|
[73aedd1d] | 52 |
|
---|
[6e41459] | 53 | <para>If the above message is received, the host does not have its
|
---|
| 54 | PTYs set up properly. In this case, there is no point in running the
|
---|
| 55 | test suites for GCC and Binutils until this issue is resolved. Please
|
---|
| 56 | consult the LFS Wiki at <ulink url="&wiki-root;"/> for more
|
---|
| 57 | information on how to get PTYs working.</para>
|
---|
[73aedd1d] | 58 |
|
---|
[6e41459] | 59 | <para>Because the C and the C++ compilers will be built, unpack both
|
---|
[69993f4] | 60 | the core and the g++ tarballs (as well as test suite, if you want to
|
---|
[6e41459] | 61 | run the tests). By unpacking them in the working directory, they will
|
---|
| 62 | all unfold into a single <filename
|
---|
| 63 | class="directory">gcc-&gcc-version;/</filename> subdirectory.</para>
|
---|
[73aedd1d] | 64 |
|
---|
[38bb44a] | 65 | <beginpage/>
|
---|
[6e41459] | 66 | <para>First correct a known problem and make an essential adjustment:</para>
|
---|
[73aedd1d] | 67 |
|
---|
[e075967] | 68 | <screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-no_fixincludes-1.patch
|
---|
| 69 | patch -Np1 -i ../gcc-&gcc-version;-specs-1.patch</userinput></screen>
|
---|
[673b0d8] | 70 |
|
---|
[6e41459] | 71 | <para>The first patch disables the GCC <command>fixincludes</command>
|
---|
| 72 | script. This was briefly mentioned earlier, but a more in-depth
|
---|
| 73 | explanation of the fixincludes process is warranted here. Under normal
|
---|
| 74 | circumstances, the GCC <command>fixincludes</command> script scans the
|
---|
| 75 | system for header files that need to be fixed. It might find that some
|
---|
| 76 | Glibc header files on the host system need to be fixed, and will fix
|
---|
| 77 | them and put them in the GCC private include directory. In <xref
|
---|
[69993f4] | 78 | linkend="chapter-building-system"/>, after the newer Glibc has been
|
---|
[6e41459] | 79 | installed, this private include directory will be searched before the
|
---|
| 80 | system include directory. This may result in GCC finding the fixed
|
---|
| 81 | headers from the host system, which most likely will not match the
|
---|
| 82 | Glibc version used for the LFS system.</para>
|
---|
| 83 |
|
---|
| 84 | <para>The second patch changes GCC's default location of the dynamic
|
---|
[e097438] | 85 | linker (typically <filename class="libraryfile">ld-linux.so.2</filename>). It also removes
|
---|
[6e41459] | 86 | <filename class="directory">/usr/include</filename> from GCC's include
|
---|
| 87 | search path. Patching now rather than adjusting the specs file after
|
---|
| 88 | installation ensures that the new dynamic linker is used during the
|
---|
| 89 | actual build of GCC. That is, all of the final (and temporary)
|
---|
| 90 | binaries created during the build will link against the new
|
---|
| 91 | Glibc.</para>
|
---|
| 92 |
|
---|
| 93 | <important><para>The above patches are critical in ensuring a
|
---|
| 94 | successful overall build. Do not forget to apply
|
---|
| 95 | them.</para></important>
|
---|
[73aedd1d] | 96 |
|
---|
| 97 | <para>Create a separate build directory again:</para>
|
---|
| 98 |
|
---|
| 99 | <screen><userinput>mkdir ../gcc-build
|
---|
| 100 | cd ../gcc-build</userinput></screen>
|
---|
| 101 |
|
---|
| 102 | <para>Before starting to build GCC, remember to unset any environment
|
---|
| 103 | variables that override the default optimization flags.</para>
|
---|
| 104 |
|
---|
[d27a27b] | 105 | <para>Now prepare GCC for compilation:</para>
|
---|
[73aedd1d] | 106 |
|
---|
[673b0d8] | 107 | <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
|
---|
[9dfc02f] | 108 | --libexecdir=/tools/lib --with-local-prefix=/tools \
|
---|
[c863747] | 109 | --enable-clocale=gnu --enable-shared \
|
---|
| 110 | --enable-threads=posix --enable-__cxa_atexit \
|
---|
| 111 | --enable-languages=c,c++ --disable-libstdcxx-pch</userinput></screen>
|
---|
[73aedd1d] | 112 |
|
---|
| 113 | <para>The meaning of the new configure options:</para>
|
---|
| 114 |
|
---|
[9652249] | 115 | <variablelist>
|
---|
| 116 | <varlistentry>
|
---|
[574b0ea] | 117 | <term><parameter>--enable-clocale=gnu</parameter></term>
|
---|
[6e41459] | 118 | <listitem><para>This option ensures the correct locale model is
|
---|
| 119 | selected for the C++ libraries under all circumstances. If the
|
---|
| 120 | configure script finds the <emphasis>de_DE</emphasis> locale installed, it will select the
|
---|
| 121 | correct gnu locale model. However, if the <emphasis>de_DE</emphasis> locale is not
|
---|
| 122 | installed, there is the risk of building Application Binary Interface
|
---|
| 123 | (ABI)-incompatible C++ libraries because the incorrect generic locale
|
---|
| 124 | model may be selected.</para></listitem>
|
---|
[9652249] | 125 | </varlistentry>
|
---|
[ede9b9b] | 126 |
|
---|
[9652249] | 127 | <varlistentry>
|
---|
[574b0ea] | 128 | <term><parameter>--enable-threads=posix</parameter></term>
|
---|
[6e41459] | 129 | <listitem><para>This enables C++ exception handling for multi-threaded
|
---|
| 130 | code.</para></listitem>
|
---|
[9652249] | 131 | </varlistentry>
|
---|
[73aedd1d] | 132 |
|
---|
[9652249] | 133 | <varlistentry>
|
---|
[574b0ea] | 134 | <term><parameter>--enable-__cxa_atexit</parameter></term>
|
---|
[6e41459] | 135 | <listitem><para>This option allows use of
|
---|
| 136 | <emphasis>__cxa_atexit</emphasis>, rather than
|
---|
| 137 | <emphasis>atexit</emphasis>, to register C++ destructors for local
|
---|
| 138 | statics and global objects. This option is essential for fully
|
---|
[4ea4bc4] | 139 | standards-compliant handling of destructors. It also effects the C++
|
---|
[69993f4] | 140 | ABI, and therefore results in C++ shared libraries and C++ programs
|
---|
[6e41459] | 141 | that are interoperable with other Linux
|
---|
[73aedd1d] | 142 | distributions.</para></listitem>
|
---|
[9652249] | 143 | </varlistentry>
|
---|
[73aedd1d] | 144 |
|
---|
[9652249] | 145 | <varlistentry>
|
---|
[574b0ea] | 146 | <term><parameter>--enable-languages=c,c++</parameter></term>
|
---|
[9652249] | 147 | <listitem><para>This option
|
---|
[ede9b9b] | 148 | ensures that both the C and C++ compilers are built.</para></listitem>
|
---|
[9652249] | 149 | </varlistentry>
|
---|
[32a531e] | 150 |
|
---|
[9652249] | 151 | <varlistentry>
|
---|
[574b0ea] | 152 | <term><parameter>--disable-libstdcxx-pch</parameter></term>
|
---|
[6e41459] | 153 | <listitem><para>Do not build the pre-compiled header (PCH) for
|
---|
[e097438] | 154 | <filename class="libraryfile">libstdc++</filename>. It takes up a lot of space,
|
---|
| 155 | and we have no use for it.</para></listitem>
|
---|
[9652249] | 156 | </varlistentry>
|
---|
| 157 | </variablelist>
|
---|
[73aedd1d] | 158 |
|
---|
| 159 | <para>Compile the package:</para>
|
---|
| 160 |
|
---|
| 161 | <screen><userinput>make</userinput></screen>
|
---|
| 162 |
|
---|
[6e41459] | 163 | <para>There is no need to use the <parameter>bootstrap</parameter>
|
---|
| 164 | target now because the compiler being used to compile this GCC was
|
---|
| 165 | built from the exact same version of the GCC sources used
|
---|
| 166 | earlier.</para>
|
---|
[73aedd1d] | 167 |
|
---|
[6e41459] | 168 | <para>Compilation is now complete. As previously mentioned, running
|
---|
| 169 | the test suites for the temporary tools compiled in this chapter is
|
---|
| 170 | not mandatory. To run the GCC test suite anyway, use the following
|
---|
| 171 | command:</para>
|
---|
[73aedd1d] | 172 |
|
---|
| 173 | <screen><userinput>make -k check</userinput></screen>
|
---|
| 174 |
|
---|
[38bb44a] | 175 | <beginpage/>
|
---|
[574b0ea] | 176 | <para>The <parameter>-k</parameter> flag is used to make the test suite run
|
---|
[6e41459] | 177 | through to completion and not stop at the first failure. The GCC test
|
---|
| 178 | suite is very comprehensive and is almost guaranteed to generate a few
|
---|
| 179 | failures. To receive a summary of the test suite results, run:</para>
|
---|
[73aedd1d] | 180 |
|
---|
[673b0d8] | 181 | <screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
|
---|
[e8692c5e] | 182 |
|
---|
[6e41459] | 183 | <para>For only the summaries, pipe the output through
|
---|
| 184 | <userinput>grep -A7 Summ</userinput>.</para>
|
---|
[73aedd1d] | 185 |
|
---|
[6e41459] | 186 | <para>Results can be compared to those posted to the gcc-testresults
|
---|
| 187 | mailing list to see similar configurations to the one being built. For
|
---|
| 188 | an example of how current GCC-&gcc-version; should look on
|
---|
| 189 | i686-pc-linux-gnu, see <ulink
|
---|
| 190 | url="http://gcc.gnu.org/ml/gcc-testresults/2004-07/msg00179.html"/>.</para>
|
---|
[ede9b9b] | 191 |
|
---|
[69993f4] | 192 | <para>A few unexpected failures cannot always be avoided. The
|
---|
[6e41459] | 193 | GCC developers are usually aware of these issues, but have not
|
---|
| 194 | resolved them yet. Unless the test results are vastly different from
|
---|
| 195 | those at the above URL, it is safe to continue.</para>
|
---|
[73aedd1d] | 196 |
|
---|
[6e41459] | 197 | <para>Install the package:</para>
|
---|
[73aedd1d] | 198 |
|
---|
| 199 | <screen><userinput>make install</userinput></screen>
|
---|
| 200 |
|
---|
[6e41459] | 201 | <note><para>At this point it is strongly recommended to repeat the
|
---|
| 202 | sanity check we performed earlier in this chapter. Refer back to <xref
|
---|
[c17fc85] | 203 | linkend="ch-tools-adjusting" role=","/> and repeat the test compilation. If
|
---|
[6e41459] | 204 | the result is wrong, the most likely reason is that the GCC Specs
|
---|
| 205 | patch was not properly applied.</para></note>
|
---|
[73aedd1d] | 206 |
|
---|
| 207 | </sect2>
|
---|
[bc82645e] | 208 |
|
---|
[9652249] | 209 | <sect2 role="content"><title/>
|
---|
[c17fc85] | 210 | <para>Details on this package are located in <xref
|
---|
| 211 | linkend="contents-gcc" role="."/></para>
|
---|
[0868461] | 212 | </sect2>
|
---|
[5888299] | 213 |
|
---|
[bc82645e] | 214 | </sect1>
|
---|
[6e41459] | 215 |
|
---|