gcc-pass2.xml 8.8 KB

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