glibc.xml 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  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-system-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-system-glibc">
  16. <primary sortas="a-Glibc">Glibc</primary>
  17. </indexterm>
  18. <sect2 role="package">
  19. <title/>
  20. <para>The Glibc package contains the main C library. This library provides
  21. the basic routines for allocating memory, searching directories, opening and
  22. closing files, reading and writing files, string handling, pattern matching,
  23. arithmetic, and so on.</para>
  24. <segmentedlist>
  25. <segtitle>&buildtime;</segtitle>
  26. <segtitle>&diskspace;</segtitle>
  27. <seglistitem>
  28. <seg>&glibc-fin-sbu;</seg>
  29. <seg>&glibc-fin-du;</seg>
  30. </seglistitem>
  31. </segmentedlist>
  32. </sect2>
  33. <sect2 role="installation">
  34. <title>Installation of Glibc</title>
  35. <para>Some of the Glibc programs use the non-FHS compliant
  36. <filename class="directory">/var/db</filename> directory to store
  37. their runtime data. Apply the following patch to make such programs
  38. store their runtime data in the FHS-compliant locations:</para>
  39. <screen><userinput remap="pre">patch -Np1 -i ../&glibc-fhs-patch;</userinput></screen>
  40. <para>Fix a bug that causes issues with chrooted applications:</para>
  41. <screen><userinput remap="pre">sed -e '402a\ *result = local->data.services[database_index];' \
  42. -i nss/nss_database.c</userinput></screen>
  43. <para>The Glibc documentation recommends building Glibc
  44. in a dedicated build directory:</para>
  45. <screen><userinput remap="pre">mkdir -v build
  46. cd build</userinput></screen>
  47. <para>Prepare Glibc for compilation:</para>
  48. <screen arch="default"><userinput remap="configure">../configure --prefix=/usr \
  49. --disable-werror \
  50. --enable-kernel=&min-kernel; \
  51. --enable-stack-protector=strong \
  52. --with-headers=/usr/include \
  53. libc_cv_slibdir=/lib</userinput></screen>
  54. <screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../configure --prefix=/usr \
  55. --disable-werror \
  56. --enable-kernel=&min-kernel; \
  57. --enable-stack-protector=strong \
  58. --with-headers=/usr/include \
  59. --enable-multi-arch \
  60. libc_cv_slibdir=/lib</userinput></screen>
  61. <variablelist>
  62. <title>The meaning of the configure options:</title>
  63. <varlistentry>
  64. <term><parameter>--disable-werror</parameter></term>
  65. <listitem>
  66. <para>This option disables the -Werror option passed to
  67. GCC. This is necessary for running the test suite.</para>
  68. </listitem>
  69. </varlistentry>
  70. <varlistentry>
  71. <term><parameter>--enable-kernel=&min-kernel;</parameter></term>
  72. <listitem>
  73. <para>This option tells the build system that this glibc may
  74. be used with kernels as old as &min-kernel;. This means generating
  75. workarounds in case a system call introduced in a later version
  76. cannot be used.</para>
  77. </listitem>
  78. </varlistentry>
  79. <varlistentry>
  80. <term><parameter>--enable-stack-protector=strong</parameter></term>
  81. <listitem>
  82. <para>This option increases system security by adding
  83. extra code to check for buffer overflows, such as stack
  84. smashing attacks.</para>
  85. </listitem>
  86. </varlistentry>
  87. <!-- do we need this one? -->
  88. <varlistentry>
  89. <term><parameter>--with-headers=/usr/include</parameter></term>
  90. <listitem>
  91. <para>This option tells the build system where to find the
  92. kernel API headers.</para>
  93. </listitem>
  94. </varlistentry>
  95. <varlistentry>
  96. <term><parameter>libc_cv_slibdir=/lib</parameter></term>
  97. <listitem>
  98. <para>This variable sets the correct library for all
  99. systems. We do not want lib64 to be used.</para>
  100. </listitem>
  101. </varlistentry>
  102. <varlistentry>
  103. <term><option>libc_cv_include_x86_isa_level=no</option></term>
  104. <listitem>
  105. <para>This disables <quote>x86 ISA needed</quote> property in
  106. Glibc libraries. Use it <emphasis role="bold">if</emphasis>
  107. you are building Glibc with <option>-march</option> option in
  108. <envar>CFLAGS</envar>, to workaround an issue in Glibc-2.33
  109. breaking it.</para>
  110. </listitem>
  111. </varlistentry>
  112. </variablelist>
  113. <para>Compile the package:</para>
  114. <screen><userinput remap="make">make</userinput></screen>
  115. <important>
  116. <para>In this section, the test suite for Glibc is considered critical.
  117. Do not skip it under any circumstance.</para>
  118. </important>
  119. <para>Generally a few tests do not pass. The test failures listed below
  120. are usually safe to ignore.</para>
  121. <!-- Use remap="make" here to work around a jhalfs issue. -->
  122. <!--<screen><userinput remap="make">case $(uname -m) in
  123. i?86) ln -sfnv $PWD/elf/ld-linux.so.2 /lib ;;
  124. x86_64) ln -sfnv $PWD/elf/ld-linux-x86-64.so.2 /lib ;;
  125. esac</userinput></screen>
  126. <note><para>The symbolic link above is needed to run the tests at this
  127. stage of building in the chroot environment. It will be overwritten
  128. in the install phase below.</para></note>
  129. -->
  130. <screen><userinput remap="test">make check</userinput></screen>
  131. <para>You may see some test failures. The Glibc test suite is
  132. somewhat dependent on the host system. This is a list of the most common
  133. issues seen for some versions of LFS:</para>
  134. <itemizedlist>
  135. <listitem>
  136. <para><emphasis>io/tst-lchmod</emphasis>
  137. is known to fail in the LFS chroot environment.</para>
  138. </listitem>
  139. <listitem>
  140. <para><emphasis>misc/tst-ttyname</emphasis>
  141. is known to fail in the LFS chroot environment.</para>
  142. </listitem>
  143. <listitem>
  144. <para><emphasis>elf/tst-cpu-features-cpuinfo</emphasis>
  145. may fail on some architectures.</para>
  146. </listitem>
  147. <listitem>
  148. <para>The <emphasis>nss/tst-nss-files-hosts-multi</emphasis>
  149. test may fail for reasons that have not been determined.</para>
  150. </listitem>
  151. <listitem>
  152. <para>The <emphasis>rt/tst-cputimer{1,2,3}</emphasis> tests depend on
  153. the host system kernel. Kernels 4.14.91&ndash;4.14.96,
  154. 4.19.13&ndash;4.19.18, and 4.20.0&ndash;4.20.5 are known to
  155. cause these tests to fail.
  156. </para>
  157. </listitem>
  158. <listitem>
  159. <para>The math tests sometimes fail when running on
  160. systems where the CPU is not a relatively new Intel or
  161. AMD processor.</para>
  162. </listitem>
  163. </itemizedlist>
  164. <para>Though it is a harmless message, the install stage of Glibc will
  165. complain about the absence of <filename>/etc/ld.so.conf</filename>.
  166. Prevent this warning with:</para>
  167. <screen><userinput remap="install">touch /etc/ld.so.conf</userinput></screen>
  168. <para>Fix the generated Makefile to skip an unneeded sanity check
  169. that fails in the LFS partial environment:
  170. </para>
  171. <screen><userinput remap="install">sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile</userinput></screen>
  172. <para>Install the package:</para>
  173. <screen><userinput remap="install">make install</userinput></screen>
  174. <para>Install the configuration file and runtime directory for
  175. <command>nscd</command>:</para>
  176. <screen><userinput remap="install">cp -v ../nscd/nscd.conf /etc/nscd.conf
  177. mkdir -pv /var/cache/nscd</userinput></screen>
  178. <para revision="systemd">Install the systemd support files for
  179. <command>nscd</command>:</para>
  180. <screen revision="systemd"><userinput remap="install">install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
  181. install -v -Dm644 ../nscd/nscd.service /lib/systemd/system/nscd.service</userinput></screen>
  182. <para>Next, install the locales that can make the system respond in a
  183. different language. None of the locales are required, but if some of them
  184. are missing, the test suites of future packages would skip important
  185. testcases.</para>
  186. <para>Individual locales can be installed using the
  187. <command>localedef</command> program. E.g., the first
  188. <command>localedef</command> command below combines the
  189. <filename>/usr/share/i18n/locales/cs_CZ</filename>
  190. charset-independent locale definition with the
  191. <filename>/usr/share/i18n/charmaps/UTF-8.gz</filename>
  192. charmap definition and appends the result to the
  193. <filename>/usr/lib/locale/locale-archive</filename> file.
  194. The following instructions will install the minimum set of
  195. locales necessary for the optimal coverage of tests:</para>
  196. <screen role="nodump"><userinput remap="locale-test">mkdir -pv /usr/lib/locale
  197. localedef -i POSIX -f UTF-8 C.UTF-8 2> /dev/null || true
  198. localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
  199. localedef -i de_DE -f ISO-8859-1 de_DE
  200. localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
  201. localedef -i de_DE -f UTF-8 de_DE.UTF-8
  202. localedef -i el_GR -f ISO-8859-7 el_GR
  203. localedef -i en_GB -f UTF-8 en_GB.UTF-8
  204. localedef -i en_HK -f ISO-8859-1 en_HK
  205. localedef -i en_PH -f ISO-8859-1 en_PH
  206. localedef -i en_US -f ISO-8859-1 en_US
  207. localedef -i en_US -f UTF-8 en_US.UTF-8
  208. localedef -i es_MX -f ISO-8859-1 es_MX
  209. localedef -i fa_IR -f UTF-8 fa_IR
  210. localedef -i fr_FR -f ISO-8859-1 fr_FR
  211. localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
  212. localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
  213. localedef -i it_IT -f ISO-8859-1 it_IT
  214. localedef -i it_IT -f UTF-8 it_IT.UTF-8
  215. localedef -i ja_JP -f EUC-JP ja_JP
  216. localedef -i ja_JP -f SHIFT_JIS ja_JP.SIJS 2> /dev/null || true
  217. localedef -i ja_JP -f UTF-8 ja_JP.UTF-8
  218. localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
  219. localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
  220. localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
  221. localedef -i zh_CN -f GB18030 zh_CN.GB18030
  222. localedef -i zh_HK -f BIG5-HKSCS zh_HK.BIG5-HKSCS</userinput></screen>
  223. <para>In addition, install the locale for your own country, language and
  224. character set.</para>
  225. <para>Alternatively, install all locales listed in the
  226. <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
  227. (it includes every locale listed above and many more) at once with the
  228. following time-consuming command:</para>
  229. <screen><userinput remap="locale-full">make localedata/install-locales</userinput></screen>
  230. <para>Then use the <command>localedef</command> command to create and
  231. install locales not listed in the
  232. <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
  233. in the unlikely case you need them.</para>
  234. <note><para>Glibc now uses libidn2 when resolving internationalized
  235. domain names. This is a run time dependency. If this capability
  236. is needed, the instructions for installing libidn2 are in the
  237. <ulink url="&blfs-book;general/libidn2.html">BLFS libidn2 page</ulink>.
  238. </para></note>
  239. </sect2>
  240. <sect2 id="conf-glibc" role="configuration">
  241. <title>Configuring Glibc</title>
  242. <indexterm zone="conf-glibc">
  243. <primary sortas="e-/etc/nsswitch.conf">/etc/nsswitch.conf</primary>
  244. </indexterm>
  245. <indexterm zone="conf-glibc">
  246. <primary sortas="e-/etc/localtime">/etc/localtime</primary>
  247. </indexterm>
  248. <sect3>
  249. <title>Adding nsswitch.conf</title>
  250. <para>The <filename>/etc/nsswitch.conf</filename> file needs to be created
  251. because the Glibc defaults do not work well in a networked environment.
  252. </para>
  253. <para>Create a new file <filename>/etc/nsswitch.conf</filename> by running the
  254. following:</para>
  255. <screen><userinput>cat &gt; /etc/nsswitch.conf &lt;&lt; "EOF"
  256. <literal># Begin /etc/nsswitch.conf
  257. passwd: files
  258. group: files
  259. shadow: files
  260. hosts: files dns
  261. networks: files
  262. protocols: files
  263. services: files
  264. ethers: files
  265. rpc: files
  266. # End /etc/nsswitch.conf</literal>
  267. EOF</userinput></screen>
  268. </sect3>
  269. <sect3>
  270. <title>Adding time zone data</title>
  271. <para>Install and set up the time zone data with the following:</para>
  272. <screen><userinput>tar -xf ../../tzdata&tzdata-version;.tar.gz
  273. ZONEINFO=/usr/share/zoneinfo
  274. mkdir -pv $ZONEINFO/{posix,right}
  275. for tz in etcetera southamerica northamerica europe africa antarctica \
  276. asia australasia backward; do
  277. zic -L /dev/null -d $ZONEINFO ${tz}
  278. zic -L /dev/null -d $ZONEINFO/posix ${tz}
  279. zic -L leapseconds -d $ZONEINFO/right ${tz}
  280. done
  281. cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
  282. zic -d $ZONEINFO -p America/New_York
  283. unset ZONEINFO</userinput></screen>
  284. <variablelist>
  285. <title>The meaning of the zic commands:</title>
  286. <varlistentry>
  287. <term><parameter>zic -L /dev/null ...</parameter></term>
  288. <listitem>
  289. <para>This creates posix time zones without any leap seconds. It is
  290. conventional to put these in both
  291. <filename class="directory">zoneinfo</filename> and
  292. <filename class="directory">zoneinfo/posix</filename>. It is
  293. necessary to put the POSIX time zones in
  294. <filename class="directory">zoneinfo</filename>, otherwise various
  295. test-suites will report errors. On an embedded system, where space is
  296. tight and you do not intend to ever update the time zones, you could save
  297. 1.9 MB by not using the <filename class="directory">posix</filename>
  298. directory, but some applications or test-suites might produce some
  299. failures.</para>
  300. </listitem>
  301. </varlistentry>
  302. <varlistentry>
  303. <term><parameter>zic -L leapseconds ...</parameter></term>
  304. <listitem>
  305. <para>This creates right time zones, including leap seconds. On an
  306. embedded system, where space is tight and you do not intend to
  307. ever update the time zones, or care about the correct time, you could
  308. save 1.9MB by omitting the <filename class="directory">right</filename>
  309. directory.</para>
  310. </listitem>
  311. </varlistentry>
  312. <varlistentry>
  313. <term><parameter>zic ... -p ...</parameter></term>
  314. <listitem>
  315. <para>This creates the <filename>posixrules</filename> file. We use
  316. New York because POSIX requires the daylight savings time rules
  317. to be in accordance with US rules.</para>
  318. </listitem>
  319. </varlistentry>
  320. </variablelist>
  321. <para>One way to determine the local time zone is to run the following
  322. script:</para>
  323. <screen role="nodump"><userinput>tzselect</userinput></screen>
  324. <para>After answering a few questions about the location, the script will
  325. output the name of the time zone (e.g.,
  326. <emphasis>America/Edmonton</emphasis>). There are also some other possible
  327. time zones listed in <filename
  328. class='directory'>/usr/share/zoneinfo</filename> such as
  329. <emphasis>Canada/Eastern</emphasis> or <emphasis>EST5EDT</emphasis> that
  330. are not identified by the script but can be used.</para>
  331. <para>Then create the <filename>/etc/localtime</filename> file by
  332. running:</para>
  333. <screen><userinput>ln -sfv /usr/share/zoneinfo/<replaceable>&lt;xxx&gt;</replaceable> /etc/localtime</userinput></screen>
  334. <para>Replace <replaceable>&lt;xxx&gt;</replaceable> with the name of the
  335. time zone selected (e.g., Canada/Eastern).</para>
  336. </sect3>
  337. <sect3 id="conf-ld" role="configuration">
  338. <title>Configuring the Dynamic Loader</title>
  339. <indexterm zone="conf-ld">
  340. <primary sortas="e-/etc/ld.so.conf">/etc/ld.so.conf</primary>
  341. </indexterm>
  342. <para>By default, the dynamic loader (<filename
  343. class="libraryfile">/lib/ld-linux.so.2</filename>) searches through
  344. <filename class="directory">/lib</filename> and <filename
  345. class="directory">/usr/lib</filename> for dynamic libraries that are
  346. needed by programs as they are run. However, if there are libraries in
  347. directories other than <filename class="directory">/lib</filename> and
  348. <filename class="directory">/usr/lib</filename>, these need to be added
  349. to the <filename>/etc/ld.so.conf</filename> file in order for the
  350. dynamic loader to find them. Two directories that are commonly known
  351. to contain additional libraries are <filename
  352. class="directory">/usr/local/lib</filename> and <filename
  353. class="directory">/opt/lib</filename>, so add those directories to the
  354. dynamic loader's search path.</para>
  355. <para>Create a new file <filename>/etc/ld.so.conf</filename> by running the
  356. following:</para>
  357. <screen><userinput>cat &gt; /etc/ld.so.conf &lt;&lt; "EOF"
  358. <literal># Begin /etc/ld.so.conf
  359. /usr/local/lib
  360. /opt/lib
  361. </literal>
  362. EOF</userinput></screen>
  363. <para>If desired, the dynamic loader can also search a directory and
  364. include the contents of files found there. Generally the files in
  365. this include directory are one line specifying the desired library path.
  366. To add this capability run the following commands:</para>
  367. <screen role="nodump"><userinput>cat &gt;&gt; /etc/ld.so.conf &lt;&lt; "EOF"
  368. <literal># Add an include directory
  369. include /etc/ld.so.conf.d/*.conf
  370. </literal>
  371. EOF
  372. mkdir -pv /etc/ld.so.conf.d</userinput></screen>
  373. </sect3>
  374. </sect2>
  375. <!-- - - - - - - - - - -->
  376. <!-- Multilib - 32bit -->
  377. <!-- - - - - - - - - - -->
  378. <sect2 arch="ml_32,ml_all">
  379. <title>Building Glibc - 32bit</title>
  380. <para>Now recompile for m32. The extracted source can be
  381. reused but needs to cleaned before installing the m32
  382. version of Glibc.</para>
  383. <para>Clear the build directory and remove artefacts from
  384. previous build:</para>
  385. <screen><userinput remap="pre">rm -rf ./*
  386. find .. -name "*.a" -delete</userinput></screen>
  387. <para>Configure Glibc for m32 with the following commands:</para>
  388. <screen><userinput remap="configure">CC="gcc -m32" CXX="g++ -m32" \
  389. ../configure \
  390. --prefix=/usr \
  391. --host=i686-pc-linux-gnu \
  392. --build=$(../scripts/config.guess) \
  393. --enable-kernel=&min-kernel; \
  394. --with-headers=/usr/include \
  395. --enable-multi-arch \
  396. --libdir=&usr-lib-m32; \
  397. --libexecdir=&usr-lib-m32; \
  398. libc_cv_slibdir=&lib-m32;</userinput></screen>
  399. <para>Compile the package:</para>
  400. <screen><userinput remap="make">make</userinput></screen>
  401. <para>Install the package:</para>
  402. <screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
  403. cp -a DESTDIR&lib-m32;/* &lib-m32;/
  404. cp -a DESTDIR&usr-lib-m32;/* &usr-lib-m32;/
  405. install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \
  406. /usr/include/gnu/
  407. ln -svf ..&lib-m32;/ld-linux.so.2 /lib/ld-linux.so.2</userinput></screen>
  408. <para>Add the library name to the dynamic loader config:</para>
  409. <screen role="install"><userinput>echo "&usr-lib-m32;" &gt;&gt; /etc/ld.so.conf</userinput></screen>
  410. <caution>
  411. <para>At this point, it is imperative to stop and ensure that the basic
  412. functions (compiling and linking) of the new toolchain are working as
  413. expected. To perform a sanity check, run the following commands:</para>
  414. <screen><userinput>echo 'int main(){}' &gt; dummy.c
  415. gcc -m32 dummy.c
  416. readelf -l a.out | grep '/ld-linux'</userinput></screen>
  417. <para>If everything is working correctly, there should be no errors,
  418. and the output of the last command will be of the form:</para>
  419. <screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen>
  420. <para>If the output is not shown as above or there was no output at all,
  421. then something is wrong. Investigate and retrace the steps to find out
  422. where the problem is and correct it. This issue must be resolved before
  423. continuing on.</para>
  424. <para>Once all is well, clean up the test files:</para>
  425. <screen><userinput>rm -v dummy.c a.out</userinput></screen>
  426. </caution>
  427. </sect2><!-- m32 -->
  428. <!-- - - - - - - - - - -->
  429. <!-- Multilib - x32bit -->
  430. <!-- - - - - - - - - - -->
  431. <sect2 arch="ml_x32,ml_all">
  432. <title>Building Glibc - x32bit</title>
  433. <para>Now recompile for mx32. The extracted source can be
  434. reused but needs to cleaned before installing the mx32
  435. version of Glibc.</para>
  436. <para>Clear the build directory and remove artefacts from
  437. previous build:</para>
  438. <screen><userinput remap="pre">rm -rf ./*
  439. find .. -name "*.a" -delete</userinput></screen>
  440. <para>Configure Glibc for mx32 with the following commands:</para>
  441. <screen><userinput remap="configure">CC="gcc -mx32" CXX="g++ -mx32" \
  442. ../configure \
  443. --prefix=/usr \
  444. --host=x86_64-pc-linux-gnux32 \
  445. --build=$(../scripts/config.guess) \
  446. --enable-kernel=&min-kernel; \
  447. --with-headers=$LFS/usr/include \
  448. --enable-multi-arch \
  449. --libdir=&usr-lib-mx32; \
  450. --libexecdir=&usr-lib-mx32; \
  451. libc_cv_slibdir=&lib-mx32;</userinput></screen>
  452. <para>Compile the package:</para>
  453. <screen><userinput remap="make">make</userinput></screen>
  454. <para>Install the package:</para>
  455. <screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
  456. cp -a DESTDIR&lib-mx32;/* &lib-mx32;/
  457. cp -a DESTDIR&usr-lib-mx32;/* &usr-lib-mx32;/
  458. install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-x32.h \
  459. /usr/include/gnu/
  460. ln -svf ..&lib-mx32;/ld-linux-x32.so.2 /lib/ld-linux-x32.so.2</userinput></screen>
  461. <para>Add the library name to the dynamic loader config:</para>
  462. <screen role="install"><userinput>echo "&usr-lib-mx32;" &gt;&gt; /etc/ld.so.conf</userinput></screen>
  463. <caution>
  464. <para>At this point, it is imperative to stop and ensure that the basic
  465. functions (compiling and linking) of the new toolchain are working as
  466. expected. To perform a sanity check, run the following commands:</para>
  467. <screen><userinput>echo 'int main(){}' &gt; dummy.c
  468. gcc -mx32 dummy.c
  469. readelf -l a.out | grep '/ld-linux-x32'</userinput></screen>
  470. <para>If everything is working correctly, there should be no errors,
  471. and the output of the last command will be of the form:</para>
  472. <screen><computeroutput>[Requesting program interpreter: /libx32/ld-linux-x32.so.2]</computeroutput></screen>
  473. <para>If the output is not shown as above or there was no output at all,
  474. then something is wrong. Investigate and retrace the steps to find out
  475. where the problem is and correct it. This issue must be resolved before
  476. continuing on.</para>
  477. <para>Once all is well, clean up the test files:</para>
  478. <screen><userinput>rm -v dummy.c a.out</userinput></screen>
  479. </caution>
  480. </sect2><!-- mx32 -->
  481. <sect2 id="contents-glibc" role="content">
  482. <title>Contents of Glibc</title>
  483. <segmentedlist>
  484. <segtitle>Installed programs</segtitle>
  485. <segtitle>Installed libraries</segtitle>
  486. <segtitle>Installed directories</segtitle>
  487. <seglistitem>
  488. <seg>catchsegv, gencat, getconf, getent, iconv, iconvconfig, ldconfig,
  489. ldd, lddlibc4, locale, localedef, makedb, mtrace, nscd,
  490. pcprofiledump, pldd, sln, sotruss, sprof, tzselect, xtrace,
  491. zdump, and zic</seg>
  492. <seg>ld-&glibc-version;.so, libBrokenLocale.{a,so}, libSegFault.so, libanl.{a,so},
  493. libc.{a,so}, libc_nonshared.a,
  494. libcrypt.{a,so}, libdl.{a,so}, libg.a, libm.{a,so},
  495. libmcheck.a, libmemusage.so, libmvec.{a,so}, libnsl.{a,so},
  496. libnss_compat.so, libnss_dns.so, libnss_files.so, libnss_hesiod.so,
  497. libpcprofile.so, libpthread.{a,so},
  498. libpthread_nonshared.a, libresolv.{a,so}, librt.{a,so},
  499. libthread_db.so, and libutil.{a,so}</seg>
  500. <seg>/usr/include/arpa, /usr/include/bits, /usr/include/gnu,
  501. /usr/include/net, /usr/include/netash, /usr/include/netatalk,
  502. /usr/include/netax25, /usr/include/neteconet, /usr/include/netinet,
  503. /usr/include/netipx, /usr/include/netiucv, /usr/include/netpacket,
  504. /usr/include/netrom, /usr/include/netrose, /usr/include/nfs,
  505. /usr/include/protocols, /usr/include/rpc,
  506. /usr/include/sys, /usr/lib/audit, /usr/lib/gconv, /usr/lib/locale,
  507. /usr/libexec/getconf, /usr/share/i18n, /usr/share/zoneinfo,
  508. /var/cache/nscd, and /var/lib/nss_db</seg>
  509. </seglistitem>
  510. </segmentedlist>
  511. <variablelist>
  512. <bridgehead renderas="sect3">Short Descriptions</bridgehead>
  513. <?dbfo list-presentation="list"?>
  514. <?dbhtml list-presentation="table"?>
  515. <varlistentry id="catchsegv">
  516. <term><command>catchsegv</command></term>
  517. <listitem>
  518. <para>Can be used to create a stack trace when a program
  519. terminates with a segmentation fault</para>
  520. <indexterm zone="ch-system-glibc catchsegv">
  521. <primary sortas="b-catchsegv">catchsegv</primary>
  522. </indexterm>
  523. </listitem>
  524. </varlistentry>
  525. <varlistentry id="gencat">
  526. <term><command>gencat</command></term>
  527. <listitem>
  528. <para>Generates message catalogues</para>
  529. <indexterm zone="ch-system-glibc gencat">
  530. <primary sortas="b-gencat">gencat</primary>
  531. </indexterm>
  532. </listitem>
  533. </varlistentry>
  534. <varlistentry id="getconf">
  535. <term><command>getconf</command></term>
  536. <listitem>
  537. <para>Displays the system configuration values for file system
  538. specific variables</para>
  539. <indexterm zone="ch-system-glibc getconf">
  540. <primary sortas="b-getconf">getconf</primary>
  541. </indexterm>
  542. </listitem>
  543. </varlistentry>
  544. <varlistentry id="getent">
  545. <term><command>getent</command></term>
  546. <listitem>
  547. <para>Gets entries from an administrative database</para>
  548. <indexterm zone="ch-system-glibc getent">
  549. <primary sortas="b-getent">getent</primary>
  550. </indexterm>
  551. </listitem>
  552. </varlistentry>
  553. <varlistentry id="iconv">
  554. <term><command>iconv</command></term>
  555. <listitem>
  556. <para>Performs character set conversion</para>
  557. <indexterm zone="ch-system-glibc iconv">
  558. <primary sortas="b-iconv">iconv</primary>
  559. </indexterm>
  560. </listitem>
  561. </varlistentry>
  562. <varlistentry id="iconvconfig">
  563. <term><command>iconvconfig</command></term>
  564. <listitem>
  565. <para>Creates fastloading <command>iconv</command> module configuration
  566. files</para>
  567. <indexterm zone="ch-system-glibc iconvconfig">
  568. <primary sortas="b-iconvconfig">iconvconfig</primary>
  569. </indexterm>
  570. </listitem>
  571. </varlistentry>
  572. <varlistentry id="ldconfig">
  573. <term><command>ldconfig</command></term>
  574. <listitem>
  575. <para>Configures the dynamic linker runtime bindings</para>
  576. <indexterm zone="ch-system-glibc ldconfig">
  577. <primary sortas="b-ldconfig">ldconfig</primary>
  578. </indexterm>
  579. </listitem>
  580. </varlistentry>
  581. <varlistentry id="ldd">
  582. <term><command>ldd</command></term>
  583. <listitem>
  584. <para>Reports which shared libraries are required
  585. by each given program or shared library</para>
  586. <indexterm zone="ch-system-glibc ldd">
  587. <primary sortas="b-ldd">ldd</primary>
  588. </indexterm>
  589. </listitem>
  590. </varlistentry>
  591. <varlistentry id="lddlibc4">
  592. <term><command>lddlibc4</command></term>
  593. <listitem>
  594. <para>Assists <command>ldd</command> with object files</para>
  595. <indexterm zone="ch-system-glibc lddlibc4">
  596. <primary sortas="b-lddlibc4">lddlibc4</primary>
  597. </indexterm>
  598. </listitem>
  599. </varlistentry>
  600. <varlistentry id="locale">
  601. <term><command>locale</command></term>
  602. <listitem>
  603. <para>Prints various information about the current locale</para>
  604. <indexterm zone="ch-system-glibc locale">
  605. <primary sortas="b-locale">locale</primary>
  606. </indexterm>
  607. </listitem>
  608. </varlistentry>
  609. <varlistentry id="localedef">
  610. <term><command>localedef</command></term>
  611. <listitem>
  612. <para>Compiles locale specifications</para>
  613. <indexterm zone="ch-system-glibc localedef">
  614. <primary sortas="b-localedef">localedef</primary>
  615. </indexterm>
  616. </listitem>
  617. </varlistentry>
  618. <varlistentry id="makedb">
  619. <term><command>makedb</command></term>
  620. <listitem>
  621. <para>Creates a simple database from textual input</para>
  622. <indexterm zone="ch-system-glibc makedb">
  623. <primary sortas="b-makedb">makedb</primary>
  624. </indexterm>
  625. </listitem>
  626. </varlistentry>
  627. <varlistentry id="mtrace">
  628. <term><command>mtrace</command></term>
  629. <listitem>
  630. <para>Reads and interprets a memory trace file and displays a summary
  631. in human-readable format</para>
  632. <indexterm zone="ch-system-glibc mtrace">
  633. <primary sortas="b-mtrace">mtrace</primary>
  634. </indexterm>
  635. </listitem>
  636. </varlistentry>
  637. <varlistentry id="nscd">
  638. <term><command>nscd</command></term>
  639. <listitem>
  640. <para>A daemon that provides a cache for the most common name
  641. service requests</para>
  642. <indexterm zone="ch-system-glibc nscd">
  643. <primary sortas="b-nscd">nscd</primary>
  644. </indexterm>
  645. </listitem>
  646. </varlistentry>
  647. <varlistentry id="pcprofiledump">
  648. <term><command>pcprofiledump</command></term>
  649. <listitem>
  650. <para>Dump information generated by PC profiling</para>
  651. <indexterm zone="ch-system-glibc pcprofiledump">
  652. <primary sortas="b-pcprofiledump">pcprofiledump</primary>
  653. </indexterm>
  654. </listitem>
  655. </varlistentry>
  656. <varlistentry id="pldd">
  657. <term><command>pldd</command></term>
  658. <listitem>
  659. <para>Lists dynamic shared objects used by running processes</para>
  660. <indexterm zone="ch-system-glibc pldd">
  661. <primary sortas="b-pldd">pldd</primary>
  662. </indexterm>
  663. </listitem>
  664. </varlistentry>
  665. <varlistentry id="sln">
  666. <term><command>sln</command></term>
  667. <listitem>
  668. <para>A statically linked <command>ln</command> program</para>
  669. <indexterm zone="ch-system-glibc sln">
  670. <primary sortas="b-sln">sln</primary>
  671. </indexterm>
  672. </listitem>
  673. </varlistentry>
  674. <varlistentry id="sotruss">
  675. <term><command>sotruss</command></term>
  676. <listitem>
  677. <para>Traces shared library procedure calls of a specified command</para>
  678. <indexterm zone="ch-system-glibc sotruss">
  679. <primary sortas="b-sotruss">sotruss</primary>
  680. </indexterm>
  681. </listitem>
  682. </varlistentry>
  683. <varlistentry id="sprof">
  684. <term><command>sprof</command></term>
  685. <listitem>
  686. <para>Reads and displays shared object profiling data</para>
  687. <indexterm zone="ch-system-glibc sprof">
  688. <primary sortas="b-sprof">sprof</primary>
  689. </indexterm>
  690. </listitem>
  691. </varlistentry>
  692. <varlistentry id="tzselect">
  693. <term><command>tzselect</command></term>
  694. <listitem>
  695. <para>Asks the user about the location of the system and reports
  696. the corresponding time zone description</para>
  697. <indexterm zone="ch-system-glibc tzselect">
  698. <primary sortas="b-tzselect">tzselect</primary>
  699. </indexterm>
  700. </listitem>
  701. </varlistentry>
  702. <varlistentry id="xtrace">
  703. <term><command>xtrace</command></term>
  704. <listitem>
  705. <para>Traces the execution of a program by printing the currently
  706. executed function</para>
  707. <indexterm zone="ch-system-glibc xtrace">
  708. <primary sortas="b-xtrace">xtrace</primary>
  709. </indexterm>
  710. </listitem>
  711. </varlistentry>
  712. <varlistentry id="zdump">
  713. <term><command>zdump</command></term>
  714. <listitem>
  715. <para>The time zone dumper</para>
  716. <indexterm zone="ch-system-glibc zdump">
  717. <primary sortas="b-zdump">zdump</primary>
  718. </indexterm>
  719. </listitem>
  720. </varlistentry>
  721. <varlistentry id="zic">
  722. <term><command>zic</command></term>
  723. <listitem>
  724. <para>The time zone compiler</para>
  725. <indexterm zone="ch-system-glibc zic">
  726. <primary sortas="b-zic">zic</primary>
  727. </indexterm>
  728. </listitem>
  729. </varlistentry>
  730. <varlistentry id="ld.so">
  731. <term><filename class="libraryfile">ld-&glibc-version;.so</filename></term>
  732. <listitem>
  733. <para>The helper program for shared library executables</para>
  734. <indexterm zone="ch-system-glibc ld.so">
  735. <primary sortas="c-ld.so">ld-&glibc-version;.so</primary>
  736. </indexterm>
  737. </listitem>
  738. </varlistentry>
  739. <varlistentry id="libBrokenLocale">
  740. <term><filename class="libraryfile">libBrokenLocale</filename></term>
  741. <listitem>
  742. <para>Used internally by Glibc as a gross hack to get broken programs
  743. (e.g., some Motif applications) running. See comments in
  744. <filename>glibc-&glibc-version;/locale/broken_cur_max.c</filename>
  745. for more information</para>
  746. <indexterm zone="ch-system-glibc libBrokenLocale">
  747. <primary sortas="c-libBrokenLocale">libBrokenLocale</primary>
  748. </indexterm>
  749. </listitem>
  750. </varlistentry>
  751. <varlistentry id="libSegFault">
  752. <term><filename class="libraryfile">libSegFault</filename></term>
  753. <listitem>
  754. <para>The segmentation fault signal handler, used by
  755. <command>catchsegv</command></para>
  756. <indexterm zone="ch-system-glibc libSegFault">
  757. <primary sortas="c-libSegFault">libSegFault</primary>
  758. </indexterm>
  759. </listitem>
  760. </varlistentry>
  761. <varlistentry id="libanl">
  762. <term><filename class="libraryfile">libanl</filename></term>
  763. <listitem>
  764. <para>An asynchronous name lookup library</para>
  765. <indexterm zone="ch-system-glibc libanl">
  766. <primary sortas="c-libanl">libanl</primary>
  767. </indexterm>
  768. </listitem>
  769. </varlistentry>
  770. <varlistentry id="libc">
  771. <term><filename class="libraryfile">libc</filename></term>
  772. <listitem>
  773. <para>The main C library</para>
  774. <indexterm zone="ch-system-glibc libc">
  775. <primary sortas="c-libc">libc</primary>
  776. </indexterm>
  777. </listitem>
  778. </varlistentry>
  779. <varlistentry id="libcrypt">
  780. <term><filename class="libraryfile">libcrypt</filename></term>
  781. <listitem>
  782. <para>The cryptography library</para>
  783. <indexterm zone="ch-system-glibc libcrypt">
  784. <primary sortas="c-libcrypt">libcrypt</primary>
  785. </indexterm>
  786. </listitem>
  787. </varlistentry>
  788. <varlistentry id="libdl">
  789. <term><filename class="libraryfile">libdl</filename></term>
  790. <listitem>
  791. <para>The dynamic linking interface library</para>
  792. <indexterm zone="ch-system-glibc libdl">
  793. <primary sortas="c-libdl">libdl</primary>
  794. </indexterm>
  795. </listitem>
  796. </varlistentry>
  797. <varlistentry id="libg">
  798. <term><filename class="libraryfile">libg</filename></term>
  799. <listitem>
  800. <para>Dummy library containing no functions. Previously was a runtime
  801. library for <command>g++</command></para>
  802. <indexterm zone="ch-system-glibc libg">
  803. <primary sortas="c-libg">libg</primary>
  804. </indexterm>
  805. </listitem>
  806. </varlistentry>
  807. <varlistentry id="libm">
  808. <term><filename class="libraryfile">libm</filename></term>
  809. <listitem>
  810. <para>The mathematical library</para>
  811. <indexterm zone="ch-system-glibc libm">
  812. <primary sortas="c-libm">libm</primary>
  813. </indexterm>
  814. </listitem>
  815. </varlistentry>
  816. <varlistentry id="libmcheck">
  817. <term><filename class="libraryfile">libmcheck</filename></term>
  818. <listitem>
  819. <para>Turns on memory allocation checking when linked to</para>
  820. <indexterm zone="ch-system-glibc libmcheck">
  821. <primary sortas="c-libmcheck">libmcheck</primary>
  822. </indexterm>
  823. </listitem>
  824. </varlistentry>
  825. <varlistentry id="libmemusage">
  826. <term><filename class="libraryfile">libmemusage</filename></term>
  827. <listitem>
  828. <para>Used by <command>memusage</command> to help collect
  829. information about the memory usage of a program</para>
  830. <indexterm zone="ch-system-glibc libmemusage">
  831. <primary sortas="c-libmemusage">libmemusage</primary>
  832. </indexterm>
  833. </listitem>
  834. </varlistentry>
  835. <varlistentry id="libnsl">
  836. <term><filename class="libraryfile">libnsl</filename></term>
  837. <listitem>
  838. <para>The network services library</para>
  839. <indexterm zone="ch-system-glibc libnsl">
  840. <primary sortas="c-libnsl">libnsl</primary>
  841. </indexterm>
  842. </listitem>
  843. </varlistentry>
  844. <varlistentry id="libnss">
  845. <term><filename class="libraryfile">libnss</filename></term>
  846. <listitem>
  847. <para>The Name Service Switch libraries, containing functions for
  848. resolving host names, user names, group names, aliases, services,
  849. protocols, etc.</para>
  850. <indexterm zone="ch-system-glibc libnss">
  851. <primary sortas="c-libnss">libnss</primary>
  852. </indexterm>
  853. </listitem>
  854. </varlistentry>
  855. <varlistentry id="libpcprofile">
  856. <term><filename class="libraryfile">libpcprofile</filename></term>
  857. <listitem>
  858. <para>Can be preloaded to PC profile an executable</para>
  859. <indexterm zone="ch-system-glibc libpcprofile">
  860. <primary sortas="c-libpcprofile">libpcprofile</primary>
  861. </indexterm>
  862. </listitem>
  863. </varlistentry>
  864. <varlistentry id="libpthread">
  865. <term><filename class="libraryfile">libpthread</filename></term>
  866. <listitem>
  867. <para>The POSIX threads library</para>
  868. <indexterm zone="ch-system-glibc libpthread">
  869. <primary sortas="c-libpthread">libpthread</primary>
  870. </indexterm>
  871. </listitem>
  872. </varlistentry>
  873. <varlistentry id="libresolv">
  874. <term><filename class="libraryfile">libresolv</filename></term>
  875. <listitem>
  876. <para>Contains functions for creating, sending, and interpreting
  877. packets to the Internet domain name servers</para>
  878. <indexterm zone="ch-system-glibc libresolv">
  879. <primary sortas="c-libresolv">libresolv</primary>
  880. </indexterm>
  881. </listitem>
  882. </varlistentry>
  883. <varlistentry id="librt">
  884. <term><filename class="libraryfile">librt</filename></term>
  885. <listitem>
  886. <para>Contains functions providing most of the interfaces specified
  887. by the POSIX.1b Realtime Extension</para>
  888. <indexterm zone="ch-system-glibc librt">
  889. <primary sortas="c-librt">librt</primary>
  890. </indexterm>
  891. </listitem>
  892. </varlistentry>
  893. <varlistentry id="libthread_db">
  894. <term><filename class="libraryfile">libthread_db</filename></term>
  895. <listitem>
  896. <para>Contains functions useful for building debuggers for
  897. multi-threaded programs</para>
  898. <indexterm zone="ch-system-glibc libthread_db">
  899. <primary sortas="c-libthread_db">libthread_db</primary>
  900. </indexterm>
  901. </listitem>
  902. </varlistentry>
  903. <varlistentry id="libutil">
  904. <term><filename class="libraryfile">libutil</filename></term>
  905. <listitem>
  906. <para>Contains code for <quote>standard</quote> functions used in
  907. many different Unix utilities</para>
  908. <indexterm zone="ch-system-glibc libutil">
  909. <primary sortas="c-libutil">libutil</primary>
  910. </indexterm>
  911. </listitem>
  912. </varlistentry>
  913. </variablelist>
  914. </sect2>
  915. </sect1>