glibc.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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="../chapter06/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-ch5-sbu;</seg>
  29. <seg>&glibc-ch5-du;</seg>
  30. </seglistitem>
  31. </segmentedlist>
  32. </sect2>
  33. <sect2 role="installation">
  34. <title>Installation of Glibc</title>
  35. <para>The Glibc documentation recommends building Glibc
  36. in a dedicated build directory:</para>
  37. <screen><userinput remap="pre">mkdir -v build
  38. cd build</userinput></screen>
  39. <para>Next, prepare Glibc for compilation:</para>
  40. <screen><userinput remap="configure">../configure \
  41. --prefix=/tools \
  42. --host=$LFS_TGT \
  43. --build=$(../scripts/config.guess) \
  44. --enable-kernel=&min-kernel; \
  45. --with-headers=/tools/include</userinput></screen>
  46. <!--
  47. libc_cv_forced_unwind=yes \
  48. libc_cv_c_cleanup=yes</userinput></screen> -->
  49. <variablelist>
  50. <title>The meaning of the configure options:</title>
  51. <varlistentry>
  52. <term><parameter>--host=$LFS_TGT, --build=$(../scripts/config.guess)</parameter></term>
  53. <listitem>
  54. <para>The combined effect of these switches is that Glibc's build system
  55. configures itself to cross-compile, using the cross-linker and
  56. cross-compiler in <filename class="directory">/tools</filename>.</para>
  57. </listitem>
  58. </varlistentry>
  59. <varlistentry>
  60. <term><parameter>--enable-kernel=&min-kernel;</parameter></term>
  61. <listitem>
  62. <para>This tells Glibc to compile the library with support
  63. for &min-kernel; and later Linux kernels. Workarounds for older
  64. kernels are not enabled.</para>
  65. </listitem>
  66. </varlistentry>
  67. <varlistentry arch="ml_32,ml_x32,ml_all">
  68. <term><parameter>--enable-multi-arch</parameter></term>
  69. <listitem>
  70. <para>Enables glibc for multiarch environments.</para>
  71. </listitem>
  72. </varlistentry>
  73. <varlistentry>
  74. <term><parameter>--with-headers=/tools/include</parameter></term>
  75. <listitem>
  76. <para>This tells Glibc to compile itself against the headers recently
  77. installed to the tools directory, so that it knows exactly what
  78. features the kernel has and can optimize itself accordingly.</para>
  79. </listitem>
  80. </varlistentry>
  81. <!--
  82. <varlistentry>
  83. <term><parameter>libc_cv_forced_unwind=yes</parameter></term>
  84. <listitem>
  85. <para>The linker installed during
  86. <xref linkend="ch-tools-binutils-pass1"/> was cross-compiled and as
  87. such cannot be used until Glibc has been installed. This means that
  88. the configure test for force-unwind support will fail, as it relies on
  89. a working linker. The libc_cv_forced_unwind=yes variable is passed in
  90. order to inform <command>configure</command> that force-unwind
  91. support is available without it having to run the test.</para>
  92. </listitem>
  93. </varlistentry>
  94. <varlistentry>
  95. <term><parameter>libc_cv_c_cleanup=yes</parameter></term>
  96. <listitem>
  97. <para>Similarly, we pass libc_cv_c_cleanup=yes through to the
  98. <command>configure</command> script so that the test is skipped and C
  99. cleanup handling support is configured.</para>
  100. </listitem>
  101. </varlistentry>
  102. -->
  103. <!-- <varlistentry>
  104. <term><parameter>libc_cv_ctors_header=yes</parameter></term>
  105. <listitem>
  106. <para>Similarly, we pass libc_cv_ctors_header=yes through to the
  107. <command>configure</command> script so that the test is skipped and
  108. gcc constructor support is configured.</para>
  109. </listitem>
  110. </varlistentry>-->
  111. </variablelist>
  112. <para>During this stage the following warning might appear:</para>
  113. <blockquote>
  114. <screen><computeroutput>configure: WARNING:
  115. *** These auxiliary programs are missing or
  116. *** incompatible versions: msgfmt
  117. *** some features will be disabled.
  118. *** Check the INSTALL file for required versions.</computeroutput></screen>
  119. </blockquote>
  120. <para>The missing or incompatible <command>msgfmt</command> program is
  121. generally harmless. This <command>msgfmt</command> program is part of the
  122. Gettext package which the host distribution should provide.</para>
  123. <note><para>There have been reports that this package may fail when
  124. building as a "parallel make". If this occurs, rerun the make command
  125. with a "-j1" option.</para></note>
  126. <para>Compile the package:</para>
  127. <screen><userinput remap="make">make</userinput></screen>
  128. <para>Install the package:</para>
  129. <screen><userinput remap="install">make install</userinput></screen>
  130. <caution>
  131. <para>At this point, it is imperative to stop and ensure that the basic
  132. functions (compiling and linking) of the new toolchain are working as
  133. expected. To perform a sanity check, run the following commands:</para>
  134. <screen><userinput>echo 'int main(){}' &gt; dummy.c
  135. $LFS_TGT-gcc dummy.c
  136. readelf -l a.out | grep ': /tools'</userinput></screen>
  137. <para>If everything is working correctly, there should be no errors,
  138. and the output of the last command will be of the form:</para>
  139. <screen><computeroutput>[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
  140. <para>Note that for 32-bit machines, the interpreter name will be
  141. <filename>/tools/lib/ld-linux.so.2</filename>.</para>
  142. <para>If the output is not shown as above or there was no output at all,
  143. then something is wrong. Investigate and retrace the steps to find out
  144. where the problem is and correct it. This issue must be resolved before
  145. continuing on.</para>
  146. <para>Once all is well, clean up the test files:</para>
  147. <screen><userinput>rm -v dummy.c a.out</userinput></screen>
  148. </caution>
  149. <note><para>Building Binutils in the section after next will serve as an
  150. additional check that the toolchain has been built properly. If Binutils
  151. fails to build, it is an indication that something has gone wrong with the
  152. previous Binutils, GCC, or Glibc installations.</para></note>
  153. </sect2>
  154. <sect2 arch="ml_32,ml_all" role="installation">
  155. <title>Installation of Glibc 32-bit</title>
  156. <para>Clean the build directory for redoing glibc for 32-bit:</para>
  157. <screen><userinput remap="pre">mkdir ../build32
  158. cd ../build32</userinput></screen>
  159. <para>Rebuild glibc for 32-bit:</para>
  160. <screen><userinput remap="configure">echo slibdir=/tools/lib32 &gt; configparms
  161. BUILD_CC="gcc -m32" \
  162. CC="${LFS_TGT}-gcc -m32" \
  163. CXX="${LFS_TGT}-g++ -m32" \
  164. AR="${LFS_TGT}-ar" \
  165. RANLIB="${LFS_TGT}-ranlib" \
  166. ../configure --prefix=/tools \
  167. --build=$(../scripts/config.guess) \
  168. --host=${LFS_TGT32} \
  169. --enable-kernel=&min-kernel; \
  170. --enable-multi-arch \
  171. --libdir=/tools/lib32 \
  172. --libexecdir=/tools/lib32 \
  173. --with-headers=/tools/include \
  174. --with-binutils=/tools/bin</userinput></screen>
  175. <!-- \
  176. libc_cv_forced_unwind=yes \
  177. libc_cv_c_cleanup=yes</userinput></screen> -->
  178. <para>Now compile the 32-bit version of glibc:</para>
  179. <screen><userinput remap="make">make</userinput></screen>
  180. <para>Install 32-bit version of glibc:</para>
  181. <screen><userinput remap="install">make install_root="${PWD}/DESTDIR" install
  182. install -vdm755 /tools/lib32
  183. cp -Rv DESTDIR/tools/lib32/* /tools/lib32
  184. install -vm644 DESTDIR/tools/include/gnu/{lib-names,stubs}-32.h \
  185. /tools/include/gnu/
  186. ln -svf /tools/lib32/ld-linux.so.2 /tools/lib/
  187. cd ..</userinput></screen>
  188. </sect2>
  189. <sect2 arch="ml_x32,ml_all" role="installation">
  190. <title>Installation of Glibc x32-bit</title>
  191. <para>Create a build directory for redoing glibc for x32-bit:</para>
  192. <screen><userinput remap="pre">mkdir build32x
  193. cd build32x</userinput></screen>
  194. <para>Rebuild glibc for x32-bit:</para>
  195. <screen><userinput remap="configure">echo slibdir=/tools/libx32 &gt; configparms
  196. BUILD_CC="gcc -mx32" \
  197. CC="${LFS_TGT}-gcc -mx32" \
  198. CXX="${LFS_TGT}-g++ -mx32" \
  199. AR="${LFS_TGT}-ar" \
  200. RANLIB="${LFS_TGT}-ranlib" \
  201. ../configure --prefix=/tools \
  202. --build=$(../scripts/config.guess) \
  203. --host=${LFS_TGTX32} \
  204. --enable-kernel=&min-kernel; \
  205. --enable-multi-arch \
  206. --libdir=/tools/libx32 \
  207. --libexecdir=/tools/libx32 \
  208. --with-headers=/tools/include \
  209. --with-binutils=/tools/bin</userinput></screen>
  210. <!-- \
  211. libc_cv_forced_unwind=yes \
  212. libc_cv_c_cleanup=yes</userinput></screen> -->
  213. <para>Now compile the x32-bit version of glibc:</para>
  214. <screen><userinput remap="make">make</userinput></screen>
  215. <para>Install x32-bit version of glibc:</para>
  216. <screen><userinput remap="install">make install_root="${PWD}/DESTDIR" install
  217. install -vdm755 /tools/libx32
  218. cp -Rv DESTDIR/tools/libx32/* /tools/libx32
  219. install -vm644 DESTDIR/tools/include/gnu/lib-names-x32.h \
  220. /tools/include/gnu/
  221. [ -e DESTDIR/tools/include/gnu/stubs-x32.h ] \
  222. &amp;&amp; install -vm644 DESTDIR/tools/include/gnu/stubs-x32.h /tools/include/gnu/ \
  223. || ln -v /tools/include/gnu/stubs-64.h /tools/include/gnu/stubs-x32.h
  224. ln -svf /tools/libx32/ld-linux-x32.so.2 /tools/lib/</userinput></screen>
  225. <!-- For whatever reason the stubs-x32.h doesn't get created. The 'ln' above is
  226. just a "brute force" workaraound - by copying the stubs-64.h file. -->
  227. <caution>
  228. <para>At this point, it is imperative to stop and ensure that the basic
  229. functions (compiling and linking) of the new toolchain are working as
  230. expected. To perform a sanity check, run the following commands:</para>
  231. <screen><userinput>echo 'int main(){}' &gt; dummy.c
  232. $LFS_TGT-gcc -m32 dummy.c
  233. readelf -l a.out | grep ': /tools'</userinput></screen>
  234. <para>If everything is working correctly, there should be no errors,
  235. and the output of the last command will be of the form:</para>
  236. <screen><computeroutput>[Requesting program interpreter: /tools/lib/ld-linux.so.2]</computeroutput></screen>
  237. <para>Redo test for x32-ABI:</para>
  238. <screen><userinput>echo 'int main(){}' &gt; dummy.c
  239. $LFS_TGT-gcc -mx32 dummy.c
  240. readelf -l a.out | grep ': /tools'</userinput></screen>
  241. <para>Output should be like:</para>
  242. <screen><computeroutput>[Requesting program interpreter: /tools/lib/ld-linux-x32.so.2]</computeroutput></screen>
  243. <para>If the output is not shown as above or there was no output at all,
  244. then something is wrong. Investigate and retrace the steps to find out
  245. where the problem is and correct it. This issue must be resolved before
  246. continuing on.</para>
  247. <para>Once all is well, clean up the test files:</para>
  248. <screen><userinput>rm -v dummy.c a.out</userinput></screen>
  249. </caution>
  250. </sect2>
  251. <sect2 role="content">
  252. <title/>
  253. <para>Details on this package are located in
  254. <xref linkend="contents-glibc" role="."/></para>
  255. </sect2>
  256. </sect1>