gcc-pass2.xml 8.8 KB

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