gcc-pass2.xml 8.5 KB

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