source: chapter08/glibc.xml@ 042f99a

multilib xry111/multilib
Last change on this file since 042f99a was 807b061, checked in by Thomas Trepl <thomas@…>, 8 months ago

Automatic merge of trunk into multilib

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