gcc-pass2.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. --libexecdir=/tools/lib --with-local-prefix=/tools \
  67. --enable-clocale=gnu --enable-shared --enable-threads=posix \
  68. --enable-__cxa_atexit --enable-languages=c,c++</userinput></screen>
  69. <para>The meaning of the new configure options:</para>
  70. <itemizedlist>
  71. <listitem><para><userinput>--enable-clocale=gnu</userinput>: This option
  72. ensures the correct locale model is selected for the C++ libraries under all
  73. circumstances. If the configure script finds the <emphasis>de_DE</emphasis>
  74. locale installed, it will select the correct <emphasis>gnu</emphasis> locale
  75. model. However, people who don't install the <emphasis>de_DE</emphasis> locale
  76. would run the risk of building ABI incompatible C++ libraries due to the wrong
  77. <emphasis>generic</emphasis> locale model being selected.</para></listitem>
  78. <listitem><para><userinput>--enable-threads=posix</userinput>: This enables
  79. C++ exception handling for multi-threaded code.</para></listitem>
  80. <listitem><para><userinput>--enable-__cxa_atexit</userinput>: This option
  81. allows use of __cxa_atexit, rather than atexit, to register C++ destructors for
  82. local statics and global objects and is essential for fully standards-compliant
  83. handling of destructors. It also affects the C++ ABI and therefore results in
  84. C++ shared libraries and C++ programs that are interoperable with other Linux
  85. distributions.</para></listitem>
  86. <listitem><para><userinput>--enable-languages=c,c++</userinput>: This option
  87. ensures that both the C and C++ compilers are built.</para></listitem>
  88. </itemizedlist>
  89. <para>Compile the package:</para>
  90. <screen><userinput>make</userinput></screen>
  91. <para>There is no need to use the <emphasis>bootstrap</emphasis> target now,
  92. as the compiler we're using to compile this GCC was built from the exact same
  93. version of the GCC sources we used earlier.</para>
  94. <para>Compilation is now complete. As mentioned earlier, we don't recommend
  95. running the test suites for the temporary tools here in this chapter. If you
  96. still want to run the GCC test suite anyway, the following command will do
  97. so:</para>
  98. <screen><userinput>make -k check</userinput></screen>
  99. <para>The <emphasis>-k</emphasis> flag is used to make the test suite run
  100. through to completion and not stop at the first failure. The GCC test suite is
  101. very comprehensive and is almost guaranteed to generate a few failures. To get
  102. a summary of the test suite results, run this:</para>
  103. <screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
  104. <para>(For just the summaries, pipe the output through
  105. <userinput>grep -A7 Summ</userinput>.)</para>
  106. <para>You can compare your results to those posted to the gcc-testresults
  107. mailing list for similar configurations to your own. For an example of how
  108. current GCC-&gcc-version; should look on i686-pc-linux-gnu, see
  109. <ulink url="http://gcc.gnu.org/ml/gcc-testresults/2004-04/msg00414.html"/>.</para>
  110. <para>Having a few unexpected failures often cannot be avoided. The GCC
  111. developers are usually aware of these, but haven't yet gotten around to fixing
  112. them. In short, unless your results are vastly different from those at the above
  113. URL, it is safe to continue.</para>
  114. <para>And finally install the package:</para>
  115. <screen><userinput>make install</userinput></screen>
  116. <note><para>At this point it is strongly recommended to repeat the sanity check
  117. we performed earlier in this chapter. Refer back to
  118. <xref linkend="ch-tools-adjusting"/> and repeat the little test compilation. If
  119. the result is wrong, then most likely you forgot to apply the above mentioned
  120. GCC Specs patch.</para></note>
  121. </sect2>
  122. <sect2><title> </title><para> </para>
  123. <para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
  124. <para> </para></sect2>
  125. </sect1>