glibc.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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 arch="default"><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. <!-- no ld-linux.so.2 here as multilib is based on x86_64, not on i686 -->
  46. <screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
  47. ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3</userinput></screen>
  48. <note>
  49. <para>
  50. The above command is correct. The <command>ln</command> command has
  51. a few syntactic versions, so be sure to check
  52. <command>info coreutils ln</command> and <filename>ln(1)</filename>
  53. before reporting what you may think is an error.
  54. </para>
  55. </note>
  56. <para>Some of the Glibc programs use the non-FHS compliant
  57. <filename class="directory">/var/db</filename> directory to store their
  58. runtime data. Apply the following patch to make such programs store their
  59. runtime data in the FHS-compliant locations:</para>
  60. <screen><userinput remap="pre">patch -Np1 -i ../glibc-&glibc-version;-fhs-1.patch</userinput></screen>
  61. <para>The Glibc documentation recommends building Glibc
  62. in a dedicated build directory:</para>
  63. <screen><userinput remap="pre">mkdir -v build
  64. cd build</userinput></screen>
  65. <para>Next, prepare Glibc for compilation:</para>
  66. <screen arch="default"><userinput remap="configure">../configure \
  67. --prefix=/usr \
  68. --host=$LFS_TGT \
  69. --build=$(../scripts/config.guess) \
  70. --enable-kernel=&min-kernel; \
  71. --with-headers=$LFS/usr/include \
  72. libc_cv_slibdir=/lib</userinput></screen>
  73. <screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../configure \
  74. --prefix=/usr \
  75. --host=$LFS_TGT \
  76. --build=$(../scripts/config.guess) \
  77. --enable-kernel=&min-kernel; \
  78. --with-headers=$LFS/usr/include \
  79. --enable-multi-arch \
  80. --libdir=/usr/lib \
  81. --libexecdir=/usr/lib \
  82. libc_cv_slibdir=/lib</userinput></screen>
  83. <!--
  84. libc_cv_forced_unwind=yes \
  85. libc_cv_c_cleanup=yes</userinput></screen> -->
  86. <variablelist>
  87. <title>The meaning of the configure options:</title>
  88. <varlistentry>
  89. <term><parameter>--host=$LFS_TGT, --build=$(../scripts/config.guess)</parameter></term>
  90. <listitem>
  91. <para>The combined effect of these switches is that Glibc's build system
  92. configures itself to be cross-compiled, using the cross-linker and
  93. cross-compiler in <filename class="directory">$LFS/tools</filename>.</para>
  94. </listitem>
  95. </varlistentry>
  96. <varlistentry>
  97. <term><parameter>--enable-kernel=&min-kernel;</parameter></term>
  98. <listitem>
  99. <para>This tells Glibc to compile the library with support
  100. for &min-kernel; and later Linux kernels. Workarounds for older
  101. kernels are not enabled.</para>
  102. </listitem>
  103. </varlistentry>
  104. <varlistentry>
  105. <term><parameter>--with-headers=$LFS/usr/include</parameter></term>
  106. <listitem>
  107. <para>This tells Glibc to compile itself against the headers
  108. recently installed to the $LFS/usr/include directory, so that
  109. it knows exactly what features the kernel has and can optimize
  110. itself accordingly.</para>
  111. </listitem>
  112. </varlistentry>
  113. <varlistentry>
  114. <term><parameter>libc_cv_slibdir=/lib</parameter></term>
  115. <listitem>
  116. <para>This ensures that the library is installed in /lib instead
  117. of the default /lib64 on 64 bit machines.</para>
  118. </listitem>
  119. </varlistentry>
  120. <varlistentry>
  121. <term><option>libc_cv_include_x86_isa_level=no</option></term>
  122. <listitem>
  123. <para>This disables <quote>x86 ISA needed</quote> property in
  124. Glibc libraries. Use it <emphasis role="bold">if</emphasis>
  125. you are building Glibc with <option>-march</option> option in
  126. <envar>CFLAGS</envar>, to workaround an issue in Glibc-2.33
  127. breaking it.</para>
  128. </listitem>
  129. </varlistentry>
  130. </variablelist>
  131. <para>During this stage the following warning might appear:</para>
  132. <blockquote>
  133. <screen><computeroutput>configure: WARNING:
  134. *** These auxiliary programs are missing or
  135. *** incompatible versions: msgfmt
  136. *** some features will be disabled.
  137. *** Check the INSTALL file for required versions.</computeroutput></screen>
  138. </blockquote>
  139. <para>The missing or incompatible <command>msgfmt</command> program is
  140. generally harmless. This <command>msgfmt</command> program is part of the
  141. Gettext package which the host distribution should provide.</para>
  142. <note><para>There have been reports that this package may fail when
  143. building as a "parallel make". If this occurs, rerun the make command
  144. with a "-j1" option.</para></note>
  145. <para>Compile the package:</para>
  146. <screen><userinput remap="make">make</userinput></screen>
  147. <para>Install the package:</para>
  148. <warning><para>If <envar>LFS</envar> is not properly set, and despite the
  149. recommendations, you are building as
  150. <systemitem class="username">root</systemitem>, the next command will
  151. install the newly built glibc to your host system, which most likely
  152. will render it unusable. So double check that the environment is
  153. correctly set, before running the following command.</para></warning>
  154. <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
  155. <variablelist>
  156. <title>The meaning of the <command>make install</command> option:</title>
  157. <varlistentry>
  158. <term><parameter>DESTDIR=$LFS</parameter></term>
  159. <listitem>
  160. <para>The <envar>DESTDIR</envar> make variable is used by almost all
  161. packages to define the location where the package should be
  162. installed. If it is not set, it defaults to the root (<filename
  163. class="directory">/</filename>) directory. Here we specify that
  164. the package be installed in <filename class="directory">$LFS
  165. </filename>, which will become the root after <xref linkend=
  166. "ch-tools-chroot"/>.</para>
  167. </listitem>
  168. </varlistentry>
  169. </variablelist>
  170. <caution>
  171. <para>At this point, it is imperative to stop and ensure that the basic
  172. functions (compiling and linking) of the new toolchain are working as
  173. expected. To perform a sanity check, run the following commands:</para>
  174. <screen><userinput>echo 'int main(){}' &gt; dummy.c
  175. $LFS_TGT-gcc dummy.c
  176. readelf -l a.out | grep '/ld-linux'</userinput></screen>
  177. <para>If everything is working correctly, there should be no errors,
  178. and the output of the last command will be of the form:</para>
  179. <screen><computeroutput>[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
  180. <para arch="default">Note that for 32-bit machines, the interpreter name will be
  181. <filename>/lib/ld-linux.so.2</filename>.</para>
  182. <para>If the output is not shown as above or there was no output at all,
  183. then something is wrong. Investigate and retrace the steps to find out
  184. where the problem is and correct it. This issue must be resolved before
  185. continuing on.</para>
  186. <para>Once all is well, clean up the test files:</para>
  187. <screen><userinput>rm -v dummy.c a.out</userinput></screen>
  188. </caution>
  189. <note><para>Building packages in the next chapter will serve as an
  190. additional check that the toolchain has been built properly. If some
  191. package, especially binutils-pass2 or gcc-pass2, fails to build, it is
  192. an indication that something has gone wrong with the
  193. previous Binutils, GCC, or Glibc installations.</para></note>
  194. <para>Now that our cross-toolchain is complete, finalize the installation
  195. of the limits.h header. For doing so, run a utility provided by the GCC
  196. developers:</para>
  197. <screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen>
  198. </sect2>
  199. <!-- - - - - - - - - - -->
  200. <!-- Multilib - 32bit -->
  201. <!-- - - - - - - - - - -->
  202. <sect2 arch="ml_32,ml_all">
  203. <title>Building Glibc - 32bit</title>
  204. <para>Now recompile for m32. The extracted source can be
  205. reused but needs to cleaned before installing the m32
  206. version of Glibc.</para>
  207. <para>Clear the build directory and remove artefacts from
  208. previous build:</para>
  209. <screen><userinput remap="pre">make clean
  210. find .. -name "*.a" -delete</userinput></screen>
  211. <para>Configure Glibc for m32 with the following commands:</para>
  212. <screen><userinput remap="configure">CC="$LFS_TGT-gcc -m32" \
  213. CXX="$LFS_TGT-g++ -m32" \
  214. ../configure \
  215. --prefix=/usr \
  216. --host=$LFS_TGT32 \
  217. --build=$(../scripts/config.guess) \
  218. --enable-kernel=&min-kernel; \
  219. --with-headers=$LFS/usr/include \
  220. --enable-multi-arch \
  221. --libdir=&usr-lib-m32; \
  222. --libexecdir=&usr-lib-m32; \
  223. libc_cv_slibdir=&lib-m32;</userinput></screen>
  224. <para>Compile the package:</para>
  225. <screen><userinput remap="make">make</userinput></screen>
  226. <para>Install the package:</para>
  227. <screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
  228. cp -a DESTDIR&lib-m32;/* $LFS&lib-m32;/
  229. cp -a DESTDIR&usr-lib-m32; $LFS/usr/
  230. install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \
  231. $LFS/usr/include/gnu/
  232. ln -svf ..&lib-m32;/ld-linux.so.2 $LFS/lib/ld-linux.so.2</userinput></screen>
  233. <caution>
  234. <para>At this point, it is imperative to stop and ensure that the basic
  235. functions (compiling and linking) of the new toolchain are working as
  236. expected. To perform a sanity check, run the following commands:</para>
  237. <screen><userinput>echo 'int main(){}' &gt; dummy.c
  238. $LFS_TGT-gcc -m32 dummy.c
  239. readelf -l a.out | grep '/ld-linux'</userinput></screen>
  240. <para>If everything is working correctly, there should be no errors,
  241. and the output of the last command will be of the form:</para>
  242. <screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.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><!-- m32 -->
  251. <!-- - - - - - - - - - -->
  252. <!-- Multilib - x32bit -->
  253. <!-- - - - - - - - - - -->
  254. <sect2 arch="ml_x32,ml_all">
  255. <title>Building Glibc - x32bit</title>
  256. <para>Now recompile for mx32. The extracted source can be
  257. reused but needs to cleaned before installing the mx32
  258. version of Glibc.</para>
  259. <para>Clear the build directory and remove artefacts from
  260. previous build:</para>
  261. <screen><userinput remap="pre">make clean
  262. find .. -name "*.a" -delete</userinput></screen>
  263. <para>Configure Glibc for mx32 with the following commands:</para>
  264. <screen><userinput remap="configure">CC="$LFS_TGT-gcc -mx32" \
  265. CXX="$LFS_TGT-g++ -mx32" \
  266. ../configure \
  267. --prefix=/usr \
  268. --host=$LFS_TGTX32 \
  269. --build=$(../scripts/config.guess) \
  270. --enable-kernel=&min-kernel; \
  271. --with-headers=$LFS/usr/include \
  272. --enable-multi-arch \
  273. --libdir=&usr-lib-mx32; \
  274. --libexecdir=&usr-lib-mx32; \
  275. libc_cv_slibdir=&lib-mx32;</userinput></screen>
  276. <para>Compile the package:</para>
  277. <screen><userinput remap="make">make</userinput></screen>
  278. <para>Install the package:</para>
  279. <screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
  280. cp -a DESTDIR&lib-mx32;/* $LFS&lib-mx32;/
  281. cp -a DESTDIR&usr-lib-mx32; $LFS/usr/
  282. install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-x32.h \
  283. $LFS/usr/include/gnu/
  284. ln -svf ..&lib-mx32;/ld-linux-x32.so.2 $LFS/lib/ld-linux-x32.so.2</userinput></screen>
  285. <caution>
  286. <para>At this point, it is imperative to stop and ensure that the basic
  287. functions (compiling and linking) of the new toolchain are working as
  288. expected. To perform a sanity check, run the following commands:</para>
  289. <screen><userinput>echo 'int main(){}' &gt; dummy.c
  290. $LFS_TGT-gcc -mx32 dummy.c
  291. readelf -l a.out | grep '/ld-linux-x32'</userinput></screen>
  292. <para>If everything is working correctly, there should be no errors,
  293. and the output of the last command will be of the form:</para>
  294. <screen><computeroutput>[Requesting program interpreter: /libx32/ld-linux-x32.so.2]</computeroutput></screen>
  295. <para>If the output is not shown as above or there was no output at all,
  296. then something is wrong. Investigate and retrace the steps to find out
  297. where the problem is and correct it. This issue must be resolved before
  298. continuing on.</para>
  299. <para>Once all is well, clean up the test files:</para>
  300. <screen><userinput>rm -v dummy.c a.out</userinput></screen>
  301. </caution>
  302. </sect2><!-- mx32 -->
  303. <sect2 role="content">
  304. <title/>
  305. <para>Details on this package are located in
  306. <xref linkend="contents-glibc" role="."/></para>
  307. </sect2>
  308. </sect1>