gcc-pass1.xml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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="../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-ch5p1-sbu;</seg>
  29. <seg>&gcc-ch5p1-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>--disable-shared</parameter></term>
  113. <listitem>
  114. <para>This switch forces GCC to link its internal libraries
  115. statically. We need this because the shared libraries require glibc,
  116. which is not yet installed on the target system.</para>
  117. </listitem>
  118. </varlistentry>
  119. <varlistentry>
  120. <term><parameter>--disable-decimal-float, --disable-threads,
  121. --disable-libatomic, --disable-libgomp, <!--- -disable-libmpx,-->
  122. --disable-libquadmath, --disable-libssp, --disable-libvtv,
  123. --disable-libstdcxx</parameter></term>
  124. <listitem>
  125. <para>These switches disable support for the decimal floating point
  126. extension, threading, libatomic, libgomp, <!--libmpx, --> libquadmath, libssp,
  127. libvtv, and the C++ standard library respectively. These features
  128. will fail to compile when building a cross-compiler and are not
  129. necessary for the task of cross-compiling the temporary libc.</para>
  130. </listitem>
  131. </varlistentry>
  132. <varlistentry>
  133. <term><parameter>--disable-multilib</parameter></term>
  134. <listitem>
  135. <para>On x86_64, LFS does not yet support a multilib configuration.
  136. This switch is harmless for x86.</para>
  137. </listitem>
  138. </varlistentry>
  139. <varlistentry>
  140. <term><parameter>--enable-languages=c,c++</parameter></term>
  141. <listitem>
  142. <para>This option ensures that only the C and C++ compilers are built.
  143. These are the only languages needed now.</para>
  144. </listitem>
  145. </varlistentry>
  146. </variablelist>
  147. <para>Compile GCC by running:</para>
  148. <screen><userinput remap="make">make</userinput></screen>
  149. <para>Install the package:</para>
  150. <screen><userinput remap="install">make install</userinput></screen>
  151. <para>This build of GCC has installed a couple of internal system
  152. headers. Normally one of them, <filename>limits.h</filename>, would in turn
  153. include the corresponding system <filename>limits.h</filename> header, in
  154. this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
  155. time of this build of gcc <filename>$LFS/usr/include/limits.h</filename>
  156. does not exist, so the internal header that has just been installed is a
  157. partial, self-contained file and does not include the extended features of
  158. the system header. This is adequate for building glibc, but the full
  159. internal header will be needed later. Create a full version of the internal
  160. header using a command that is identical to what the GCC build system does
  161. in normal circumstances:</para>
  162. <screen><userinput remap="install">cd ..
  163. cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
  164. `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen>
  165. </sect2>
  166. <sect2 role="content">
  167. <title/>
  168. <para>Details on this package are located in
  169. <xref linkend="contents-gcc" role="."/></para>
  170. </sect2>
  171. </sect1>