source: chapter08/glibc.xml@ 82bb649

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

Use --disable-nscd for ml{,x}32 too

  • 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 --disable-nscd \
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">localedef -i C -f UTF-8 C.UTF-8
368localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
369localedef -i de_DE -f ISO-8859-1 de_DE
370localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
371localedef -i de_DE -f UTF-8 de_DE.UTF-8
372localedef -i el_GR -f ISO-8859-7 el_GR
373localedef -i en_GB -f ISO-8859-1 en_GB
374localedef -i en_GB -f UTF-8 en_GB.UTF-8
375localedef -i en_HK -f ISO-8859-1 en_HK
376localedef -i en_PH -f ISO-8859-1 en_PH
377localedef -i en_US -f ISO-8859-1 en_US
378localedef -i en_US -f UTF-8 en_US.UTF-8
379localedef -i es_ES -f ISO-8859-15 es_ES@euro
380localedef -i es_MX -f ISO-8859-1 es_MX
381localedef -i fa_IR -f UTF-8 fa_IR
382localedef -i fr_FR -f ISO-8859-1 fr_FR
383localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
384localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
385localedef -i is_IS -f ISO-8859-1 is_IS
386localedef -i is_IS -f UTF-8 is_IS.UTF-8
387localedef -i it_IT -f ISO-8859-1 it_IT
388localedef -i it_IT -f ISO-8859-15 it_IT@euro
389localedef -i it_IT -f UTF-8 it_IT.UTF-8
390localedef -i ja_JP -f EUC-JP ja_JP
391localedef -i ja_JP -f SHIFT_JIS ja_JP.SJIS 2> /dev/null || true
392localedef -i ja_JP -f UTF-8 ja_JP.UTF-8
393localedef -i nl_NL@euro -f ISO-8859-15 nl_NL@euro
394localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
395localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
396localedef -i se_NO -f UTF-8 se_NO.UTF-8
397localedef -i ta_IN -f UTF-8 ta_IN.UTF-8
398localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
399localedef -i zh_CN -f GB18030 zh_CN.GB18030
400localedef -i zh_HK -f BIG5-HKSCS zh_HK.BIG5-HKSCS
401localedef -i zh_TW -f UTF-8 zh_TW.UTF-8</userinput></screen>
402
403 <para>In addition, install the locale for your own country, language and
404 character set.</para>
405
406 <para>Alternatively, install all the locales listed in the
407 <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
408 (it includes every locale listed above and many more) at once with the
409 following time-consuming command:</para>
410
411<screen><userinput remap="locale-full">make localedata/install-locales</userinput></screen>
412
413 <para>Then use the <command>localedef</command> command to create and
414 install locales not listed in the
415 <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
416 when you need them. For instance, the following two locales are
417 needed for some tests later in this chapter:</para>
418
419<screen role="nodump"><userinput remap="locale-full">localedef -i C -f UTF-8 C.UTF-8
420localedef -i ja_JP -f SHIFT_JIS ja_JP.SJIS 2> /dev/null || true</userinput></screen>
421
422 <note><para>Glibc now uses libidn2 when resolving internationalized
423 domain names. This is a run time dependency. If this capability
424 is needed, the instructions for installing libidn2 are in the
425 <ulink url="&blfs-book;general/libidn2.html">BLFS libidn2 page</ulink>.
426 </para></note>
427
428 </sect2>
429
430 <sect2 id="conf-glibc" role="configuration">
431 <title>Configuring Glibc</title>
432
433 <indexterm zone="conf-glibc">
434 <primary sortas="e-/etc/nsswitch.conf">/etc/nsswitch.conf</primary>
435 </indexterm>
436
437 <indexterm zone="conf-glibc">
438 <primary sortas="e-/etc/localtime">/etc/localtime</primary>
439 </indexterm>
440
441 <sect3>
442 <title>Adding nsswitch.conf</title>
443
444 <para>The <filename>/etc/nsswitch.conf</filename> file needs to be created
445 because the Glibc defaults do not work well in a networked environment.
446 </para>
447
448 <para>Create a new file <filename>/etc/nsswitch.conf</filename> by running the
449 following:</para>
450
451<screen revision='sysv'><userinput>cat &gt; /etc/nsswitch.conf &lt;&lt; "EOF"
452<literal># Begin /etc/nsswitch.conf
453
454passwd: files
455group: files
456shadow: files
457
458hosts: files dns
459networks: files
460
461protocols: files
462services: files
463ethers: files
464rpc: files
465
466# End /etc/nsswitch.conf</literal>
467EOF</userinput></screen>
468
469<screen revision='systemd'><userinput>cat &gt; /etc/nsswitch.conf &lt;&lt; "EOF"
470<literal># Begin /etc/nsswitch.conf
471
472passwd: files systemd
473group: files systemd
474shadow: files systemd
475
476hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns
477networks: files
478
479protocols: files
480services: files
481ethers: files
482rpc: files
483
484# End /etc/nsswitch.conf</literal>
485EOF</userinput></screen>
486
487 </sect3>
488
489 <sect3>
490 <title>Adding Time Zone Data</title>
491
492 <para>Install and set up the time zone data with the following:</para>
493<screen><userinput>tar -xf ../../tzdata&tzdata-version;.tar.gz
494
495ZONEINFO=/usr/share/zoneinfo
496mkdir -pv $ZONEINFO/{posix,right}
497
498for tz in etcetera southamerica northamerica europe africa antarctica \
499 asia australasia backward; do
500 zic -L /dev/null -d $ZONEINFO ${tz}
501 zic -L /dev/null -d $ZONEINFO/posix ${tz}
502 zic -L leapseconds -d $ZONEINFO/right ${tz}
503done
504
505cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
506zic -d $ZONEINFO -p America/New_York
507unset ZONEINFO</userinput></screen>
508
509 <variablelist>
510 <title>The meaning of the zic commands:</title>
511
512 <varlistentry>
513 <term><parameter>zic -L /dev/null ...</parameter></term>
514 <listitem>
515 <para>This creates posix time zones without any leap seconds. It is
516 conventional to put these in both
517 <filename class="directory">zoneinfo</filename> and
518 <filename class="directory">zoneinfo/posix</filename>. It is
519 necessary to put the POSIX time zones in
520 <filename class="directory">zoneinfo</filename>, otherwise various
521 test suites will report errors. On an embedded system, where space is
522 tight and you do not intend to ever update the time zones, you could save
523 1.9 MB by not using the <filename class="directory">posix</filename>
524 directory, but some applications or test suites might produce some
525 failures.</para>
526 </listitem>
527 </varlistentry>
528 <varlistentry>
529 <term><parameter>zic -L leapseconds ...</parameter></term>
530 <listitem>
531 <para>This creates right time zones, including leap seconds. On an
532 embedded system, where space is tight and you do not intend to
533 ever update the time zones, or care about the correct time, you could
534 save 1.9MB by omitting the <filename class="directory">right</filename>
535 directory.</para>
536 </listitem>
537 </varlistentry>
538 <varlistentry>
539 <term><parameter>zic ... -p ...</parameter></term>
540 <listitem>
541 <para>This creates the <filename>posixrules</filename> file. We use
542 New York because POSIX requires the daylight saving time rules
543 to be in accordance with US rules.</para>
544 </listitem>
545 </varlistentry>
546 </variablelist>
547
548
549 <para>One way to determine the local time zone is to run the following
550 script:</para>
551
552<screen role="nodump"><userinput>tzselect</userinput></screen>
553
554 <para>After answering a few questions about the location, the script will
555 output the name of the time zone (e.g.,
556 <emphasis>America/Edmonton</emphasis>). There are also some other possible
557 time zones listed in <filename
558 class='directory'>/usr/share/zoneinfo</filename> such as
559 <emphasis>Canada/Eastern</emphasis> or <emphasis>EST5EDT</emphasis> that
560 are not identified by the script but can be used.</para>
561
562 <para>Then create the <filename>/etc/localtime</filename> file by
563 running:</para>
564
565<screen><userinput>ln -sfv /usr/share/zoneinfo/<replaceable>&lt;xxx&gt;</replaceable> /etc/localtime</userinput></screen>
566
567 <para>Replace <replaceable>&lt;xxx&gt;</replaceable> with the name of the
568 time zone selected (e.g., Canada/Eastern).</para>
569
570 </sect3>
571
572 <sect3 id="conf-ld" role="configuration">
573 <title>Configuring the Dynamic Loader</title>
574
575 <indexterm zone="conf-ld">
576 <primary sortas="e-/etc/ld.so.conf">/etc/ld.so.conf</primary>
577 </indexterm>
578
579 <para>By default, the dynamic loader (<filename
580 class="libraryfile">/lib/ld-linux.so.2</filename>) searches through
581 <filename class="directory">/usr/lib</filename> for dynamic libraries
582 that are needed by programs as they are run. However, if there are
583 libraries in directories other than
584 <filename class="directory">/usr/lib</filename>, these need to be added
585 to the <filename>/etc/ld.so.conf</filename> file in order for the
586 dynamic loader to find them. Two directories that are commonly known
587 to contain additional libraries are <filename
588 class="directory">/usr/local/lib</filename> and <filename
589 class="directory">/opt/lib</filename>, so add those directories to the
590 dynamic loader's search path.</para>
591
592 <para>Create a new file <filename>/etc/ld.so.conf</filename> by running the
593 following:</para>
594
595<screen><userinput>cat &gt; /etc/ld.so.conf &lt;&lt; "EOF"
596<literal># Begin /etc/ld.so.conf
597/usr/local/lib
598/opt/lib
599</literal>
600EOF</userinput></screen>
601
602 <para>If desired, the dynamic loader can also search a directory and
603 include the contents of files found there. Generally the files in
604 this include directory are one line specifying the desired library path.
605 To add this capability run the following commands:</para>
606
607<screen role="nodump"><userinput>cat &gt;&gt; /etc/ld.so.conf &lt;&lt; "EOF"
608<literal># Add an include directory
609include /etc/ld.so.conf.d/*.conf
610</literal>
611EOF
612mkdir -pv /etc/ld.so.conf.d</userinput></screen>
613
614 </sect3>
615 </sect2>
616
617 <!-- - - - - - - - - - -->
618 <!-- Multilib - 32bit -->
619 <!-- - - - - - - - - - -->
620 <sect2 arch="ml_32,ml_all">
621 <title>Building Glibc - 32bit</title>
622
623 <para>Now recompile for m32. The extracted source can be
624 reused but needs to be cleaned before installing the m32
625 version of Glibc.</para>
626
627 <para>Clear the build directory and remove artefacts from
628 previous build:</para>
629
630<screen><userinput remap="pre">rm -rf ./*
631find .. -name "*.a" -delete</userinput></screen>
632
633 <para>Configure Glibc for m32 with the following commands:</para>
634
635<screen><userinput remap="configure">CC="gcc -m32" CXX="g++ -m32" \
636../configure \
637 --prefix=/usr \
638 --host=i686-pc-linux-gnu \
639 --build=$(../scripts/config.guess) \
640 --enable-kernel=&min-kernel; \
641 --with-headers=/usr/include \
642 --enable-multi-arch \
643 --libdir=/usr/lib32 \
644 --libexecdir=/usr/lib32 \
645 libc_cv_slibdir=/usr/lib32</userinput></screen>
646
647 <para>Compile the package:</para>
648
649<screen><userinput remap="make">make</userinput></screen>
650
651 <para>Install the package:</para>
652
653<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
654cp -a DESTDIR/usr/lib32/* /usr/lib32/
655install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \
656 /usr/include/gnu/</userinput></screen>
657<!-- no longer required as they are created in chap5
658ln -svf ../lib32/ld-linux.so.2 /lib/ld-linux.so.2
659-->
660
661 <para>Add the library name to the dynamic loader config:</para>
662
663<screen role="install"><userinput>echo "/usr/lib32" &gt;&gt; /etc/ld.so.conf</userinput></screen>
664
665 <caution>
666 <para>At this point, it is imperative to stop and ensure that the basic
667 functions (compiling and linking) of the new toolchain are working as
668 expected. To perform a sanity check, run the following commands:</para>
669
670<screen><userinput>echo 'int main(){}' &gt; dummy.c
671gcc -m32 dummy.c
672readelf -l a.out | grep '/ld-linux'</userinput></screen>
673
674 <para>If everything is working correctly, there should be no errors,
675 and the output of the last command will be of the form:</para>
676
677<screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen>
678
679 <para>If the output is not shown as above or there was no output at all,
680 then something is wrong. Investigate and retrace the steps to find out
681 where the problem is and correct it. This issue must be resolved before
682 continuing on.</para>
683
684 <para>Once all is well, clean up the test files:</para>
685
686<screen><userinput>rm -v dummy.c a.out</userinput></screen>
687
688 </caution>
689
690 </sect2><!-- m32 -->
691
692 <!-- - - - - - - - - - -->
693 <!-- Multilib - x32bit -->
694 <!-- - - - - - - - - - -->
695
696 <sect2 arch="ml_x32,ml_all">
697 <title>Building Glibc - x32bit</title>
698
699 <para>Now recompile for mx32. The extracted source can be
700 reused but needs to be cleaned before installing the mx32
701 version of Glibc.</para>
702
703 <para>Clear the build directory and remove artefacts from
704 previous build:</para>
705
706<screen><userinput remap="pre">rm -rf ./*
707find .. -name "*.a" -delete</userinput></screen>
708
709 <para>Configure Glibc for mx32 with the following commands:</para>
710
711<screen><userinput remap="configure">CC="gcc -mx32" CXX="g++ -mx32" \
712../configure \
713 --prefix=/usr \
714 --host=x86_64-pc-linux-gnux32 \
715 --build=$(../scripts/config.guess) \
716 --enable-kernel=&min-kernel; \
717 --with-headers=/usr/include \
718 --enable-multi-arch \
719 --libdir=/usr/libx32 \
720 --libexecdir=/usr/libx32 \
721 libc_cv_slibdir=/usr/libx32</userinput></screen>
722
723 <para>Compile the package:</para>
724
725<screen><userinput remap="make">make</userinput></screen>
726
727 <para>Install the package:</para>
728
729<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
730cp -a DESTDIR/usr/libx32/* /usr/libx32/
731install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-x32.h \
732 /usr/include/gnu/</userinput></screen>
733<!-- no longer required as they are created in chap5
734ln -svf ../libx32/ld-linux-x32.so.2 /lib/ld-linux-x32.so.2
735-->
736 <para>Add the library name to the dynamic loader config:</para>
737
738<screen role="install"><userinput>echo "/usr/libx32" &gt;&gt; /etc/ld.so.conf</userinput></screen>
739
740 <caution>
741 <para>At this point, it is imperative to stop and ensure that the basic
742 functions (compiling and linking) of the new toolchain are working as
743 expected. To perform a sanity check, run the following commands:</para>
744
745<screen><userinput>echo 'int main(){}' &gt; dummy.c
746gcc -mx32 dummy.c
747readelf -l a.out | grep '/ld-linux-x32'</userinput></screen>
748
749 <para>If everything is working correctly, there should be no errors,
750 and the output of the last command will be of the form:</para>
751
752<screen><computeroutput>[Requesting program interpreter: /libx32/ld-linux-x32.so.2]</computeroutput></screen>
753
754 <para>If the output is not shown as above or there was no output at all,
755 then something is wrong. Investigate and retrace the steps to find out
756 where the problem is and correct it. This issue must be resolved before
757 continuing on.</para>
758
759 <para>Once all is well, clean up the test files:</para>
760
761<screen><userinput>rm -v dummy.c a.out</userinput></screen>
762
763 </caution>
764
765 </sect2><!-- mx32 -->
766
767 <sect2 id="contents-glibc" role="content">
768 <title>Contents of Glibc</title>
769
770 <segmentedlist>
771 <segtitle>Installed programs</segtitle>
772 <segtitle>Installed libraries</segtitle>
773 <segtitle>Installed directories</segtitle>
774
775 <seglistitem>
776 <seg>gencat, getconf, getent, iconv, iconvconfig, ldconfig,
777 ldd, lddlibc4,
778 ld.so (symlink to ld-linux-x86-64.so.2 or ld-linux.so.2),
779 locale, localedef, makedb, mtrace,
780 pcprofiledump, pldd, sln, sotruss, sprof, tzselect, xtrace,
781 zdump, and zic</seg>
782 <seg>ld-linux-x86-64.so.2, ld-linux.so.2,
783 libBrokenLocale.{a,so}, libanl.{a,so},
784 libc.{a,so}, libc_nonshared.a, libc_malloc_debug.so,
785 libdl.{a,so.2}, libg.a, libm.{a,so},
786 libmcheck.a, libmemusage.so, libmvec.{a,so}, libnsl.so.1,
787 libnss_compat.so, libnss_dns.so, libnss_files.so, libnss_hesiod.so,
788 libpcprofile.so, libpthread.{a,so.0},
789 libresolv.{a,so}, librt.{a,so.1},
790 libthread_db.so, and libutil.{a,so.1}</seg>
791 <seg>/usr/include/arpa, /usr/include/bits, /usr/include/gnu,
792 /usr/include/net, /usr/include/netash, /usr/include/netatalk,
793 /usr/include/netax25, /usr/include/neteconet, /usr/include/netinet,
794 /usr/include/netipx, /usr/include/netiucv, /usr/include/netpacket,
795 /usr/include/netrom, /usr/include/netrose, /usr/include/nfs,
796 /usr/include/protocols, /usr/include/rpc,
797 /usr/include/sys, /usr/lib/audit, /usr/lib/gconv, /usr/lib/locale,
798 /usr/libexec/getconf, /usr/share/i18n, /usr/share/zoneinfo,
799 and /var/lib/nss_db</seg>
800 </seglistitem>
801 </segmentedlist>
802
803 <variablelist>
804 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
805 <?dbfo list-presentation="list"?>
806 <?dbhtml list-presentation="table"?>
807
808 <varlistentry id="gencat">
809 <term><command>gencat</command></term>
810 <listitem>
811 <para>Generates message catalogues</para>
812 <indexterm zone="ch-system-glibc gencat">
813 <primary sortas="b-gencat">gencat</primary>
814 </indexterm>
815 </listitem>
816 </varlistentry>
817
818 <varlistentry id="getconf">
819 <term><command>getconf</command></term>
820 <listitem>
821 <para>Displays the system configuration values for file system
822 specific variables</para>
823 <indexterm zone="ch-system-glibc getconf">
824 <primary sortas="b-getconf">getconf</primary>
825 </indexterm>
826 </listitem>
827 </varlistentry>
828
829 <varlistentry id="getent">
830 <term><command>getent</command></term>
831 <listitem>
832 <para>Gets entries from an administrative database</para>
833 <indexterm zone="ch-system-glibc getent">
834 <primary sortas="b-getent">getent</primary>
835 </indexterm>
836 </listitem>
837 </varlistentry>
838
839 <varlistentry id="iconv">
840 <term><command>iconv</command></term>
841 <listitem>
842 <para>Performs character set conversion</para>
843 <indexterm zone="ch-system-glibc iconv">
844 <primary sortas="b-iconv">iconv</primary>
845 </indexterm>
846 </listitem>
847 </varlistentry>
848
849 <varlistentry id="iconvconfig">
850 <term><command>iconvconfig</command></term>
851 <listitem>
852 <para>Creates fastloading <command>iconv</command> module configuration
853 files</para>
854 <indexterm zone="ch-system-glibc iconvconfig">
855 <primary sortas="b-iconvconfig">iconvconfig</primary>
856 </indexterm>
857 </listitem>
858 </varlistentry>
859
860 <varlistentry id="ldconfig">
861 <term><command>ldconfig</command></term>
862 <listitem>
863 <para>Configures the dynamic linker runtime bindings</para>
864 <indexterm zone="ch-system-glibc ldconfig">
865 <primary sortas="b-ldconfig">ldconfig</primary>
866 </indexterm>
867 </listitem>
868 </varlistentry>
869
870 <varlistentry id="ldd">
871 <term><command>ldd</command></term>
872 <listitem>
873 <para>Reports which shared libraries are required
874 by each given program or shared library</para>
875 <indexterm zone="ch-system-glibc ldd">
876 <primary sortas="b-ldd">ldd</primary>
877 </indexterm>
878 </listitem>
879 </varlistentry>
880
881 <varlistentry id="lddlibc4">
882 <term><command>lddlibc4</command></term>
883 <listitem>
884 <para>Assists <command>ldd</command> with object files.
885 It does not exist on newer architectures like x86_64</para>
886 <indexterm zone="ch-system-glibc lddlibc4">
887 <primary sortas="b-lddlibc4">lddlibc4</primary>
888 </indexterm>
889 </listitem>
890 </varlistentry>
891
892 <varlistentry id="locale">
893 <term><command>locale</command></term>
894 <listitem>
895 <para>Prints various information about the current locale</para>
896 <indexterm zone="ch-system-glibc locale">
897 <primary sortas="b-locale">locale</primary>
898 </indexterm>
899 </listitem>
900 </varlistentry>
901
902 <varlistentry id="localedef">
903 <term><command>localedef</command></term>
904 <listitem>
905 <para>Compiles locale specifications</para>
906 <indexterm zone="ch-system-glibc localedef">
907 <primary sortas="b-localedef">localedef</primary>
908 </indexterm>
909 </listitem>
910 </varlistentry>
911
912 <varlistentry id="makedb">
913 <term><command>makedb</command></term>
914 <listitem>
915 <para>Creates a simple database from textual input</para>
916 <indexterm zone="ch-system-glibc makedb">
917 <primary sortas="b-makedb">makedb</primary>
918 </indexterm>
919 </listitem>
920 </varlistentry>
921
922 <varlistentry id="mtrace">
923 <term><command>mtrace</command></term>
924 <listitem>
925 <para>Reads and interprets a memory trace file and displays a summary
926 in human-readable format</para>
927 <indexterm zone="ch-system-glibc mtrace">
928 <primary sortas="b-mtrace">mtrace</primary>
929 </indexterm>
930 </listitem>
931 </varlistentry>
932
933 <varlistentry id="pcprofiledump">
934 <term><command>pcprofiledump</command></term>
935 <listitem>
936 <para>Dump information generated by PC profiling</para>
937 <indexterm zone="ch-system-glibc pcprofiledump">
938 <primary sortas="b-pcprofiledump">pcprofiledump</primary>
939 </indexterm>
940 </listitem>
941 </varlistentry>
942
943 <varlistentry id="pldd">
944 <term><command>pldd</command></term>
945 <listitem>
946 <para>Lists dynamic shared objects used by running processes</para>
947 <indexterm zone="ch-system-glibc pldd">
948 <primary sortas="b-pldd">pldd</primary>
949 </indexterm>
950 </listitem>
951 </varlistentry>
952
953 <varlistentry id="sln">
954 <term><command>sln</command></term>
955 <listitem>
956 <para>A statically linked <command>ln</command> program</para>
957 <indexterm zone="ch-system-glibc sln">
958 <primary sortas="b-sln">sln</primary>
959 </indexterm>
960 </listitem>
961 </varlistentry>
962
963 <varlistentry id="sotruss">
964 <term><command>sotruss</command></term>
965 <listitem>
966 <para>Traces shared library procedure calls of a specified command</para>
967 <indexterm zone="ch-system-glibc sotruss">
968 <primary sortas="b-sotruss">sotruss</primary>
969 </indexterm>
970 </listitem>
971 </varlistentry>
972
973 <varlistentry id="sprof">
974 <term><command>sprof</command></term>
975 <listitem>
976 <para>Reads and displays shared object profiling data</para>
977 <indexterm zone="ch-system-glibc sprof">
978 <primary sortas="b-sprof">sprof</primary>
979 </indexterm>
980 </listitem>
981 </varlistentry>
982
983 <varlistentry id="tzselect">
984 <term><command>tzselect</command></term>
985 <listitem>
986 <para>Asks the user about the location of the system and reports
987 the corresponding time zone description</para>
988 <indexterm zone="ch-system-glibc tzselect">
989 <primary sortas="b-tzselect">tzselect</primary>
990 </indexterm>
991 </listitem>
992 </varlistentry>
993
994 <varlistentry id="xtrace">
995 <term><command>xtrace</command></term>
996 <listitem>
997 <para>Traces the execution of a program by printing the currently
998 executed function</para>
999 <indexterm zone="ch-system-glibc xtrace">
1000 <primary sortas="b-xtrace">xtrace</primary>
1001 </indexterm>
1002 </listitem>
1003 </varlistentry>
1004
1005 <varlistentry id="zdump">
1006 <term><command>zdump</command></term>
1007 <listitem>
1008 <para>The time zone dumper</para>
1009 <indexterm zone="ch-system-glibc zdump">
1010 <primary sortas="b-zdump">zdump</primary>
1011 </indexterm>
1012 </listitem>
1013 </varlistentry>
1014
1015 <varlistentry id="zic">
1016 <term><command>zic</command></term>
1017 <listitem>
1018 <para>The time zone compiler</para>
1019 <indexterm zone="ch-system-glibc zic">
1020 <primary sortas="b-zic">zic</primary>
1021 </indexterm>
1022 </listitem>
1023 </varlistentry>
1024
1025 <varlistentry id="ld.so">
1026 <term><filename class="libraryfile">ld-*.so</filename></term>
1027 <listitem>
1028 <para>The helper program for shared library executables</para>
1029 <indexterm zone="ch-system-glibc ld.so">
1030 <primary sortas="c-ld.so">ld-&glibc-version;.so</primary>
1031 </indexterm>
1032 </listitem>
1033 </varlistentry>
1034
1035 <varlistentry id="libBrokenLocale">
1036 <term><filename class="libraryfile">libBrokenLocale</filename></term>
1037 <listitem>
1038 <para>Used internally by Glibc as a gross hack to get broken programs
1039 (e.g., some Motif applications) running. See comments in
1040 <filename>glibc-&glibc-version;/locale/broken_cur_max.c</filename>
1041 for more information</para>
1042 <indexterm zone="ch-system-glibc libBrokenLocale">
1043 <primary sortas="c-libBrokenLocale">libBrokenLocale</primary>
1044 </indexterm>
1045 </listitem>
1046 </varlistentry>
1047
1048 <varlistentry id="libanl">
1049 <term><filename class="libraryfile">libanl</filename></term>
1050 <listitem>
1051 <para>Dummy library containing no functions. Previously was the
1052 asynchronous name lookup library, whose functions are now in
1053 <filename class='libraryfile'>libc</filename></para>
1054 <indexterm zone="ch-system-glibc libanl">
1055 <primary sortas="c-libanl">libanl</primary>
1056 </indexterm>
1057 </listitem>
1058 </varlistentry>
1059
1060 <varlistentry id="libc">
1061 <term><filename class="libraryfile">libc</filename></term>
1062 <listitem>
1063 <para>The main C library</para>
1064 <indexterm zone="ch-system-glibc libc">
1065 <primary sortas="c-libc">libc</primary>
1066 </indexterm>
1067 </listitem>
1068 </varlistentry>
1069
1070 <varlistentry id="libc_malloc_debug">
1071 <term><filename class="libraryfile">libc_malloc_debug</filename></term>
1072 <listitem>
1073 <para>Turns on memory allocation checking when preloaded</para>
1074 <indexterm zone="ch-system-glibc libc_malloc_debug">
1075 <primary sortas="c-libc_malloc_debug">libc_malloc_debug</primary>
1076 </indexterm>
1077 </listitem>
1078 </varlistentry>
1079
1080 <varlistentry id="libdl">
1081 <term><filename class="libraryfile">libdl</filename></term>
1082 <listitem>
1083 <para>Dummy library containing no functions. Previously was the
1084 dynamic linking interface library, whose functions are now in
1085 <filename class="libraryfile">libc</filename></para>
1086 <indexterm zone="ch-system-glibc libdl">
1087 <primary sortas="c-libdl">libdl</primary>
1088 </indexterm>
1089 </listitem>
1090 </varlistentry>
1091
1092 <varlistentry id="libg">
1093 <term><filename class="libraryfile">libg</filename></term>
1094 <listitem>
1095 <para>Dummy library containing no functions. Previously was a runtime
1096 library for <command>g++</command></para>
1097 <indexterm zone="ch-system-glibc libg">
1098 <primary sortas="c-libg">libg</primary>
1099 </indexterm>
1100 </listitem>
1101 </varlistentry>
1102
1103 <varlistentry id="libm">
1104 <term><filename class="libraryfile">libm</filename></term>
1105 <listitem>
1106 <para>The mathematical library</para>
1107 <indexterm zone="ch-system-glibc libm">
1108 <primary sortas="c-libm">libm</primary>
1109 </indexterm>
1110 </listitem>
1111 </varlistentry>
1112
1113 <varlistentry id="libmvec">
1114 <term><filename class="libraryfile">libmvec</filename></term>
1115 <listitem>
1116 <para>The vector math library, linked in as needed
1117 when <filename class='libraryfile'>libm</filename> is used</para>
1118 <indexterm zone="ch-system-glibc libmvec">
1119 <primary sortas="c-libmvec">libmvec</primary>
1120 </indexterm>
1121 </listitem>
1122 </varlistentry>
1123
1124 <varlistentry id="libmcheck">
1125 <term><filename class="libraryfile">libmcheck</filename></term>
1126 <listitem>
1127 <para>Turns on memory allocation checking when linked to</para>
1128 <indexterm zone="ch-system-glibc libmcheck">
1129 <primary sortas="c-libmcheck">libmcheck</primary>
1130 </indexterm>
1131 </listitem>
1132 </varlistentry>
1133
1134 <varlistentry id="libmemusage">
1135 <term><filename class="libraryfile">libmemusage</filename></term>
1136 <listitem>
1137 <para>Used by <command>memusage</command> to help collect
1138 information about the memory usage of a program</para>
1139 <indexterm zone="ch-system-glibc libmemusage">
1140 <primary sortas="c-libmemusage">libmemusage</primary>
1141 </indexterm>
1142 </listitem>
1143 </varlistentry>
1144
1145 <varlistentry id="libnsl">
1146 <term><filename class="libraryfile">libnsl</filename></term>
1147 <listitem>
1148 <para>The network services library, now deprecated</para>
1149 <indexterm zone="ch-system-glibc libnsl">
1150 <primary sortas="c-libnsl">libnsl</primary>
1151 </indexterm>
1152 </listitem>
1153 </varlistentry>
1154
1155 <varlistentry id="libnss">
1156 <term><filename class="libraryfile">libnss_*</filename></term>
1157 <listitem>
1158 <para>The Name Service Switch modules, containing functions for
1159 resolving host names, user names, group names, aliases, services,
1160 protocols, etc. Loaded by
1161 <filename class='libraryfile'>libc</filename> according to the
1162 configuration in <filename>/etc/nsswitch.conf</filename></para>
1163 <indexterm zone="ch-system-glibc libnss">
1164 <primary sortas="c-libnss">libnss_*</primary>
1165 </indexterm>
1166 </listitem>
1167 </varlistentry>
1168
1169 <varlistentry id="libpcprofile">
1170 <term><filename class="libraryfile">libpcprofile</filename></term>
1171 <listitem>
1172 <para>Can be preloaded to PC profile an executable</para>
1173 <indexterm zone="ch-system-glibc libpcprofile">
1174 <primary sortas="c-libpcprofile">libpcprofile</primary>
1175 </indexterm>
1176 </listitem>
1177 </varlistentry>
1178
1179 <varlistentry id="libpthread">
1180 <term><filename class="libraryfile">libpthread</filename></term>
1181 <listitem>
1182 <para>Dummy library containing no functions. Previously contained
1183 functions providing most of the interfaces specified
1184 by the POSIX.1c Threads Extensions and the semaphore interfaces
1185 specified by the POSIX.1b Real-time Extensions, now the functions
1186 are in <filename class="libraryfile">libc</filename></para>
1187 <indexterm zone="ch-system-glibc libpthread">
1188 <primary sortas="c-libpthread">libpthread</primary>
1189 </indexterm>
1190 </listitem>
1191 </varlistentry>
1192
1193 <varlistentry id="libresolv">
1194 <term><filename class="libraryfile">libresolv</filename></term>
1195 <listitem>
1196 <para>Contains functions for creating, sending, and interpreting
1197 packets to the Internet domain name servers</para>
1198 <indexterm zone="ch-system-glibc libresolv">
1199 <primary sortas="c-libresolv">libresolv</primary>
1200 </indexterm>
1201 </listitem>
1202 </varlistentry>
1203
1204 <varlistentry id="librt">
1205 <term><filename class="libraryfile">librt</filename></term>
1206 <listitem>
1207 <para>Contains functions providing most of the interfaces specified
1208 by the POSIX.1b Real-time Extensions</para>
1209 <indexterm zone="ch-system-glibc librt">
1210 <primary sortas="c-librt">librt</primary>
1211 </indexterm>
1212 </listitem>
1213 </varlistentry>
1214
1215 <varlistentry id="libthread_db">
1216 <term><filename class="libraryfile">libthread_db</filename></term>
1217 <listitem>
1218 <para>Contains functions useful for building debuggers for
1219 multi-threaded programs</para>
1220 <indexterm zone="ch-system-glibc libthread_db">
1221 <primary sortas="c-libthread_db">libthread_db</primary>
1222 </indexterm>
1223 </listitem>
1224 </varlistentry>
1225
1226 <varlistentry id="libutil">
1227 <term><filename class="libraryfile">libutil</filename></term>
1228 <listitem>
1229 <para>Dummy library containing no functions. Previously contained
1230 code for <quote>standard</quote> functions used in
1231 many different Unix utilities. These functions are now in
1232 <filename class="libraryfile">libc</filename></para>
1233 <indexterm zone="ch-system-glibc libutil">
1234 <primary sortas="c-libutil">libutil</primary>
1235 </indexterm>
1236 </listitem>
1237 </varlistentry>
1238
1239 </variablelist>
1240
1241 </sect2>
1242
1243</sect1>
Note: See TracBrowser for help on using the repository browser.