gcc-pass2.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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" xreflabel="gcc-pass2">
  8. <?dbhtml filename="gcc-pass2.html"?>
  9. <sect1info condition="script">
  10. <productname>gcc-pass2</productname>
  11. <productnumber>&gcc-version;</productnumber>
  12. <address>&gcc-url;</address>
  13. </sect1info>
  14. <title>GCC-&gcc-version; - Pass 2</title>
  15. <indexterm zone="ch-tools-gcc-pass2">
  16. <primary sortas="a-GCC">GCC</primary>
  17. <secondary>tools, pass 2</secondary>
  18. </indexterm>
  19. <sect2 role="package">
  20. <title/>
  21. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  22. href="../chapter08/gcc.xml"
  23. xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
  24. <segmentedlist>
  25. <segtitle>&buildtime;</segtitle>
  26. <segtitle>&diskspace;</segtitle>
  27. <seglistitem>
  28. <seg>&gcc-tmpp2-sbu;</seg>
  29. <seg>&gcc-tmpp2-du;</seg>
  30. </seglistitem>
  31. </segmentedlist>
  32. </sect2>
  33. <sect2 role="installation">
  34. <title>Installation of GCC</title>
  35. <para>As in the first build of GCC, the GMP, MPFR, and MPC packages are
  36. required. Unpack the tarballs and move them into the required directory
  37. names:</para>
  38. <screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
  39. mv -v mpfr-&mpfr-version; mpfr
  40. tar -xf ../gmp-&gmp-version;.tar.xz
  41. mv -v gmp-&gmp-version; gmp
  42. tar -xf ../mpc-&mpc-version;.tar.gz
  43. mv -v mpc-&mpc-version; mpc</userinput></screen>
  44. <para>If building on x86_64, change the default directory name for 64-bit
  45. libraries to <quote>lib</quote>:</para>
  46. <screen><userinput remap="pre">case $(uname -m) in
  47. x86_64)
  48. sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
  49. ;;
  50. esac</userinput></screen>
  51. <!--
  52. <para>Fix an issue with GCC-10.1 when building with a cross
  53. compiler:</para>
  54. <screen><userinput remap="pre">patch -Np1 -i ../&gcc-cross-patch;</userinput></screen>
  55. -->
  56. <para>Create a separate build directory again:</para>
  57. <screen><userinput remap="pre">mkdir -v build
  58. cd build</userinput></screen>
  59. <para>Create a symlink that allows libgcc to be built with posix threads
  60. support:</para>
  61. <screen><userinput remap="pre">mkdir -pv $LFS_TGT/libgcc
  62. ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h</userinput></screen>
  63. <para>Before starting to build GCC, remember to unset any environment
  64. variables that override the default optimization flags.</para>
  65. <para>Now prepare GCC for compilation:</para>
  66. <screen><userinput remap="configure">../configure \
  67. --build=$(../config.guess) \
  68. --host=$LFS_TGT \
  69. --prefix=/usr \
  70. CC_FOR_TARGET=$LFS_TGT-gcc \
  71. --with-build-sysroot=$LFS \
  72. --enable-initfini-array \
  73. --disable-nls \
  74. --disable-multilib \
  75. --disable-decimal-float \
  76. --disable-libatomic \
  77. --disable-libgomp \
  78. --disable-libquadmath \
  79. --disable-libssp \
  80. --disable-libvtv \
  81. --disable-libstdcxx \
  82. --enable-languages=c,c++</userinput></screen>
  83. <variablelist>
  84. <title>The meaning of the new configure options:</title><!-- WIP -->
  85. <varlistentry>
  86. <term><parameter>-with-build-sysroot=$LFS</parameter></term>
  87. <listitem>
  88. <para>Normally, using <parameter>--host</parameter> ensures that
  89. a cross-compiler is used for building GCC, and that compiler knows
  90. that it has to look for headers and libraries in <filename
  91. class="directory">$LFS</filename>. But the build system of GCC uses
  92. other tools, which are not aware of this location. This switch is
  93. needed to have them find the needed files in <filename
  94. class="directory">$LFS</filename>, and not on the host.</para>
  95. </listitem>
  96. </varlistentry>
  97. <varlistentry>
  98. <term><parameter>--enable-initfini-array</parameter></term>
  99. <listitem>
  100. <para>This option is automatically enabled when building a native
  101. compiler with a native compiler on x86. But here, we build with
  102. a cross compiler, so we need to explicitly set this option.</para>
  103. </listitem>
  104. </varlistentry>
  105. </variablelist>
  106. <para>Compile the package:</para>
  107. <screen><userinput remap="make">make</userinput></screen>
  108. <para>Install the package:</para>
  109. <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
  110. <para>As a finishing touch, create a utility symlink. Many programs and scripts
  111. run <command>cc</command> instead of <command>gcc</command>, which is
  112. used to keep programs generic and therefore usable on all kinds of UNIX
  113. systems where the GNU C compiler is not always installed. Running
  114. <command>cc</command> leaves the system administrator free to decide
  115. which C compiler to install:</para>
  116. <screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen>
  117. </sect2>
  118. <sect2 role="content">
  119. <title/>
  120. <para>Details on this package are located in
  121. <xref linkend="contents-gcc" role="."/></para>
  122. </sect2>
  123. </sect1>