source: chapter08/glibc.xml@ bc33d9d

multilib xry111/multilib
Last change on this file since bc33d9d was bc33d9d, checked in by Thomas Trepl <thomas@…>, 4 months ago

Merge upstream

  • Property mode set to 100644
File size: 46.9 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
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
8<sect1 id="ch-system-glibc" role="wrap">
9 <?dbhtml filename="glibc.html"?>
10
11 <sect1info condition="script">
12 <productname>glibc</productname>
13 <productnumber>&glibc-version;</productnumber>
14 <address>&glibc-url;</address>
15 </sect1info>
16
17 <title>Glibc-&glibc-version;</title>
18
19 <indexterm zone="ch-system-glibc">
20 <primary sortas="a-Glibc">Glibc</primary>
21 </indexterm>
22
23 <sect2 role="package">
24 <title/>
25
26 <para>The Glibc package contains the main C library. This library provides
27 the basic routines for allocating memory, searching directories, opening and
28 closing files, reading and writing files, string handling, pattern matching,
29 arithmetic, and so on.</para>
30
31 <segmentedlist>
32 <segtitle>&buildtime;</segtitle>
33 <segtitle>&diskspace;</segtitle>
34
35 <seglistitem>
36 <seg>&glibc-fin-sbu;</seg>
37 <seg>&glibc-fin-du;</seg>
38 </seglistitem>
39 </segmentedlist>
40
41 </sect2>
42
43 <sect2 role="installation">
44 <title>Installation of Glibc</title>
45
46 <para>Some of the Glibc programs use the non-FHS compliant
47 <filename class="directory">/var/db</filename> directory to store
48 their runtime data. Apply the following patch to make such programs
49 store their runtime data in the FHS-compliant locations:</para>
50
51<screen><userinput remap="pre">patch -Np1 -i ../&glibc-fhs-patch;</userinput></screen>
52<!--
53 <para>Now fix two security vulnerabilities and a regression causing the
54 posix_memalign() function very slow in some conditions:</para>
55
56<screen><userinput remap="pre">patch -Np1 -i ../&glibc-upstream-fixes-patch;</userinput></screen>
57-->
58 <para>The Glibc documentation recommends building Glibc
59 in a dedicated build directory:</para>
60
61<screen><userinput remap="pre">mkdir -v build
62cd build</userinput></screen>
63
64 <para>Ensure that the <command>ldconfig</command> and <command>sln</command>
65 utilities will be installed into
66 <filename class="directory">/usr/sbin</filename>:</para>
67
68<screen><userinput remap="pre">echo "rootsbindir=/usr/sbin" &gt; configparms</userinput></screen>
69
70 <para>Prepare Glibc for compilation:</para>
71
72<screen arch="default"><userinput remap="configure">../configure --prefix=/usr \
73 --disable-werror \
74 --enable-kernel=&min-kernel; \
75 --enable-stack-protector=strong \
76 --disable-nscd \
77 libc_cv_slibdir=/usr/lib</userinput></screen>
78<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../configure --prefix=/usr \
79 --disable-werror \
80 --enable-kernel=&min-kernel; \
81 --enable-stack-protector=strong \
82 --with-headers=/usr/include \
83 --enable-multi-arch \
84 libc_cv_slibdir=/usr/lib</userinput></screen>
85
86 <variablelist>
87 <title>The meaning of the configure options:</title>
88
89 <varlistentry>
90 <term><parameter>--disable-werror</parameter></term>
91 <listitem>
92 <para>This option disables the -Werror option passed to
93 GCC. This is necessary for running the test suite.</para>
94 </listitem>
95 </varlistentry>
96
97 <varlistentry>
98 <term><parameter>--enable-kernel=&min-kernel;</parameter></term>
99 <listitem>
100 <para>This option tells the build system that this Glibc may
101 be used with kernels as old as &min-kernel;. This means generating
102 workarounds in case a system call introduced in a later version
103 cannot be used.</para>
104 </listitem>
105 </varlistentry>
106
107 <varlistentry>
108 <term><parameter>--enable-stack-protector=strong</parameter></term>
109 <listitem>
110 <para>This option increases system security by adding
111 extra code to check for buffer overflows, such as stack
112 smashing attacks. Note that Glibc always explicitly overrides
113 the default of GCC, so this option is still needed even though
114 we've already specified <option>--enable-default-ssp</option> for
115 GCC.</para>
116 </listitem>
117 </varlistentry>
118
119 <varlistentry>
120 <term><parameter>--disable-nscd</parameter></term>
121 <listitem>
122 <para>Do not build the name service cache daemon which is no
123 longer used.</para>
124 </listitem>
125 </varlistentry>
126
127 <varlistentry>
128 <term><parameter>libc_cv_slibdir=/usr/lib</parameter></term>
129 <listitem>
130 <para>This variable sets the correct library for all
131 systems. We do not want lib64 to be used.</para>
132 </listitem>
133 </varlistentry>
134
135 </variablelist>
136
137 <para>Compile the package:</para>
138
139<screen><userinput remap="make">make</userinput></screen>
140
141 <important>
142 <para>In this section, the test suite for Glibc is considered critical.
143 Do not skip it under any circumstance.</para>
144 </important>
145
146 <para>Generally a few tests do not pass. The test failures listed below
147 are usually safe to ignore.</para>
148
149<!-- Use remap="make" here to work around a jhalfs issue. -->
150<!--<screen><userinput remap="make">case $(uname -m) in
151 i?86) ln -sfnv $PWD/elf/ld-linux.so.2 /lib ;;
152 x86_64) ln -sfnv $PWD/elf/ld-linux-x86-64.so.2 /lib ;;
153esac</userinput></screen>
154
155 <note><para>The symbolic link above is needed to run the tests at this
156 stage of building in the chroot environment. It will be overwritten
157 in the install phase below.</para></note>
158-->
159<screen><userinput remap="test">make check</userinput></screen>
160
161 <para>You may see some test failures. The Glibc test suite is
162 somewhat dependent on the host system. A few failures out of
163 over 5000 tests can generally be ignored. This is a list of the
164 most common issues seen for recent versions of LFS:</para>
165
166 <itemizedlist>
167
168 <listitem>
169 <para><emphasis>io/tst-lchmod</emphasis>
170 is known to fail in the LFS chroot environment.</para>
171 </listitem>
172
173 <listitem>
174 <para>Some tests, for example
175 <emphasis>nss/tst-nss-files-hosts-multi</emphasis> and
176 <emphasis>nptl/tst-thread-affinity*</emphasis>
177 are known to fail due to a timeout (especially when the system is
178 relatively slow and/or running the test suite with multiple
179 parallel make jobs). These tests can be identified with:</para>
180
181 <screen><userinput remap="test">grep "Timed out" $(find -name \*.out)</userinput></screen>
182
183 <para>It's possible to re-run a single test with enlarged timeout
184 with
185 <command>TIMEOUTFACTOR=<replaceable>&lt;factor&gt;</replaceable>
186 make test t=<replaceable>&lt;test name&gt;</replaceable></command>.
187 For example, <command>TIMEOUTFACTOR=10 make test
188 t=nss/tst-nss-files-hosts-multi</command> will re-run
189 <emphasis>nss/tst-nss-files-hosts-multi</emphasis> with ten times
190 the original timeout.</para>
191 </listitem>
192
193 <listitem>
194 <para>Additionally, some tests may fail with a relatively old CPU
195 model (for example
196 <emphasis>elf/tst-cpu-features-cpuinfo</emphasis>) or host kernel
197 version (for example
198 <emphasis>stdlib/tst-arc4random-thread</emphasis>).</para>
199 </listitem>
200 </itemizedlist>
201
202 <para>Though it is a harmless message, the install stage of Glibc will
203 complain about the absence of <filename>/etc/ld.so.conf</filename>.
204 Prevent this warning with:</para>
205
206<screen><userinput remap="install">touch /etc/ld.so.conf</userinput></screen>
207
208 <!-- https://sourceware.org/bugzilla/show_bug.cgi?id=21911 -->
209 <para>Fix the Makefile to skip an outdated sanity check
210 that fails with a modern Glibc configuration:</para>
211
212<screen><userinput remap="install">sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile</userinput></screen>
213
214 <important>
215 <para>
216 If upgrading Glibc to a new minor version (for example, from
217 Glibc-2.36 to Glibc-&glibc-version;) on a running LFS system, you
218 need to take some extra precautions to avoid breaking the system:
219 </para>
220
221 <itemizedlist>
222 <listitem>
223 <!-- There are two reasons we don't support this:
224 1. Upgrading on a system with separate /lib and /usr/lib is
225 tricky.
226 2. With Glibc prior to 2.34 libc.so.6 etc. are symlinks to
227 libc-2.33.so etc., again causing the upgradation tricky.
228 The Glibc NEWS file explicit states they no longer use
229 symlinks for the ABI names to avoid upgradation
230 issues. -->
231 <para>
232 Upgrading Glibc on a LFS system prior to 11.0 (exclusive) is
233 not supported. Rebuild LFS if you are running such an old LFS
234 system but you need a newer Glibc.
235 </para>
236 </listitem>
237
238 <!-- https://sourceware.org/pipermail/libc-alpha/2024-January/154095.html -->
239 <listitem>
240 <para>
241 If upgrading on a LFS system prior to 12.0 (exclusive), install
242 <application>Libxcrypt</application> following
243 <xref role='.' linkend='ch-system-libxcrypt'/> In addition to
244 a normal <application>Libxcrypt</application> installation,
245 <emphasis role='bold'>you MUST follow the note in Libxcrypt
246 section to install
247 <filename class='libraryfile'>libcrypt.so.1*</filename>
248 (replacing
249 <filename class='libraryfile'>libcrypt.so.1</filename> from the
250 prior Glibc installation)</emphasis>.
251 </para>
252 </listitem>
253
254 <!-- Otherwise on lfs-systemd nscd will fail to start on boot,
255 and on both lfs-sysv and lfs-systemd useradd etc. will try
256 to start nscd, then nscd will fail to start as well and
257 produce some spurious error message. -->
258 <listitem>
259 <para>
260 If upgrading on a LFS system prior to 12.1 (exclusive),
261 remove the <command>nscd</command> program:
262 </para>
263
264 <screen role='nodump'><userinput>rm -f /usr/sbin/nscd</userinput></screen>
265
266 <para revision='systemd'>
267 If this system (prior to LFS 12.1, exclusive) is based on
268 Systemd, it's also needed to disable and stop the
269 <command>nscd</command> service now:
270 </para>
271
272 <screen revision='systemd' role='nodump'><userinput>systemctl disable --now nscd</userinput></screen>
273 </listitem>
274
275 <listitem>
276 <para>
277 Upgrade the kernel and reboot if it's older than &min-kernel;
278 (check the current version with <command>uname -r</command>)
279 or if you want to upgrade it anyway, following
280 <xref linkend='ch-bootable-kernel' role='.'/>
281 </para>
282 </listitem>
283
284 <listitem>
285 <para>
286 Upgrade the kernel API headers if it's older than &min-kernel;
287 (check the current version with
288 <command>cat /usr/include/linux/version.h</command>)
289 or if you want to upgrade it anyway, following
290 <xref linkend='ch-tools-linux-headers'/> (but removing
291 <envar>$LFS</envar> from the <command>cp</command> command).
292 </para>
293 </listitem>
294
295 <!-- This is to ensure we don't start a process at the time point
296 where some Glibc shared libraries are updated but the others
297 are not. Such mismatches can cause programs crash on startup,
298 esp. a mismatch between ld-linux-x86-64.so.2 and
299 libc.so.6. Note that a crash in the installation process
300 will leave the system in a state with the mismatch forever,
301 unrecoverable without the help of another distro. -->
302 <listitem>
303 <para>
304 Perform a <envar>DESTDIR</envar> installation and upgrade
305 the Glibc shared libraries on the system using one single
306 <command>install</command> command:
307 </para>
308
309 <screen role='nodump'><userinput>make DESTDIR=$PWD/dest install
310install -vm755 dest/usr/lib/*.so.* /usr/lib</userinput></screen>
311 </listitem>
312 </itemizedlist>
313
314 <para>
315 It's imperative to strictly follow these steps above unless you
316 completely understand what you are doing.
317 <emphasis role='bold'>Any unexpected deviation may render the
318 system completely unusable. YOU ARE WARNED.</emphasis>
319 </para>
320
321 <para>
322 Then continue to run the <command>make install</command> command,
323 the <command>sed</command> command against
324 <filename>/usr/bin/ldd</filename>, and the commands to install
325 the locales. Once they are finished, reboot the system
326 immediately.
327 </para>
328 </important>
329
330 <para>Install the package:</para>
331
332<screen><userinput remap="install">make install</userinput></screen>
333
334 <para>Fix a hardcoded path to the executable loader in the
335 <command>ldd</command> script:</para>
336
337<screen><userinput remap="install">sed '/RTLDLIST=/s@/usr@@g' -i /usr/bin/ldd</userinput></screen>
338<!--
339 <para>Install the configuration file and runtime directory for
340 <command>nscd</command>:</para>
341
342<screen><userinput remap="install">cp -v ../nscd/nscd.conf /etc/nscd.conf
343mkdir -pv /var/cache/nscd</userinput></screen>
344
345 <para revision="systemd">Install the systemd support files for
346 <command>nscd</command>:</para>
347
348 <screen revision="systemd"><userinput remap="install">install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
349install -v -Dm644 ../nscd/nscd.service /usr/lib/systemd/system/nscd.service</userinput></screen>
350-->
351 <para>Next, install the locales that can make the system respond in a
352 different language. None of these locales are required, but if some of them
353 are missing, the test suites of some packages will skip important
354 test cases.</para>
355
356 <para>Individual locales can be installed using the
357 <command>localedef</command> program. E.g., the second
358 <command>localedef</command> command below combines the
359 <filename>/usr/share/i18n/locales/cs_CZ</filename>
360 charset-independent locale definition with the
361 <filename>/usr/share/i18n/charmaps/UTF-8.gz</filename>
362 charmap definition and appends the result to the
363 <filename>/usr/lib/locale/locale-archive</filename> file.
364 The following instructions will install the minimum set of
365 locales necessary for the optimal coverage of tests:</para>
366
367<screen role="nodump"><userinput remap="locale-test">mkdir -pv /usr/lib/locale
368localedef -i C -f UTF-8 C.UTF-8
369localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
370localedef -i de_DE -f ISO-8859-1 de_DE
371localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
372localedef -i de_DE -f UTF-8 de_DE.UTF-8
373localedef -i el_GR -f ISO-8859-7 el_GR
374localedef -i en_GB -f ISO-8859-1 en_GB
375localedef -i en_GB -f UTF-8 en_GB.UTF-8
376localedef -i en_HK -f ISO-8859-1 en_HK
377localedef -i en_PH -f ISO-8859-1 en_PH
378localedef -i en_US -f ISO-8859-1 en_US
379localedef -i en_US -f UTF-8 en_US.UTF-8
380localedef -i es_ES -f ISO-8859-15 es_ES@euro
381localedef -i es_MX -f ISO-8859-1 es_MX
382localedef -i fa_IR -f UTF-8 fa_IR
383localedef -i fr_FR -f ISO-8859-1 fr_FR
384localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
385localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
386localedef -i is_IS -f ISO-8859-1 is_IS
387localedef -i is_IS -f UTF-8 is_IS.UTF-8
388localedef -i it_IT -f ISO-8859-1 it_IT
389localedef -i it_IT -f ISO-8859-15 it_IT@euro
390localedef -i it_IT -f UTF-8 it_IT.UTF-8
391localedef -i ja_JP -f EUC-JP ja_JP
392localedef -i ja_JP -f SHIFT_JIS ja_JP.SJIS 2> /dev/null || true
393localedef -i ja_JP -f UTF-8 ja_JP.UTF-8
394localedef -i nl_NL@euro -f ISO-8859-15 nl_NL@euro
395localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
396localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
397localedef -i se_NO -f UTF-8 se_NO.UTF-8
398localedef -i ta_IN -f UTF-8 ta_IN.UTF-8
399localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
400localedef -i zh_CN -f GB18030 zh_CN.GB18030
401localedef -i zh_HK -f BIG5-HKSCS zh_HK.BIG5-HKSCS
402localedef -i zh_TW -f UTF-8 zh_TW.UTF-8</userinput></screen>
403
404 <para>In addition, install the locale for your own country, language and
405 character set.</para>
406
407 <para>Alternatively, install all the locales listed in the
408 <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
409 (it includes every locale listed above and many more) at once with the
410 following time-consuming command:</para>
411
412<screen><userinput remap="locale-full">make localedata/install-locales</userinput></screen>
413
414 <para>Then use the <command>localedef</command> command to create and
415 install locales not listed in the
416 <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
417 when you need them. For instance, the following two locales are
418 needed for some tests later in this chapter:</para>
419
420<screen role="nodump"><userinput remap="locale-full">localedef -i C -f UTF-8 C.UTF-8
421localedef -i ja_JP -f SHIFT_JIS ja_JP.SJIS 2> /dev/null || true</userinput></screen>
422
423 <note><para>Glibc now uses libidn2 when resolving internationalized
424 domain names. This is a run time dependency. If this capability
425 is needed, the instructions for installing libidn2 are in the
426 <ulink url="&blfs-book;general/libidn2.html">BLFS libidn2 page</ulink>.
427 </para></note>
428
429 </sect2>
430
431 <sect2 id="conf-glibc" role="configuration">
432 <title>Configuring Glibc</title>
433
434 <indexterm zone="conf-glibc">
435 <primary sortas="e-/etc/nsswitch.conf">/etc/nsswitch.conf</primary>
436 </indexterm>
437
438 <indexterm zone="conf-glibc">
439 <primary sortas="e-/etc/localtime">/etc/localtime</primary>
440 </indexterm>
441
442 <sect3>
443 <title>Adding nsswitch.conf</title>
444
445 <para>The <filename>/etc/nsswitch.conf</filename> file needs to be created
446 because the Glibc defaults do not work well in a networked environment.
447 </para>
448
449 <para>Create a new file <filename>/etc/nsswitch.conf</filename> by running the
450 following:</para>
451
452<screen revision='sysv'><userinput>cat &gt; /etc/nsswitch.conf &lt;&lt; "EOF"
453<literal># Begin /etc/nsswitch.conf
454
455passwd: files
456group: files
457shadow: files
458
459hosts: files dns
460networks: files
461
462protocols: files
463services: files
464ethers: files
465rpc: files
466
467# End /etc/nsswitch.conf</literal>
468EOF</userinput></screen>
469
470<screen revision='systemd'><userinput>cat &gt; /etc/nsswitch.conf &lt;&lt; "EOF"
471<literal># Begin /etc/nsswitch.conf
472
473passwd: files systemd
474group: files systemd
475shadow: files systemd
476
477hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns
478networks: files
479
480protocols: files
481services: files
482ethers: files
483rpc: files
484
485# End /etc/nsswitch.conf</literal>
486EOF</userinput></screen>
487
488 </sect3>
489
490 <sect3>
491 <title>Adding Time Zone Data</title>
492
493 <para>Install and set up the time zone data with the following:</para>
494<screen><userinput>tar -xf ../../tzdata&tzdata-version;.tar.gz
495
496ZONEINFO=/usr/share/zoneinfo
497mkdir -pv $ZONEINFO/{posix,right}
498
499for tz in etcetera southamerica northamerica europe africa antarctica \
500 asia australasia backward; do
501 zic -L /dev/null -d $ZONEINFO ${tz}
502 zic -L /dev/null -d $ZONEINFO/posix ${tz}
503 zic -L leapseconds -d $ZONEINFO/right ${tz}
504done
505
506cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
507zic -d $ZONEINFO -p America/New_York
508unset ZONEINFO</userinput></screen>
509
510 <variablelist>
511 <title>The meaning of the zic commands:</title>
512
513 <varlistentry>
514 <term><parameter>zic -L /dev/null ...</parameter></term>
515 <listitem>
516 <para>This creates posix time zones without any leap seconds. It is
517 conventional to put these in both
518 <filename class="directory">zoneinfo</filename> and
519 <filename class="directory">zoneinfo/posix</filename>. It is
520 necessary to put the POSIX time zones in
521 <filename class="directory">zoneinfo</filename>, otherwise various
522 test suites will report errors. On an embedded system, where space is
523 tight and you do not intend to ever update the time zones, you could save
524 1.9 MB by not using the <filename class="directory">posix</filename>
525 directory, but some applications or test suites might produce some
526 failures.</para>
527 </listitem>
528 </varlistentry>
529 <varlistentry>
530 <term><parameter>zic -L leapseconds ...</parameter></term>
531 <listitem>
532 <para>This creates right time zones, including leap seconds. On an
533 embedded system, where space is tight and you do not intend to
534 ever update the time zones, or care about the correct time, you could
535 save 1.9MB by omitting the <filename class="directory">right</filename>
536 directory.</para>
537 </listitem>
538 </varlistentry>
539 <varlistentry>
540 <term><parameter>zic ... -p ...</parameter></term>
541 <listitem>
542 <para>This creates the <filename>posixrules</filename> file. We use
543 New York because POSIX requires the daylight saving time rules
544 to be in accordance with US rules.</para>
545 </listitem>
546 </varlistentry>
547 </variablelist>
548
549
550 <para>One way to determine the local time zone is to run the following
551 script:</para>
552
553<screen role="nodump"><userinput>tzselect</userinput></screen>
554
555 <para>After answering a few questions about the location, the script will
556 output the name of the time zone (e.g.,
557 <emphasis>America/Edmonton</emphasis>). There are also some other possible
558 time zones listed in <filename
559 class='directory'>/usr/share/zoneinfo</filename> such as
560 <emphasis>Canada/Eastern</emphasis> or <emphasis>EST5EDT</emphasis> that
561 are not identified by the script but can be used.</para>
562
563 <para>Then create the <filename>/etc/localtime</filename> file by
564 running:</para>
565
566<screen><userinput>ln -sfv /usr/share/zoneinfo/<replaceable>&lt;xxx&gt;</replaceable> /etc/localtime</userinput></screen>
567
568 <para>Replace <replaceable>&lt;xxx&gt;</replaceable> with the name of the
569 time zone selected (e.g., Canada/Eastern).</para>
570
571 </sect3>
572
573 <sect3 id="conf-ld" role="configuration">
574 <title>Configuring the Dynamic Loader</title>
575
576 <indexterm zone="conf-ld">
577 <primary sortas="e-/etc/ld.so.conf">/etc/ld.so.conf</primary>
578 </indexterm>
579
580 <para>By default, the dynamic loader (<filename
581 class="libraryfile">/lib/ld-linux.so.2</filename>) searches through
582 <filename class="directory">/usr/lib</filename> for dynamic libraries
583 that are needed by programs as they are run. However, if there are
584 libraries in directories other than
585 <filename class="directory">/usr/lib</filename>, these need to be added
586 to the <filename>/etc/ld.so.conf</filename> file in order for the
587 dynamic loader to find them. Two directories that are commonly known
588 to contain additional libraries are <filename
589 class="directory">/usr/local/lib</filename> and <filename
590 class="directory">/opt/lib</filename>, so add those directories to the
591 dynamic loader's search path.</para>
592
593 <para>Create a new file <filename>/etc/ld.so.conf</filename> by running the
594 following:</para>
595
596<screen><userinput>cat &gt; /etc/ld.so.conf &lt;&lt; "EOF"
597<literal># Begin /etc/ld.so.conf
598/usr/local/lib
599/opt/lib
600</literal>
601EOF</userinput></screen>
602
603 <para>If desired, the dynamic loader can also search a directory and
604 include the contents of files found there. Generally the files in
605 this include directory are one line specifying the desired library path.
606 To add this capability run the following commands:</para>
607
608<screen role="nodump"><userinput>cat &gt;&gt; /etc/ld.so.conf &lt;&lt; "EOF"
609<literal># Add an include directory
610include /etc/ld.so.conf.d/*.conf
611</literal>
612EOF
613mkdir -pv /etc/ld.so.conf.d</userinput></screen>
614
615 </sect3>
616 </sect2>
617
618 <!-- - - - - - - - - - -->
619 <!-- Multilib - 32bit -->
620 <!-- - - - - - - - - - -->
621 <sect2 arch="ml_32,ml_all">
622 <title>Building Glibc - 32bit</title>
623
624 <para>Now recompile for m32. The extracted source can be
625 reused but needs to be cleaned before installing the m32
626 version of Glibc.</para>
627
628 <para>Clear the build directory and remove artefacts from
629 previous build:</para>
630
631<screen><userinput remap="pre">rm -rf ./*
632find .. -name "*.a" -delete</userinput></screen>
633
634 <para>Configure Glibc for m32 with the following commands:</para>
635
636<screen><userinput remap="configure">CC="gcc -m32" CXX="g++ -m32" \
637../configure \
638 --prefix=/usr \
639 --host=i686-pc-linux-gnu \
640 --build=$(../scripts/config.guess) \
641 --enable-kernel=&min-kernel; \
642 --with-headers=/usr/include \
643 --enable-multi-arch \
644 --libdir=/usr/lib32 \
645 --libexecdir=/usr/lib32 \
646 libc_cv_slibdir=/usr/lib32</userinput></screen>
647
648 <para>Compile the package:</para>
649
650<screen><userinput remap="make">make</userinput></screen>
651
652 <para>Install the package:</para>
653
654<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
655cp -a DESTDIR/usr/lib32/* /usr/lib32/
656install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \
657 /usr/include/gnu/</userinput></screen>
658<!-- no longer required as they are created in chap5
659ln -svf ../lib32/ld-linux.so.2 /lib/ld-linux.so.2
660-->
661
662 <para>Add the library name to the dynamic loader config:</para>
663
664<screen role="install"><userinput>echo "/usr/lib32" &gt;&gt; /etc/ld.so.conf</userinput></screen>
665
666 <caution>
667 <para>At this point, it is imperative to stop and ensure that the basic
668 functions (compiling and linking) of the new toolchain are working as
669 expected. To perform a sanity check, run the following commands:</para>
670
671<screen><userinput>echo 'int main(){}' &gt; dummy.c
672gcc -m32 dummy.c
673readelf -l a.out | grep '/ld-linux'</userinput></screen>
674
675 <para>If everything is working correctly, there should be no errors,
676 and the output of the last command will be of the form:</para>
677
678<screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen>
679
680 <para>If the output is not shown as above or there was no output at all,
681 then something is wrong. Investigate and retrace the steps to find out
682 where the problem is and correct it. This issue must be resolved before
683 continuing on.</para>
684
685 <para>Once all is well, clean up the test files:</para>
686
687<screen><userinput>rm -v dummy.c a.out</userinput></screen>
688
689 </caution>
690
691 </sect2><!-- m32 -->
692
693 <!-- - - - - - - - - - -->
694 <!-- Multilib - x32bit -->
695 <!-- - - - - - - - - - -->
696
697 <sect2 arch="ml_x32,ml_all">
698 <title>Building Glibc - x32bit</title>
699
700 <para>Now recompile for mx32. The extracted source can be
701 reused but needs to be cleaned before installing the mx32
702 version of Glibc.</para>
703
704 <para>Clear the build directory and remove artefacts from
705 previous build:</para>
706
707<screen><userinput remap="pre">rm -rf ./*
708find .. -name "*.a" -delete</userinput></screen>
709
710 <para>Configure Glibc for mx32 with the following commands:</para>
711
712<screen><userinput remap="configure">CC="gcc -mx32" CXX="g++ -mx32" \
713../configure \
714 --prefix=/usr \
715 --host=x86_64-pc-linux-gnux32 \
716 --build=$(../scripts/config.guess) \
717 --enable-kernel=&min-kernel; \
718 --with-headers=/usr/include \
719 --enable-multi-arch \
720 --libdir=/usr/libx32 \
721 --libexecdir=/usr/libx32 \
722 libc_cv_slibdir=/usr/libx32</userinput></screen>
723
724 <para>Compile the package:</para>
725
726<screen><userinput remap="make">make</userinput></screen>
727
728 <para>Install the package:</para>
729
730<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
731cp -a DESTDIR/usr/libx32/* /usr/libx32/
732install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-x32.h \
733 /usr/include/gnu/</userinput></screen>
734<!-- no longer required as they are created in chap5
735ln -svf ../libx32/ld-linux-x32.so.2 /lib/ld-linux-x32.so.2
736-->
737 <para>Add the library name to the dynamic loader config:</para>
738
739<screen role="install"><userinput>echo "/usr/libx32" &gt;&gt; /etc/ld.so.conf</userinput></screen>
740
741 <caution>
742 <para>At this point, it is imperative to stop and ensure that the basic
743 functions (compiling and linking) of the new toolchain are working as
744 expected. To perform a sanity check, run the following commands:</para>
745
746<screen><userinput>echo 'int main(){}' &gt; dummy.c
747gcc -mx32 dummy.c
748readelf -l a.out | grep '/ld-linux-x32'</userinput></screen>
749
750 <para>If everything is working correctly, there should be no errors,
751 and the output of the last command will be of the form:</para>
752
753<screen><computeroutput>[Requesting program interpreter: /libx32/ld-linux-x32.so.2]</computeroutput></screen>
754
755 <para>If the output is not shown as above or there was no output at all,
756 then something is wrong. Investigate and retrace the steps to find out
757 where the problem is and correct it. This issue must be resolved before
758 continuing on.</para>
759
760 <para>Once all is well, clean up the test files:</para>
761
762<screen><userinput>rm -v dummy.c a.out</userinput></screen>
763
764 </caution>
765
766 </sect2><!-- mx32 -->
767
768 <sect2 id="contents-glibc" role="content">
769 <title>Contents of Glibc</title>
770
771 <segmentedlist>
772 <segtitle>Installed programs</segtitle>
773 <segtitle>Installed libraries</segtitle>
774 <segtitle>Installed directories</segtitle>
775
776 <seglistitem>
777 <seg>gencat, getconf, getent, iconv, iconvconfig, ldconfig,
778 ldd, lddlibc4,
779 ld.so (symlink to ld-linux-x86-64.so.2 or ld-linux.so.2),
780 locale, localedef, makedb, mtrace,
781 pcprofiledump, pldd, sln, sotruss, sprof, tzselect, xtrace,
782 zdump, and zic</seg>
783 <seg>ld-linux-x86-64.so.2, ld-linux.so.2,
784 libBrokenLocale.{a,so}, libanl.{a,so},
785 libc.{a,so}, libc_nonshared.a, libc_malloc_debug.so,
786 libdl.{a,so.2}, libg.a, libm.{a,so},
787 libmcheck.a, libmemusage.so, libmvec.{a,so}, libnsl.so.1,
788 libnss_compat.so, libnss_dns.so, libnss_files.so, libnss_hesiod.so,
789 libpcprofile.so, libpthread.{a,so.0},
790 libresolv.{a,so}, librt.{a,so.1},
791 libthread_db.so, and libutil.{a,so.1}</seg>
792 <seg>/usr/include/arpa, /usr/include/bits, /usr/include/gnu,
793 /usr/include/net, /usr/include/netash, /usr/include/netatalk,
794 /usr/include/netax25, /usr/include/neteconet, /usr/include/netinet,
795 /usr/include/netipx, /usr/include/netiucv, /usr/include/netpacket,
796 /usr/include/netrom, /usr/include/netrose, /usr/include/nfs,
797 /usr/include/protocols, /usr/include/rpc,
798 /usr/include/sys, /usr/lib/audit, /usr/lib/gconv, /usr/lib/locale,
799 /usr/libexec/getconf, /usr/share/i18n, /usr/share/zoneinfo,
800 and /var/lib/nss_db</seg>
801 </seglistitem>
802 </segmentedlist>
803
804 <variablelist>
805 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
806 <?dbfo list-presentation="list"?>
807 <?dbhtml list-presentation="table"?>
808
809 <varlistentry id="gencat">
810 <term><command>gencat</command></term>
811 <listitem>
812 <para>Generates message catalogues</para>
813 <indexterm zone="ch-system-glibc gencat">
814 <primary sortas="b-gencat">gencat</primary>
815 </indexterm>
816 </listitem>
817 </varlistentry>
818
819 <varlistentry id="getconf">
820 <term><command>getconf</command></term>
821 <listitem>
822 <para>Displays the system configuration values for file system
823 specific variables</para>
824 <indexterm zone="ch-system-glibc getconf">
825 <primary sortas="b-getconf">getconf</primary>
826 </indexterm>
827 </listitem>
828 </varlistentry>
829
830 <varlistentry id="getent">
831 <term><command>getent</command></term>
832 <listitem>
833 <para>Gets entries from an administrative database</para>
834 <indexterm zone="ch-system-glibc getent">
835 <primary sortas="b-getent">getent</primary>
836 </indexterm>
837 </listitem>
838 </varlistentry>
839
840 <varlistentry id="iconv">
841 <term><command>iconv</command></term>
842 <listitem>
843 <para>Performs character set conversion</para>
844 <indexterm zone="ch-system-glibc iconv">
845 <primary sortas="b-iconv">iconv</primary>
846 </indexterm>
847 </listitem>
848 </varlistentry>
849
850 <varlistentry id="iconvconfig">
851 <term><command>iconvconfig</command></term>
852 <listitem>
853 <para>Creates fastloading <command>iconv</command> module configuration
854 files</para>
855 <indexterm zone="ch-system-glibc iconvconfig">
856 <primary sortas="b-iconvconfig">iconvconfig</primary>
857 </indexterm>
858 </listitem>
859 </varlistentry>
860
861 <varlistentry id="ldconfig">
862 <term><command>ldconfig</command></term>
863 <listitem>
864 <para>Configures the dynamic linker runtime bindings</para>
865 <indexterm zone="ch-system-glibc ldconfig">
866 <primary sortas="b-ldconfig">ldconfig</primary>
867 </indexterm>
868 </listitem>
869 </varlistentry>
870
871 <varlistentry id="ldd">
872 <term><command>ldd</command></term>
873 <listitem>
874 <para>Reports which shared libraries are required
875 by each given program or shared library</para>
876 <indexterm zone="ch-system-glibc ldd">
877 <primary sortas="b-ldd">ldd</primary>
878 </indexterm>
879 </listitem>
880 </varlistentry>
881
882 <varlistentry id="lddlibc4">
883 <term><command>lddlibc4</command></term>
884 <listitem>
885 <para>Assists <command>ldd</command> with object files.
886 It does not exist on newer architectures like x86_64</para>
887 <indexterm zone="ch-system-glibc lddlibc4">
888 <primary sortas="b-lddlibc4">lddlibc4</primary>
889 </indexterm>
890 </listitem>
891 </varlistentry>
892
893 <varlistentry id="locale">
894 <term><command>locale</command></term>
895 <listitem>
896 <para>Prints various information about the current locale</para>
897 <indexterm zone="ch-system-glibc locale">
898 <primary sortas="b-locale">locale</primary>
899 </indexterm>
900 </listitem>
901 </varlistentry>
902
903 <varlistentry id="localedef">
904 <term><command>localedef</command></term>
905 <listitem>
906 <para>Compiles locale specifications</para>
907 <indexterm zone="ch-system-glibc localedef">
908 <primary sortas="b-localedef">localedef</primary>
909 </indexterm>
910 </listitem>
911 </varlistentry>
912
913 <varlistentry id="makedb">
914 <term><command>makedb</command></term>
915 <listitem>
916 <para>Creates a simple database from textual input</para>
917 <indexterm zone="ch-system-glibc makedb">
918 <primary sortas="b-makedb">makedb</primary>
919 </indexterm>
920 </listitem>
921 </varlistentry>
922
923 <varlistentry id="mtrace">
924 <term><command>mtrace</command></term>
925 <listitem>
926 <para>Reads and interprets a memory trace file and displays a summary
927 in human-readable format</para>
928 <indexterm zone="ch-system-glibc mtrace">
929 <primary sortas="b-mtrace">mtrace</primary>
930 </indexterm>
931 </listitem>
932 </varlistentry>
933
934 <varlistentry id="pcprofiledump">
935 <term><command>pcprofiledump</command></term>
936 <listitem>
937 <para>Dump information generated by PC profiling</para>
938 <indexterm zone="ch-system-glibc pcprofiledump">
939 <primary sortas="b-pcprofiledump">pcprofiledump</primary>
940 </indexterm>
941 </listitem>
942 </varlistentry>
943
944 <varlistentry id="pldd">
945 <term><command>pldd</command></term>
946 <listitem>
947 <para>Lists dynamic shared objects used by running processes</para>
948 <indexterm zone="ch-system-glibc pldd">
949 <primary sortas="b-pldd">pldd</primary>
950 </indexterm>
951 </listitem>
952 </varlistentry>
953
954 <varlistentry id="sln">
955 <term><command>sln</command></term>
956 <listitem>
957 <para>A statically linked <command>ln</command> program</para>
958 <indexterm zone="ch-system-glibc sln">
959 <primary sortas="b-sln">sln</primary>
960 </indexterm>
961 </listitem>
962 </varlistentry>
963
964 <varlistentry id="sotruss">
965 <term><command>sotruss</command></term>
966 <listitem>
967 <para>Traces shared library procedure calls of a specified command</para>
968 <indexterm zone="ch-system-glibc sotruss">
969 <primary sortas="b-sotruss">sotruss</primary>
970 </indexterm>
971 </listitem>
972 </varlistentry>
973
974 <varlistentry id="sprof">
975 <term><command>sprof</command></term>
976 <listitem>
977 <para>Reads and displays shared object profiling data</para>
978 <indexterm zone="ch-system-glibc sprof">
979 <primary sortas="b-sprof">sprof</primary>
980 </indexterm>
981 </listitem>
982 </varlistentry>
983
984 <varlistentry id="tzselect">
985 <term><command>tzselect</command></term>
986 <listitem>
987 <para>Asks the user about the location of the system and reports
988 the corresponding time zone description</para>
989 <indexterm zone="ch-system-glibc tzselect">
990 <primary sortas="b-tzselect">tzselect</primary>
991 </indexterm>
992 </listitem>
993 </varlistentry>
994
995 <varlistentry id="xtrace">
996 <term><command>xtrace</command></term>
997 <listitem>
998 <para>Traces the execution of a program by printing the currently
999 executed function</para>
1000 <indexterm zone="ch-system-glibc xtrace">
1001 <primary sortas="b-xtrace">xtrace</primary>
1002 </indexterm>
1003 </listitem>
1004 </varlistentry>
1005
1006 <varlistentry id="zdump">
1007 <term><command>zdump</command></term>
1008 <listitem>
1009 <para>The time zone dumper</para>
1010 <indexterm zone="ch-system-glibc zdump">
1011 <primary sortas="b-zdump">zdump</primary>
1012 </indexterm>
1013 </listitem>
1014 </varlistentry>
1015
1016 <varlistentry id="zic">
1017 <term><command>zic</command></term>
1018 <listitem>
1019 <para>The time zone compiler</para>
1020 <indexterm zone="ch-system-glibc zic">
1021 <primary sortas="b-zic">zic</primary>
1022 </indexterm>
1023 </listitem>
1024 </varlistentry>
1025
1026 <varlistentry id="ld.so">
1027 <term><filename class="libraryfile">ld-*.so</filename></term>
1028 <listitem>
1029 <para>The helper program for shared library executables</para>
1030 <indexterm zone="ch-system-glibc ld.so">
1031 <primary sortas="c-ld.so">ld-&glibc-version;.so</primary>
1032 </indexterm>
1033 </listitem>
1034 </varlistentry>
1035
1036 <varlistentry id="libBrokenLocale">
1037 <term><filename class="libraryfile">libBrokenLocale</filename></term>
1038 <listitem>
1039 <para>Used internally by Glibc as a gross hack to get broken programs
1040 (e.g., some Motif applications) running. See comments in
1041 <filename>glibc-&glibc-version;/locale/broken_cur_max.c</filename>
1042 for more information</para>
1043 <indexterm zone="ch-system-glibc libBrokenLocale">
1044 <primary sortas="c-libBrokenLocale">libBrokenLocale</primary>
1045 </indexterm>
1046 </listitem>
1047 </varlistentry>
1048
1049 <varlistentry id="libanl">
1050 <term><filename class="libraryfile">libanl</filename></term>
1051 <listitem>
1052 <para>Dummy library containing no functions. Previously was the
1053 asynchronous name lookup library, whose functions are now in
1054 <filename class='libraryfile'>libc</filename></para>
1055 <indexterm zone="ch-system-glibc libanl">
1056 <primary sortas="c-libanl">libanl</primary>
1057 </indexterm>
1058 </listitem>
1059 </varlistentry>
1060
1061 <varlistentry id="libc">
1062 <term><filename class="libraryfile">libc</filename></term>
1063 <listitem>
1064 <para>The main C library</para>
1065 <indexterm zone="ch-system-glibc libc">
1066 <primary sortas="c-libc">libc</primary>
1067 </indexterm>
1068 </listitem>
1069 </varlistentry>
1070
1071 <varlistentry id="libc_malloc_debug">
1072 <term><filename class="libraryfile">libc_malloc_debug</filename></term>
1073 <listitem>
1074 <para>Turns on memory allocation checking when preloaded</para>
1075 <indexterm zone="ch-system-glibc libc_malloc_debug">
1076 <primary sortas="c-libc_malloc_debug">libc_malloc_debug</primary>
1077 </indexterm>
1078 </listitem>
1079 </varlistentry>
1080
1081 <varlistentry id="libdl">
1082 <term><filename class="libraryfile">libdl</filename></term>
1083 <listitem>
1084 <para>Dummy library containing no functions. Previously was the
1085 dynamic linking interface library, whose functions are now in
1086 <filename class="libraryfile">libc</filename></para>
1087 <indexterm zone="ch-system-glibc libdl">
1088 <primary sortas="c-libdl">libdl</primary>
1089 </indexterm>
1090 </listitem>
1091 </varlistentry>
1092
1093 <varlistentry id="libg">
1094 <term><filename class="libraryfile">libg</filename></term>
1095 <listitem>
1096 <para>Dummy library containing no functions. Previously was a runtime
1097 library for <command>g++</command></para>
1098 <indexterm zone="ch-system-glibc libg">
1099 <primary sortas="c-libg">libg</primary>
1100 </indexterm>
1101 </listitem>
1102 </varlistentry>
1103
1104 <varlistentry id="libm">
1105 <term><filename class="libraryfile">libm</filename></term>
1106 <listitem>
1107 <para>The mathematical library</para>
1108 <indexterm zone="ch-system-glibc libm">
1109 <primary sortas="c-libm">libm</primary>
1110 </indexterm>
1111 </listitem>
1112 </varlistentry>
1113
1114 <varlistentry id="libmvec">
1115 <term><filename class="libraryfile">libmvec</filename></term>
1116 <listitem>
1117 <para>The vector math library, linked in as needed
1118 when <filename class='libraryfile'>libm</filename> is used</para>
1119 <indexterm zone="ch-system-glibc libmvec">
1120 <primary sortas="c-libmvec">libmvec</primary>
1121 </indexterm>
1122 </listitem>
1123 </varlistentry>
1124
1125 <varlistentry id="libmcheck">
1126 <term><filename class="libraryfile">libmcheck</filename></term>
1127 <listitem>
1128 <para>Turns on memory allocation checking when linked to</para>
1129 <indexterm zone="ch-system-glibc libmcheck">
1130 <primary sortas="c-libmcheck">libmcheck</primary>
1131 </indexterm>
1132 </listitem>
1133 </varlistentry>
1134
1135 <varlistentry id="libmemusage">
1136 <term><filename class="libraryfile">libmemusage</filename></term>
1137 <listitem>
1138 <para>Used by <command>memusage</command> to help collect
1139 information about the memory usage of a program</para>
1140 <indexterm zone="ch-system-glibc libmemusage">
1141 <primary sortas="c-libmemusage">libmemusage</primary>
1142 </indexterm>
1143 </listitem>
1144 </varlistentry>
1145
1146 <varlistentry id="libnsl">
1147 <term><filename class="libraryfile">libnsl</filename></term>
1148 <listitem>
1149 <para>The network services library, now deprecated</para>
1150 <indexterm zone="ch-system-glibc libnsl">
1151 <primary sortas="c-libnsl">libnsl</primary>
1152 </indexterm>
1153 </listitem>
1154 </varlistentry>
1155
1156 <varlistentry id="libnss">
1157 <term><filename class="libraryfile">libnss_*</filename></term>
1158 <listitem>
1159 <para>The Name Service Switch modules, containing functions for
1160 resolving host names, user names, group names, aliases, services,
1161 protocols, etc. Loaded by
1162 <filename class='libraryfile'>libc</filename> according to the
1163 configuration in <filename>/etc/nsswitch.conf</filename></para>
1164 <indexterm zone="ch-system-glibc libnss">
1165 <primary sortas="c-libnss">libnss_*</primary>
1166 </indexterm>
1167 </listitem>
1168 </varlistentry>
1169
1170 <varlistentry id="libpcprofile">
1171 <term><filename class="libraryfile">libpcprofile</filename></term>
1172 <listitem>
1173 <para>Can be preloaded to PC profile an executable</para>
1174 <indexterm zone="ch-system-glibc libpcprofile">
1175 <primary sortas="c-libpcprofile">libpcprofile</primary>
1176 </indexterm>
1177 </listitem>
1178 </varlistentry>
1179
1180 <varlistentry id="libpthread">
1181 <term><filename class="libraryfile">libpthread</filename></term>
1182 <listitem>
1183 <para>Dummy library containing no functions. Previously contained
1184 functions providing most of the interfaces specified
1185 by the POSIX.1c Threads Extensions and the semaphore interfaces
1186 specified by the POSIX.1b Real-time Extensions, now the functions
1187 are in <filename class="libraryfile">libc</filename></para>
1188 <indexterm zone="ch-system-glibc libpthread">
1189 <primary sortas="c-libpthread">libpthread</primary>
1190 </indexterm>
1191 </listitem>
1192 </varlistentry>
1193
1194 <varlistentry id="libresolv">
1195 <term><filename class="libraryfile">libresolv</filename></term>
1196 <listitem>
1197 <para>Contains functions for creating, sending, and interpreting
1198 packets to the Internet domain name servers</para>
1199 <indexterm zone="ch-system-glibc libresolv">
1200 <primary sortas="c-libresolv">libresolv</primary>
1201 </indexterm>
1202 </listitem>
1203 </varlistentry>
1204
1205 <varlistentry id="librt">
1206 <term><filename class="libraryfile">librt</filename></term>
1207 <listitem>
1208 <para>Contains functions providing most of the interfaces specified
1209 by the POSIX.1b Real-time Extensions</para>
1210 <indexterm zone="ch-system-glibc librt">
1211 <primary sortas="c-librt">librt</primary>
1212 </indexterm>
1213 </listitem>
1214 </varlistentry>
1215
1216 <varlistentry id="libthread_db">
1217 <term><filename class="libraryfile">libthread_db</filename></term>
1218 <listitem>
1219 <para>Contains functions useful for building debuggers for
1220 multi-threaded programs</para>
1221 <indexterm zone="ch-system-glibc libthread_db">
1222 <primary sortas="c-libthread_db">libthread_db</primary>
1223 </indexterm>
1224 </listitem>
1225 </varlistentry>
1226
1227 <varlistentry id="libutil">
1228 <term><filename class="libraryfile">libutil</filename></term>
1229 <listitem>
1230 <para>Dummy library containing no functions. Previously contained
1231 code for <quote>standard</quote> functions used in
1232 many different Unix utilities. These functions are now in
1233 <filename class="libraryfile">libc</filename></para>
1234 <indexterm zone="ch-system-glibc libutil">
1235 <primary sortas="c-libutil">libutil</primary>
1236 </indexterm>
1237 </listitem>
1238 </varlistentry>
1239
1240 </variablelist>
1241
1242 </sect2>
1243
1244</sect1>
Note: See TracBrowser for help on using the repository browser.