glibc.xml 8.2 KB

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