source: chapter08/glibc.xml@ 7f3f152

multilib
Last change on this file since 7f3f152 was 7f3f152, checked in by Thomas Trepl <thomas@…>, 3 weeks ago

Automatic merge of trunk into multilib

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