gcc-pass2.xml 5.5 KB

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