source: chapter08/glibc.xml@ b3a55dc

multilib xry111/multilib
Last change on this file since b3a55dc was 9bc9f43, checked in by Thomas Trepl <thomas@…>, 7 months ago

Automatic merge of trunk into multilib

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