gcc-pass2.xml 9.4 KB

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