glibc.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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-glibc" role="wrap">
  8. <?dbhtml filename="glibc.html"?>
  9. <sect1info condition="script">
  10. <productname>glibc</productname>
  11. <productnumber>&glibc-version;</productnumber>
  12. <address>&glibc-url;</address>
  13. </sect1info>
  14. <title>Glibc-&glibc-version;</title>
  15. <indexterm zone="ch-tools-glibc">
  16. <primary sortas="a-Glibc">Glibc</primary>
  17. <secondary>tools</secondary>
  18. </indexterm>
  19. <sect2 role="package">
  20. <title/>
  21. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  22. href="../chapter08/glibc.xml"
  23. xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
  24. <segmentedlist>
  25. <segtitle>&buildtime;</segtitle>
  26. <segtitle>&diskspace;</segtitle>
  27. <seglistitem>
  28. <seg>&glibc-tmp-sbu;</seg>
  29. <seg>&glibc-tmp-du;</seg>
  30. </seglistitem>
  31. </segmentedlist>
  32. </sect2>
  33. <sect2 role="installation">
  34. <title>Installation of Glibc</title>
  35. <para>First, create two symbolic links, which are needed for proper
  36. operation of the dynamic library loader:</para>
  37. <screen><userinput remap="pre">ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
  38. ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3</userinput></screen>
  39. <para>Some of the Glibc programs use the non-FHS compliant
  40. <filename class="directory">/var/db</filename> directory to store their
  41. runtime data. Apply the following patch to make such programs store their
  42. runtime data in the FHS-compliant locations:</para>
  43. <screen><userinput remap="pre">patch -Np1 -i ../glibc-&glibc-version;-fhs-1.patch</userinput></screen>
  44. <para>The Glibc documentation recommends building Glibc
  45. in a dedicated build directory:</para>
  46. <screen><userinput remap="pre">mkdir -v build
  47. cd build</userinput></screen>
  48. <para>Next, prepare Glibc for compilation:</para>
  49. <screen><userinput remap="configure">../configure \
  50. --prefix=/usr \
  51. --host=$LFS_TGT \
  52. --build=$(../scripts/config.guess) \
  53. --enable-kernel=&min-kernel; \
  54. --with-headers=$LFS/usr/include \
  55. libc_cv_slibdir=/lib</userinput></screen>
  56. <!--
  57. libc_cv_forced_unwind=yes \
  58. libc_cv_c_cleanup=yes</userinput></screen> -->
  59. <variablelist>
  60. <title>The meaning of the configure options:</title>
  61. <varlistentry>
  62. <term><parameter>--host=$LFS_TGT, --build=$(../scripts/config.guess)</parameter></term>
  63. <listitem>
  64. <para>The combined effect of these switches is that Glibc's build system
  65. configures itself to be cross-compiled, using the cross-linker and
  66. cross-compiler in <filename class="directory">/tools</filename>.</para>
  67. </listitem>
  68. </varlistentry>
  69. <varlistentry>
  70. <term><parameter>--enable-kernel=&min-kernel;</parameter></term>
  71. <listitem>
  72. <para>This tells Glibc to compile the library with support
  73. for &min-kernel; and later Linux kernels. Workarounds for older
  74. kernels are not enabled.</para>
  75. </listitem>
  76. </varlistentry>
  77. <varlistentry>
  78. <term><parameter>--with-headers=$LFS/usr/include</parameter></term>
  79. <listitem>
  80. <para>This tells Glibc to compile itself against the headers recently
  81. installed to the usr/include directory, so that it knows exactly what
  82. features the kernel has and can optimize itself accordingly.</para>
  83. </listitem>
  84. </varlistentry>
  85. <varlistentry>
  86. <term><parameter>libc_cv_slibdir=/lib</parameter></term>
  87. <listitem>
  88. <para>This ensures that the library is installed in /lib instead
  89. of the default /lib64 on 64 bit machines.</para>
  90. </listitem>
  91. </varlistentry>
  92. <!--
  93. <varlistentry>
  94. <term><parameter>libc_cv_c_cleanup=yes</parameter></term>
  95. <listitem>
  96. <para>Similarly, we pass libc_cv_c_cleanup=yes through to the
  97. <command>configure</command> script so that the test is skipped and C
  98. cleanup handling support is configured.</para>
  99. </listitem>
  100. </varlistentry>
  101. <varlistentry>
  102. <term><parameter>libc_cv_ctors_header=yes</parameter></term>
  103. <listitem>
  104. <para>Similarly, we pass libc_cv_ctors_header=yes through to the
  105. <command>configure</command> script so that the test is skipped and
  106. gcc constructor support is configured.</para>
  107. </listitem>
  108. </varlistentry>-->
  109. </variablelist>
  110. <para>During this stage the following warning might appear:</para>
  111. <blockquote>
  112. <screen><computeroutput>configure: WARNING:
  113. *** These auxiliary programs are missing or
  114. *** incompatible versions: msgfmt
  115. *** some features will be disabled.
  116. *** Check the INSTALL file for required versions.</computeroutput></screen>
  117. </blockquote>
  118. <para>The missing or incompatible <command>msgfmt</command> program is
  119. generally harmless. This <command>msgfmt</command> program is part of the
  120. Gettext package which the host distribution should provide.</para>
  121. <note><para>There have been reports that this package may fail when
  122. building as a "parallel make". If this occurs, rerun the make command
  123. with a "-j1" option.</para></note>
  124. <para>Compile the package:</para>
  125. <screen><userinput remap="make">make</userinput></screen>
  126. <para>Install the package:</para>
  127. <warning><para>If <envar>LFS</envar> is not properly set, and despite the
  128. recommendations, you are building as root, the next command will install
  129. the newly built glibc to your host system, which most likely will render it
  130. unusable. So double check that the environment is correctly set for user
  131. <systemitem class="username">lfs</systemitem>.</para></warning>
  132. <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
  133. <variablelist>
  134. <title>The meaning of the <command>make install</command> option:</title>
  135. <varlistentry>
  136. <term><parameter>DESTDIR=$LFS</parameter></term>
  137. <listitem>
  138. <para>The <envar>DESTDIR</envar> make variable is used by almost all
  139. packages to define the location where the package should be
  140. installed. If it is not set, it defaults to the root (<filename
  141. class="directory">/</filename>) directory. Here we specify that
  142. the package be installed in <filename class="directory">$LFS
  143. </filename>, which will become the root after <xref linkend=
  144. "ch-tools-chroot"/>.</para>
  145. </listitem>
  146. </varlistentry>
  147. </variablelist>
  148. <caution>
  149. <para>At this point, it is imperative to stop and ensure that the basic
  150. functions (compiling and linking) of the new toolchain are working as
  151. expected. To perform a sanity check, run the following commands:</para>
  152. <screen><userinput>echo 'int main(){}' &gt; dummy.c
  153. $LFS_TGT-gcc dummy.c
  154. readelf -l a.out | grep '/ld-linux'</userinput></screen>
  155. <para>If everything is working correctly, there should be no errors,
  156. and the output of the last command will be of the form:</para>
  157. <screen><computeroutput>[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
  158. <para>Note that for 32-bit machines, the interpreter name will be
  159. <filename>/lib/ld-linux.so.2</filename>.</para>
  160. <para>If the output is not shown as above or there was no output at all,
  161. then something is wrong. Investigate and retrace the steps to find out
  162. where the problem is and correct it. This issue must be resolved before
  163. continuing on.</para>
  164. <para>Once all is well, clean up the test files:</para>
  165. <screen><userinput>rm -v dummy.c a.out</userinput></screen>
  166. </caution>
  167. <note><para>Building packages in the next chapter will serve as an
  168. additional check that the toolchain has been built properly. If some
  169. package, especially binutils-pass2 or gcc-pass2, fails to build, it is
  170. an indication that something has gone wrong with the
  171. previous Binutils, GCC, or Glibc installations.</para></note>
  172. <para>Now that our cross-toolchain is complete, finalize the installation
  173. of the limits.h header. For doing so, run a utility provided by the GCC
  174. developers:</para>
  175. <screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen>
  176. </sect2>
  177. <sect2 role="content">
  178. <title/>
  179. <para>Details on this package are located in
  180. <xref linkend="contents-glibc" role="."/></para>
  181. </sect2>
  182. </sect1>