glibc.xml 14 KB

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