gcc-pass2.xml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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>292 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 PTYs set up
  42. properly. In this case, there is no point in running the test suites for GCC and
  43. Binutils until this issue is resolved. Please consult the LFS FAQ at <ulink
  44. url="&lfs-root;/lfs/faq.html#no-ptys"/> for more information on how to get PTYs
  45. working.</para>
  46. <para>First correct a known problem and make an essential adjustment:</para>
  47. <screen><userinput>patch -Np1 -i ../&gcc-no_fixincludes-patch;
  48. patch -Np1 -i ../&gcc-specs-patch;</userinput></screen>
  49. <para>The first patch disables the GCC <command>fixincludes</command>
  50. script. This was briefly mentioned earlier, but a more in-depth
  51. explanation of the fixincludes process is warranted here. Under normal
  52. circumstances, the GCC <command>fixincludes</command> script scans the
  53. system for header files that need to be fixed. It might find that some
  54. Glibc header files on the host system need to be fixed, and will fix
  55. them and put them in the GCC private include directory. In <xref
  56. linkend="chapter-building-system"/>, after the newer Glibc has been
  57. installed, this private include directory will be searched before the
  58. system include directory. This may result in GCC finding the fixed
  59. headers from the host system, which most likely will not match the
  60. Glibc version used for the LFS system.</para>
  61. <para>The second patch changes GCC's default location of the dynamic
  62. linker (typically <filename class="libraryfile">ld-linux.so.2</filename>). It also removes
  63. <filename class="directory">/usr/include</filename> from GCC's include
  64. search path. Patching now rather than adjusting the specs file after
  65. installation ensures that the new dynamic linker is used during the
  66. actual build of GCC. That is, all of the final (and temporary)
  67. binaries created during the build will link against the new
  68. Glibc.</para>
  69. <beginpage/>
  70. <important><para>The above patches are critical in ensuring a
  71. successful overall build. Do not forget to apply
  72. them.</para></important>
  73. <para>Create a separate build directory again:</para>
  74. <screen><userinput>mkdir -v ../gcc-build
  75. cd ../gcc-build</userinput></screen>
  76. <para>Before starting to build GCC, remember to unset any environment
  77. variables that override the default optimization flags.</para>
  78. <para>Now prepare GCC for compilation:</para>
  79. <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
  80. --libexecdir=/tools/lib --with-local-prefix=/tools \
  81. --enable-clocale=gnu --enable-shared \
  82. --enable-threads=posix --enable-__cxa_atexit \
  83. --enable-languages=c,c++ --disable-libstdcxx-pch</userinput></screen>
  84. <para>The meaning of the new configure options:</para>
  85. <variablelist>
  86. <varlistentry>
  87. <term><parameter>--enable-clocale=gnu</parameter></term>
  88. <listitem><para>This option ensures the correct locale model is
  89. selected for the C++ libraries under all circumstances. If the
  90. configure script finds the <emphasis>de_DE</emphasis> locale installed, it will select the
  91. correct gnu locale model. However, if the <emphasis>de_DE</emphasis> locale is not
  92. installed, there is the risk of building Application Binary Interface
  93. (ABI)-incompatible C++ libraries because the incorrect generic locale
  94. model may be selected.</para></listitem>
  95. </varlistentry>
  96. <varlistentry>
  97. <term><parameter>--enable-threads=posix</parameter></term>
  98. <listitem><para>This enables C++ exception handling for multi-threaded
  99. code.</para></listitem>
  100. </varlistentry>
  101. <varlistentry>
  102. <term><parameter>--enable-__cxa_atexit</parameter></term>
  103. <listitem><para>This option allows use of
  104. <emphasis>__cxa_atexit</emphasis>, rather than
  105. <emphasis>atexit</emphasis>, to register C++ destructors for local
  106. statics and global objects. This option is essential for fully
  107. standards-compliant handling of destructors. It also affects the C++
  108. ABI, and therefore results in C++ shared libraries and C++ programs
  109. that are interoperable with other Linux
  110. distributions.</para></listitem>
  111. </varlistentry>
  112. <varlistentry>
  113. <term><parameter>--enable-languages=c,c++</parameter></term>
  114. <listitem><para>This option
  115. ensures that both the C and C++ compilers are built.</para></listitem>
  116. </varlistentry>
  117. <varlistentry>
  118. <term><parameter>--disable-libstdcxx-pch</parameter></term>
  119. <listitem><para>Do not build the pre-compiled header (PCH) for
  120. <filename class="libraryfile">libstdc++</filename>. It takes up a lot of space,
  121. and we have no use for it.</para></listitem>
  122. </varlistentry>
  123. </variablelist>
  124. <para>Compile the package:</para>
  125. <screen><userinput>make</userinput></screen>
  126. <para>There is no need to use the <parameter>bootstrap</parameter>
  127. target now because the compiler being used to compile this GCC was
  128. built from the exact same version of the GCC sources used
  129. earlier.</para>
  130. <beginpage/>
  131. <para>Compilation is now complete. As previously mentioned, running
  132. the test suites for the temporary tools compiled in this chapter is
  133. not mandatory. To run the GCC test suite anyway, use the following
  134. command:</para>
  135. <screen><userinput>make -k check</userinput></screen>
  136. <para>The <parameter>-k</parameter> flag is used to make the test suite run
  137. through to completion and not stop at the first failure. The GCC test
  138. suite is very comprehensive and is almost guaranteed to generate a few
  139. failures. To receive a summary of the test suite results, run:</para>
  140. <screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
  141. <para>For only the summaries, pipe the output through
  142. <userinput>grep -A7 Summ</userinput>.</para>
  143. <para>Results can be compared with those located at <ulink
  144. url="&test-results;"/>.</para>
  145. <para>A few unexpected failures cannot always be avoided. The
  146. GCC developers are usually aware of these issues, but have not
  147. resolved them yet. Unless the test results are vastly different from
  148. those at the above URL, it is safe to continue.</para>
  149. <para>Install the package:</para>
  150. <screen><userinput>make install</userinput></screen>
  151. <note><para>At this point it is strongly recommended to repeat the
  152. sanity check we performed earlier in this chapter. Refer back to <xref
  153. linkend="ch-tools-adjusting" role=","/> and repeat the test compilation. If
  154. the result is wrong, the most likely reason is that the GCC Specs
  155. patch was not properly applied.</para></note>
  156. </sect2>
  157. <sect2 role="content"><title/>
  158. <para>Details on this package are located in <xref
  159. linkend="contents-gcc" role="."/></para>
  160. </sect2>
  161. </sect1>