gcc-pass2.xml 8.8 KB

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