gcc-pass1.xml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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-pass1" role="wrap" xreflabel="gcc-pass1">
  8. <?dbhtml filename="gcc-pass1.html"?>
  9. <sect1info condition="script">
  10. <productname>gcc-pass1</productname>
  11. <productnumber>&gcc-version;</productnumber>
  12. <address>&gcc-url;</address>
  13. </sect1info>
  14. <title>GCC-&gcc-version; - Pass 1</title>
  15. <indexterm zone="ch-tools-gcc-pass1">
  16. <primary sortas="a-GCC">GCC</primary>
  17. <secondary>tools, pass 1</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-tmpp1-sbu;</seg>
  29. <seg>&gcc-tmpp1-du;</seg>
  30. </seglistitem>
  31. </segmentedlist>
  32. </sect2>
  33. <sect2 role="installation">
  34. <title>Installation of Cross GCC</title>
  35. <para>GCC requires the GMP, MPFR and MPC packages. As these packages may
  36. not be included in your host distribution, they will be built with
  37. GCC. Unpack each package into the GCC source directory and rename the
  38. resulting directories so the GCC build procedures will automatically
  39. use them:</para>
  40. <note><para>There are frequent misunderstandings about this chapter. The
  41. procedures are the same as every other chapter as explained earlier (<xref
  42. linkend='buildinstr'/>). First extract the gcc tarball from the sources
  43. directory and then change to the directory created. Only then should you
  44. proceed with the instructions below.</para></note>
  45. <screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
  46. mv -v mpfr-&mpfr-version; mpfr
  47. tar -xf ../gmp-&gmp-version;.tar.xz
  48. mv -v gmp-&gmp-version; gmp
  49. tar -xf ../mpc-&mpc-version;.tar.gz
  50. mv -v mpc-&mpc-version; mpc</userinput></screen>
  51. <para>On x86_64 hosts, set the default directory name for
  52. 64-bit libraries to <quote>lib</quote>:</para>
  53. <screen><userinput remap="pre">case $(uname -m) in
  54. x86_64)
  55. sed -e '/m64=/s/lib64/lib/' \
  56. -i.orig gcc/config/i386/t-linux64
  57. ;;
  58. esac</userinput></screen>
  59. <para>The GCC documentation recommends building GCC
  60. in a dedicated build directory:</para>
  61. <screen><userinput remap="pre">mkdir -v build
  62. cd build</userinput></screen>
  63. <para>Prepare GCC for compilation:</para>
  64. <screen><userinput remap="configure">../configure \
  65. --target=$LFS_TGT \
  66. --prefix=$LFS/tools \
  67. --with-glibc-version=2.11 \
  68. --with-sysroot=$LFS \
  69. --with-newlib \
  70. --without-headers \
  71. --enable-initfini-array \
  72. --disable-nls \
  73. --disable-shared \
  74. --disable-multilib \
  75. --disable-decimal-float \
  76. --disable-threads \
  77. --disable-libatomic \
  78. --disable-libgomp \
  79. --disable-libquadmath \
  80. --disable-libssp \
  81. --disable-libvtv \
  82. --disable-libstdcxx \
  83. --enable-languages=c,c++</userinput></screen>
  84. <variablelist>
  85. <title>The meaning of the configure options:</title>
  86. <varlistentry>
  87. <term><parameter>--with-glibc-version=2.11</parameter></term>
  88. <listitem>
  89. <para>This option ensures the package will be compatible with the host's
  90. version of glibc. It is set to the minimum glibc requirement
  91. specified in the <xref linkend="ch-partitioning-hostreqs"/>.</para>
  92. </listitem>
  93. </varlistentry>
  94. <varlistentry>
  95. <term><parameter>--with-newlib</parameter></term>
  96. <listitem>
  97. <para>Since a working C library is not yet available, this ensures
  98. that the inhibit_libc constant is defined when building libgcc. This prevents
  99. the compiling of any code that requires libc support.</para>
  100. </listitem>
  101. </varlistentry>
  102. <varlistentry>
  103. <term><parameter>--without-headers</parameter></term>
  104. <listitem>
  105. <para>When creating a complete cross-compiler, GCC requires
  106. standard headers compatible with the target system. For our
  107. purposes these headers will not be needed. This switch prevents
  108. GCC from looking for them.</para>
  109. </listitem>
  110. </varlistentry>
  111. <varlistentry>
  112. <term><parameter>--enable-initfini-array</parameter></term>
  113. <listitem>
  114. <para>This switch forces the use of some internal data structures
  115. that are needed but cannot be detected when building a cross
  116. compiler.</para>
  117. </listitem>
  118. </varlistentry>
  119. <varlistentry>
  120. <term><parameter>--disable-shared</parameter></term>
  121. <listitem>
  122. <para>This switch forces GCC to link its internal libraries
  123. statically. We need this because the shared libraries require glibc,
  124. which is not yet installed on the target system.</para>
  125. </listitem>
  126. </varlistentry>
  127. <varlistentry>
  128. <term><parameter>--disable-multilib</parameter></term>
  129. <listitem>
  130. <para>On x86_64, LFS does not support a multilib configuration.
  131. This switch is harmless for x86.</para>
  132. </listitem>
  133. </varlistentry>
  134. <varlistentry>
  135. <term><parameter>--disable-decimal-float, --disable-threads,
  136. --disable-libatomic, --disable-libgomp,
  137. --disable-libquadmath, --disable-libssp, --disable-libvtv,
  138. --disable-libstdcxx</parameter></term>
  139. <listitem>
  140. <para>These switches disable support for the decimal floating point
  141. extension, threading, libatomic, libgomp, libquadmath, libssp,
  142. libvtv, and the C++ standard library respectively. These features
  143. will fail to compile when building a cross-compiler and are not
  144. necessary for the task of cross-compiling the temporary libc.</para>
  145. </listitem>
  146. </varlistentry>
  147. <varlistentry>
  148. <term><parameter>--enable-languages=c,c++</parameter></term>
  149. <listitem>
  150. <para>This option ensures that only the C and C++ compilers are built.
  151. These are the only languages needed now.</para>
  152. </listitem>
  153. </varlistentry>
  154. </variablelist>
  155. <para>Compile GCC by running:</para>
  156. <screen><userinput remap="make">make</userinput></screen>
  157. <para>Install the package:</para>
  158. <screen><userinput remap="install">make install</userinput></screen>
  159. <para>This build of GCC has installed a couple of internal system
  160. headers. Normally one of them, <filename>limits.h</filename>, would in turn
  161. include the corresponding system <filename>limits.h</filename> header, in
  162. this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
  163. time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
  164. does not exist, so the internal header that has just been installed is a
  165. partial, self-contained file and does not include the extended features of
  166. the system header. This is adequate for building glibc, but the full
  167. internal header will be needed later. Create a full version of the internal
  168. header using a command that is identical to what the GCC build system does
  169. in normal circumstances:</para>
  170. <screen><userinput remap="install">cd ..
  171. cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
  172. `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen>
  173. </sect2>
  174. <sect2 role="content">
  175. <title/>
  176. <para>Details on this package are located in
  177. <xref linkend="contents-gcc" role="."/></para>
  178. </sect2>
  179. </sect1>