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. <para>Fix an issue with GCC-10.1 when building with a cross
  52. compiler:</para>
  53. <screen><userinput remap="pre">patch -Np1 -i ../&gcc-cross-patch;</userinput></screen>
  54. <para>Create a separate build directory again:</para>
  55. <screen><userinput remap="pre">mkdir -v build
  56. cd build</userinput></screen>
  57. <para>Create a symlink that allows libgcc to be built with posix threads
  58. support:</para>
  59. <screen><userinput remap="pre">mkdir -pv $LFS_TGT/libgcc
  60. ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h</userinput></screen>
  61. <para>Before starting to build GCC, remember to unset any environment
  62. variables that override the default optimization flags.</para>
  63. <para>Now prepare GCC for compilation:</para>
  64. <screen><userinput remap="configure">../configure \
  65. --build=$(../config.guess) \
  66. --host=$LFS_TGT \
  67. --prefix=/usr \
  68. CC_FOR_TARGET=$LFS_TGT-gcc \
  69. --with-build-sysroot=$LFS \
  70. --enable-initfini-array \
  71. --disable-nls \
  72. --disable-multilib \
  73. --disable-decimal-float \
  74. --disable-libatomic \
  75. --disable-libgomp \
  76. --disable-libquadmath \
  77. --disable-libssp \
  78. --disable-libvtv \
  79. --disable-libstdcxx \
  80. --enable-languages=c,c++</userinput></screen>
  81. <variablelist>
  82. <title>The meaning of the new configure options:</title><!-- WIP -->
  83. <varlistentry>
  84. <term><parameter>-with-build-sysroot=$LFS</parameter></term>
  85. <listitem>
  86. <para>Normally, using <parameter>--host</parameter> ensures that
  87. a cross-compiler is used for building GCC, and that compiler knows
  88. that it has to look for headers and libraries in <filename
  89. class="directory">$LFS</filename>. But the build system of GCC uses
  90. other tools, which are not aware of this location. This switch is
  91. needed to have them find the needed files in <filename
  92. class="directory">$LFS</filename>, and not on the host.</para>
  93. </listitem>
  94. </varlistentry>
  95. <varlistentry>
  96. <term><parameter>--enable-initfini-array</parameter></term>
  97. <listitem>
  98. <para>This option is automatically enabled when building a native
  99. compiler with a native compiler on x86. But here, we build with
  100. a cross compiler, so we need to explicitely set this option.</para>
  101. </listitem>
  102. </varlistentry>
  103. </variablelist>
  104. <para>Compile the package:</para>
  105. <screen><userinput remap="make">make</userinput></screen>
  106. <para>Install the package:</para>
  107. <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
  108. <para>As a finishing touch, create a utility symlink. Many programs and scripts
  109. run <command>cc</command> instead of <command>gcc</command>, which is
  110. used to keep programs generic and therefore usable on all kinds of UNIX
  111. systems where the GNU C compiler is not always installed. Running
  112. <command>cc</command> leaves the system administrator free to decide
  113. which C compiler to install:</para>
  114. <screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen>
  115. </sect2>
  116. <sect2 role="content">
  117. <title/>
  118. <para>Details on this package are located in
  119. <xref linkend="contents-gcc" role="."/></para>
  120. </sect2>
  121. </sect1>