gcc-pass2.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/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. </sect2>
  19. <sect2 role="installation">
  20. <title>Re-installation of GCC</title>
  21. <para>The tools required to test GCC and Binutils are installed now: Tcl,
  22. Expect and DejaGNU. Therefore we can now rebuild GCC and Binutils, linking
  23. them against the new Glibc, and test them properly (if running the test suites
  24. in this chapter). One thing to note, however, is that these test suites are
  25. highly dependent on properly functioning pseudo terminals (PTYs) which are
  26. provided by your host. These days, PTYs are most commonly implemented via the
  27. <systemitem class="filesystem">devpts</systemitem> file system. You can quickly check if your host
  28. system is set up correctly in this regard by performing a simple test:</para>
  29. <screen><userinput>expect -c "spawn ls"</userinput></screen>
  30. <para>The response might be:</para>
  31. <blockquote><screen><computeroutput>The system has no more ptys. Ask your system administrator to create more.</computeroutput></screen></blockquote>
  32. <para>If you receive the above message, your host doesn't have its PTYs set up
  33. properly. In this case there is no point in running the test suites for GCC
  34. and Binutils until you are able to resolve the issue. You can consult the LFS
  35. Wiki at <ulink url="&wiki-root;"/> for more information on how to get PTYs
  36. working.</para>
  37. <para>This time we will build both the C and the C++ compilers, so you'll have
  38. to unpack both the core and the g++ tarballs (and testsuite too, if you want to
  39. run the tests). Unpacking them in your working directory, they will all unfold
  40. into a single <filename class="directory">gcc-&gcc-version;/</filename> subdirectory.</para>
  41. <para>First correct a problem and make an essential adjustment:</para>
  42. <screen><userinput>patch -Np1 -i ../gcc-&gcc-short-version;-no_fixincludes-1.patch
  43. patch -Np1 -i ../gcc-&gcc-short-version;-specs-1.patch</userinput></screen>
  44. <para>The first patch disables the GCC <command>fixincludes</command> script. We
  45. mentioned this briefly earlier, but a slightly more in-depth explanation of
  46. the fixincludes process is warranted here. Under normal circumstances, the GCC
  47. <command>fixincludes</command> script scans your system for header files that need to be fixed. It
  48. might find that some Glibc header files on your host system need to be fixed,
  49. fix them and put them in the GCC private include directory. Then, later on in
  50. <xref linkend="chapter-building-system"/>, after we've installed the newer
  51. Glibc, this private include directory would be searched before the system
  52. include directory, resulting in GCC finding the fixed headers from the host
  53. system, which would most likely not match the Glibc version actually used for
  54. the LFS system.</para>
  55. <para>The second patch changes GCC's default location of the dynamic linker
  56. (typically <filename>ld-linux.so.2</filename>). It also removes
  57. <filename class="directory">/usr/include</filename> from GCC's include search
  58. path. Patching now rather than adjusting the specs file after installation
  59. ensures that our new dynamic linker gets used during the actual build of GCC.
  60. That is, all the final (and temporary) binaries created during the build will
  61. link against the new Glibc.</para>
  62. <important><para>The above patches are <emphasis>critical</emphasis> in ensuring
  63. a successful overall build. Do not forget to apply them.</para></important>
  64. <para>Create a separate build directory again:</para>
  65. <screen><userinput>mkdir ../gcc-build
  66. cd ../gcc-build</userinput></screen>
  67. <para>Before starting to build GCC, remember to unset any environment
  68. variables that override the default optimization flags.</para>
  69. <para>Now prepare GCC for compilation:</para>
  70. <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
  71. --libexecdir=/tools/lib --with-local-prefix=/tools \
  72. --enable-clocale=gnu --enable-shared --enable-threads=posix \
  73. --enable-__cxa_atexit --enable-languages=c,c++ \
  74. --disable-libstdcxx-pch</userinput></screen>
  75. <para>The meaning of the new configure options:</para>
  76. <variablelist>
  77. <varlistentry>
  78. <term><parameter>--enable-clocale=gnu</parameter></term>
  79. <listitem><para>This option
  80. ensures the correct locale model is selected for the C++ libraries under all
  81. circumstances. If the configure script finds the <emphasis>de_DE</emphasis>
  82. locale installed, it will select the correct <emphasis>gnu</emphasis> locale
  83. model. However, people who don't install the <emphasis>de_DE</emphasis> locale
  84. would run the risk of building ABI incompatible C++ libraries due to the wrong
  85. <emphasis>generic</emphasis> locale model being selected.</para></listitem>
  86. </varlistentry>
  87. <varlistentry>
  88. <term><parameter>--enable-threads=posix</parameter></term>
  89. <listitem><para>This enables
  90. C++ exception handling for multi-threaded code.</para></listitem>
  91. </varlistentry>
  92. <varlistentry>
  93. <term><parameter>--enable-__cxa_atexit</parameter></term>
  94. <listitem><para>This option
  95. allows use of __cxa_atexit, rather than atexit, to register C++ destructors for
  96. local statics and global objects and is essential for fully standards-compliant
  97. handling of destructors. It also affects the C++ ABI and therefore results in
  98. C++ shared libraries and C++ programs that are interoperable with other Linux
  99. distributions.</para></listitem>
  100. </varlistentry>
  101. <varlistentry>
  102. <term><parameter>--enable-languages=c,c++</parameter></term>
  103. <listitem><para>This option
  104. ensures that both the C and C++ compilers are built.</para></listitem>
  105. </varlistentry>
  106. <varlistentry>
  107. <term><parameter>--disable-libstdcxx-pch</parameter></term>
  108. <listitem><para>Don't build the
  109. PCH (pre-compiled header) for libstdc++. It takes up a ton of space, and we
  110. have no use for it.</para></listitem>
  111. </varlistentry>
  112. </variablelist>
  113. <para>Compile the package:</para>
  114. <screen><userinput>make</userinput></screen>
  115. <para>There is no need to use the <parameter>bootstrap</parameter> target now,
  116. as the compiler we're using to compile this GCC was built from the exact same
  117. version of the GCC sources we used earlier.</para>
  118. <para>Compilation is now complete. As mentioned earlier, we don't recommend
  119. running the test suites for the temporary tools here in this chapter. If you
  120. still want to run the GCC test suite anyway, the following command will do
  121. so:</para>
  122. <screen><userinput>make -k check</userinput></screen>
  123. <para>The <parameter>-k</parameter> flag is used to make the test suite run
  124. through to completion and not stop at the first failure. The GCC test suite is
  125. very comprehensive and is almost guaranteed to generate a few failures. To get
  126. a summary of the test suite results, run this:</para>
  127. <screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
  128. <para>(For just the summaries, pipe the output through
  129. <userinput>grep -A7 Summ</userinput>.)</para>
  130. <para>You can compare your results to those posted to the gcc-testresults
  131. mailing list for similar configurations to your own. For an example of how
  132. current GCC-&gcc-version; should look on i686-pc-linux-gnu, see
  133. <ulink url="http://gcc.gnu.org/ml/gcc-testresults/2004-04/msg00414.html"/>.</para>
  134. <para>Having a few unexpected failures often cannot be avoided. The GCC
  135. developers are usually aware of these, but haven't yet gotten around to fixing
  136. them. In short, unless your results are vastly different from those at the above
  137. URL, it is safe to continue.</para>
  138. <para>And finally install the package:</para>
  139. <screen><userinput>make install</userinput></screen>
  140. <note><para>At this point it is strongly recommended to repeat the sanity check
  141. we performed earlier in this chapter. Refer back to
  142. <xref linkend="ch-tools-adjusting"/> and repeat the little test compilation. If
  143. the result is wrong, then most likely you forgot to apply the above mentioned
  144. GCC Specs patch.</para></note>
  145. </sect2>
  146. <sect2 role="content"><title/>
  147. <para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
  148. </sect2>
  149. </sect1>