[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[1770019] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
---|
[673b0d8] | 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 |
|
---|
[81fd230] | 10 | <indexterm zone="ch-tools-gcc-pass2">
|
---|
| 11 | <primary sortas="a-GCC">GCC</primary>
|
---|
| 12 | <secondary>tools, pass 2</secondary></indexterm>
|
---|
| 13 |
|
---|
[9652249] | 14 | <sect2 role="package"><title/>
|
---|
[73aedd1d] | 15 |
|
---|
[9652249] | 16 | <segmentedlist>
|
---|
| 17 | <segtitle>&buildtime;</segtitle>
|
---|
| 18 | <segtitle>&diskspace;</segtitle>
|
---|
[fc1024a] | 19 | <seglistitem><seg>11.0 SBU</seg><seg>292 MB</seg></seglistitem>
|
---|
[9652249] | 20 | </segmentedlist>
|
---|
[73aedd1d] | 21 |
|
---|
[81fd230] | 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 |
|
---|
[81fd230] | 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
|
---|
| 33 | as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
|
---|
| 34 | unset them when building GCC.</para>
|
---|
| 35 |
|
---|
| 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 |
|
---|
[81fd230] | 48 | <para>The response might be:</para>
|
---|
| 49 |
|
---|
| 50 | <screen><computeroutput>The system has no more ptys.
|
---|
| 51 | Ask your system administrator to create more.</computeroutput></screen>
|
---|
| 52 |
|
---|
| 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
|
---|
[49eaebc] | 56 | consult the LFS FAQ at <ulink url="&faq-root;"/> for more
|
---|
[81fd230] | 57 | information on how to get PTYs working.</para>
|
---|
| 58 |
|
---|
| 59 | <para>First correct a known problem and make an essential adjustment:</para>
|
---|
[3d36131c] | 60 |
|
---|
[e075967] | 61 | <screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-no_fixincludes-1.patch
|
---|
[26c3109c] | 62 | patch -Np1 -i ../gcc-&gcc-version;-specs-2.patch</userinput></screen>
|
---|
[673b0d8] | 63 |
|
---|
[81fd230] | 64 | <para>The first patch disables the GCC <command>fixincludes</command>
|
---|
| 65 | script. This was briefly mentioned earlier, but a more in-depth
|
---|
| 66 | explanation of the fixincludes process is warranted here. Under normal
|
---|
| 67 | circumstances, the GCC <command>fixincludes</command> script scans the
|
---|
| 68 | system for header files that need to be fixed. It might find that some
|
---|
| 69 | Glibc header files on the host system need to be fixed, and will fix
|
---|
| 70 | them and put them in the GCC private include directory. In <xref
|
---|
| 71 | linkend="chapter-building-system"/>, after the newer Glibc has been
|
---|
| 72 | installed, this private include directory will be searched before the
|
---|
| 73 | system include directory. This may result in GCC finding the fixed
|
---|
| 74 | headers from the host system, which most likely will not match the
|
---|
| 75 | Glibc version used for the LFS system.</para>
|
---|
| 76 |
|
---|
| 77 | <para>The second patch changes GCC's default location of the dynamic
|
---|
| 78 | linker (typically <filename class="libraryfile">ld-linux.so.2</filename>). It also removes
|
---|
| 79 | <filename class="directory">/usr/include</filename> from GCC's include
|
---|
| 80 | search path. Patching now rather than adjusting the specs file after
|
---|
| 81 | installation ensures that the new dynamic linker is used during the
|
---|
| 82 | actual build of GCC. That is, all of the final (and temporary)
|
---|
| 83 | binaries created during the build will link against the new
|
---|
| 84 | Glibc.</para>
|
---|
| 85 |
|
---|
| 86 | <important><para>The above patches are critical in ensuring a
|
---|
| 87 | successful overall build. Do not forget to apply
|
---|
| 88 | them.</para></important>
|
---|
| 89 |
|
---|
[73aedd1d] | 90 | <para>Create a separate build directory again:</para>
|
---|
| 91 |
|
---|
| 92 | <screen><userinput>mkdir ../gcc-build
|
---|
| 93 | cd ../gcc-build</userinput></screen>
|
---|
| 94 |
|
---|
[81fd230] | 95 | <para>Before starting to build GCC, remember to unset any environment
|
---|
| 96 | variables that override the default optimization flags.</para>
|
---|
| 97 |
|
---|
[d27a27b] | 98 | <para>Now prepare GCC for compilation:</para>
|
---|
[73aedd1d] | 99 |
|
---|
[673b0d8] | 100 | <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
|
---|
[9dfc02f] | 101 | --libexecdir=/tools/lib --with-local-prefix=/tools \
|
---|
[d72e04a] | 102 | --enable-clocale=gnu --enable-shared \
|
---|
| 103 | --enable-threads=posix --enable-__cxa_atexit \
|
---|
| 104 | --enable-languages=c,c++ --disable-libstdcxx-pch</userinput></screen>
|
---|
[73aedd1d] | 105 |
|
---|
[81fd230] | 106 | <para>The meaning of the new configure options:</para>
|
---|
| 107 |
|
---|
| 108 | <variablelist>
|
---|
| 109 | <varlistentry>
|
---|
| 110 | <term><parameter>--enable-clocale=gnu</parameter></term>
|
---|
| 111 | <listitem><para>This option ensures the correct locale model is
|
---|
| 112 | selected for the C++ libraries under all circumstances. If the
|
---|
| 113 | configure script finds the <emphasis>de_DE</emphasis> locale installed, it will select the
|
---|
| 114 | correct gnu locale model. However, if the <emphasis>de_DE</emphasis> locale is not
|
---|
| 115 | installed, there is the risk of building Application Binary Interface
|
---|
| 116 | (ABI)-incompatible C++ libraries because the incorrect generic locale
|
---|
| 117 | model may be selected.</para></listitem>
|
---|
| 118 | </varlistentry>
|
---|
| 119 |
|
---|
| 120 | <varlistentry>
|
---|
| 121 | <term><parameter>--enable-threads=posix</parameter></term>
|
---|
| 122 | <listitem><para>This enables C++ exception handling for multi-threaded
|
---|
| 123 | code.</para></listitem>
|
---|
| 124 | </varlistentry>
|
---|
| 125 |
|
---|
| 126 | <varlistentry>
|
---|
| 127 | <term><parameter>--enable-__cxa_atexit</parameter></term>
|
---|
| 128 | <listitem><para>This option allows use of
|
---|
| 129 | <emphasis>__cxa_atexit</emphasis>, rather than
|
---|
| 130 | <emphasis>atexit</emphasis>, to register C++ destructors for local
|
---|
| 131 | statics and global objects. This option is essential for fully
|
---|
[c184525] | 132 | standards-compliant handling of destructors. It also affects the C++
|
---|
[81fd230] | 133 | ABI, and therefore results in C++ shared libraries and C++ programs
|
---|
| 134 | that are interoperable with other Linux
|
---|
| 135 | distributions.</para></listitem>
|
---|
| 136 | </varlistentry>
|
---|
| 137 |
|
---|
| 138 | <varlistentry>
|
---|
| 139 | <term><parameter>--enable-languages=c,c++</parameter></term>
|
---|
| 140 | <listitem><para>This option
|
---|
| 141 | ensures that both the C and C++ compilers are built.</para></listitem>
|
---|
| 142 | </varlistentry>
|
---|
| 143 |
|
---|
| 144 | <varlistentry>
|
---|
| 145 | <term><parameter>--disable-libstdcxx-pch</parameter></term>
|
---|
| 146 | <listitem><para>Do not build the pre-compiled header (PCH) for
|
---|
| 147 | <filename class="libraryfile">libstdc++</filename>. It takes up a lot of space,
|
---|
| 148 | and we have no use for it.</para></listitem>
|
---|
| 149 | </varlistentry>
|
---|
| 150 | </variablelist>
|
---|
| 151 |
|
---|
[73aedd1d] | 152 | <para>Compile the package:</para>
|
---|
| 153 |
|
---|
| 154 | <screen><userinput>make</userinput></screen>
|
---|
| 155 |
|
---|
[81fd230] | 156 | <para>There is no need to use the <parameter>bootstrap</parameter>
|
---|
| 157 | target now because the compiler being used to compile this GCC was
|
---|
| 158 | built from the exact same version of the GCC sources used
|
---|
| 159 | earlier.</para>
|
---|
| 160 |
|
---|
[0b5096ca] | 161 | <beginpage/>
|
---|
| 162 |
|
---|
[81fd230] | 163 | <para>Compilation is now complete. As previously mentioned, running
|
---|
| 164 | the test suites for the temporary tools compiled in this chapter is
|
---|
| 165 | not mandatory. To run the GCC test suite anyway, use the following
|
---|
| 166 | command:</para>
|
---|
[3d36131c] | 167 |
|
---|
[73aedd1d] | 168 | <screen><userinput>make -k check</userinput></screen>
|
---|
| 169 |
|
---|
[81fd230] | 170 | <para>The <parameter>-k</parameter> flag is used to make the test suite run
|
---|
| 171 | through to completion and not stop at the first failure. The GCC test
|
---|
| 172 | suite is very comprehensive and is almost guaranteed to generate a few
|
---|
| 173 | failures. To receive a summary of the test suite results, run:</para>
|
---|
[73aedd1d] | 174 |
|
---|
[673b0d8] | 175 | <screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
|
---|
[e8692c5e] | 176 |
|
---|
[fba1478] | 177 | <para>For only the summaries, pipe the output through
|
---|
[81fd230] | 178 | <userinput>grep -A7 Summ</userinput>.</para>
|
---|
[73aedd1d] | 179 |
|
---|
[5f9a00a] | 180 | <para>Results can be compared with those located at <ulink
|
---|
| 181 | url="&test-results;"/>.</para>
|
---|
[81fd230] | 182 |
|
---|
| 183 | <para>A few unexpected failures cannot always be avoided. The
|
---|
| 184 | GCC developers are usually aware of these issues, but have not
|
---|
| 185 | resolved them yet. Unless the test results are vastly different from
|
---|
| 186 | those at the above URL, it is safe to continue.</para>
|
---|
[ede9b9b] | 187 |
|
---|
[81fd230] | 188 | <para>Install the package:</para>
|
---|
[73aedd1d] | 189 |
|
---|
| 190 | <screen><userinput>make install</userinput></screen>
|
---|
| 191 |
|
---|
[81fd230] | 192 | <note><para>At this point it is strongly recommended to repeat the
|
---|
| 193 | sanity check we performed earlier in this chapter. Refer back to <xref
|
---|
| 194 | linkend="ch-tools-adjusting" role=","/> and repeat the test compilation. If
|
---|
| 195 | the result is wrong, the most likely reason is that the GCC Specs
|
---|
| 196 | patch was not properly applied.</para></note>
|
---|
[73aedd1d] | 197 |
|
---|
| 198 | </sect2>
|
---|
[bc82645e] | 199 |
|
---|
[81fd230] | 200 | <sect2 role="content"><title/>
|
---|
| 201 | <para>Details on this package are located in <xref
|
---|
| 202 | linkend="contents-gcc" role="."/></para>
|
---|
| 203 | </sect2>
|
---|
| 204 |
|
---|
[bc82645e] | 205 | </sect1>
|
---|
[81fd230] | 206 |
|
---|