gcc-pass2.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/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>&gcc-ch5p2-sbu;</seg>
  24. <seg>&gcc-ch5p2-du;</seg>
  25. </seglistitem>
  26. </segmentedlist>
  27. </sect2>
  28. <sect2 role="installation">
  29. <title>Re-installation of GCC</title>
  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 PTYs
  44. set up properly. In this case, there is no point in running the test
  45. suites for GCC and Binutils until this issue is resolved. Please consult
  46. the LFS FAQ at <ulink url="&lfs-root;/lfs/faq.html#no-ptys"/> for more
  47. information on how to get PTYs working.</para>
  48. <para>As previously explained in <xref linkend="ch-tools-adjusting"/>,
  49. under normal circumstances the GCC <command>fixincludes</command> script
  50. is run in order to fix potentially broken header files. As GCC-&gcc-version;
  51. and Glibc-&glibc-version; have already been installed at this point, and
  52. their respective header files are known to not require fixing, the
  53. <command>fixincludes</command> script is not required. As mentioned
  54. previously, the script may in fact pollute the build environment by
  55. installing fixed headers from the host system into GCC's private include
  56. directory. The running of the <command>fixincludes</command> script can
  57. be suppressed by issuing the following commands:</para>
  58. <screen><userinput>cp -v gcc/Makefile.in{,.orig} &amp;&amp;
  59. sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig &gt; gcc/Makefile.in</userinput></screen>
  60. <para>The bootstrap build performed in <xref linkend="ch-tools-gcc-pass1"/>
  61. built GCC with the <option>-fomit-frame-pointer</option> compiler flag.
  62. Non-bootstrap builds omit this flag by default, so apply the following
  63. <command>sed</command> to use it in order to ensure consistent compiler
  64. builds:</para>
  65. <screen><userinput>cp -v gcc/Makefile.in{,.tmp} &amp;&amp;
  66. sed 's/^XCFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in.tmp \
  67. &gt; gcc/Makefile.in</userinput></screen>
  68. <para>Apply the following patch to change the location of GCC's default
  69. dynamic linker (typically <filename
  70. class="libraryfile">ld-linux.so.2</filename>):</para>
  71. <screen><userinput>patch -Np1 -i ../&gcc-specs-patch;</userinput></screen>
  72. <para>The above patch also removes <filename
  73. class="directory">/usr/include</filename> from GCC's include search path.
  74. Patching now rather than adjusting the specs file after installation
  75. ensures that the new dynamic linker is used during the actual build of
  76. GCC. That is, all of the binaries created during the build will link
  77. against the new Glibc.</para>
  78. <important>
  79. <para>The above patch is critical in ensuring a successful overall
  80. build. Do not forget to apply it.</para>
  81. </important>
  82. <para>Create a separate build directory again:</para>
  83. <screen><userinput>mkdir -v ../gcc-build
  84. cd ../gcc-build</userinput></screen>
  85. <para>Before starting to build GCC, remember to unset any environment
  86. variables that override the default optimization flags.</para>
  87. <para>Now prepare GCC for compilation:</para>
  88. <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
  89. --with-local-prefix=/tools --enable-clocale=gnu \
  90. --enable-shared --enable-threads=posix \
  91. --enable-__cxa_atexit --enable-languages=c,c++ \
  92. --disable-libstdcxx-pch</userinput></screen>
  93. <variablelist>
  94. <title>The meaning of the new configure options:</title>
  95. <varlistentry>
  96. <term><parameter>--enable-clocale=gnu</parameter></term>
  97. <listitem>
  98. <para>This option ensures the correct locale model is selected
  99. for the C++ libraries under all circumstances. If the configure
  100. script finds the <emphasis>de_DE</emphasis> locale installed,
  101. it will select the correct gnu locale model. However, if the
  102. <emphasis>de_DE</emphasis> locale is not installed, there is the
  103. risk of building Application Binary Interface (ABI)-incompatible
  104. C++ libraries because the incorrect generic locale model may be
  105. selected.</para>
  106. </listitem>
  107. </varlistentry>
  108. <varlistentry>
  109. <term><parameter>--enable-threads=posix</parameter></term>
  110. <listitem>
  111. <para>This enables C++ exception handling for multi-threaded code.</para>
  112. </listitem>
  113. </varlistentry>
  114. <varlistentry>
  115. <term><parameter>--enable-__cxa_atexit</parameter></term>
  116. <listitem>
  117. <para>This option allows use of <function>__cxa_atexit</function>,
  118. rather than <function>atexit</function>, to register C++ destructors
  119. for local statics and global objects. This option is essential for
  120. fully standards-compliant handling of destructors. It also affects
  121. the C++ ABI, and therefore results in C++ shared libraries and C++
  122. programs that are interoperable with other Linux distributions.</para>
  123. </listitem>
  124. </varlistentry>
  125. <varlistentry>
  126. <term><parameter>--enable-languages=c,c++</parameter></term>
  127. <listitem>
  128. <para>This option ensures that both the C and C++ compilers are
  129. built.</para>
  130. </listitem>
  131. </varlistentry>
  132. <varlistentry>
  133. <term><parameter>--disable-libstdcxx-pch</parameter></term>
  134. <listitem>
  135. <para>Do not build the pre-compiled header (PCH) for
  136. <filename class="libraryfile">libstdc++</filename>. It takes up a
  137. lot of space, and we have no use for it.</para>
  138. </listitem>
  139. </varlistentry>
  140. </variablelist>
  141. <para>Compile the package:</para>
  142. <screen><userinput>make</userinput></screen>
  143. <para>There is no need to use the <parameter>bootstrap</parameter> target
  144. now because the compiler being used to compile this GCC was built from
  145. the exact same version of the GCC sources used earlier.</para>
  146. <para>Compilation is now complete. As previously mentioned, running the test
  147. suites for the temporary tools compiled in this chapter is not mandatory.
  148. To run the GCC test suite anyway, use the following command:</para>
  149. <screen><userinput>make -k check</userinput></screen>
  150. <para>The <parameter>-k</parameter> flag is used to make the test suite run
  151. through to completion and not stop at the first failure. The GCC test
  152. suite is very comprehensive and is almost guaranteed to generate a few
  153. failures.</para>
  154. <para>For a discussion of test failures that are of particular
  155. importance, please see <xref linkend="ch-system-gcc" role="."/></para>
  156. <para>Install the package:</para>
  157. <screen><userinput>make install</userinput></screen>
  158. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  159. href="adjusting.xml"
  160. xpointer="xpointer(/sect1/caution[1])"/>
  161. </sect2>
  162. <sect2 role="content">
  163. <title/>
  164. <para>Details on this package are located in
  165. <xref linkend="contents-gcc" role="."/></para>
  166. </sect2>
  167. </sect1>