123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
- "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
- <!ENTITY % general-entities SYSTEM "../general.ent">
- %general-entities;
- ]>
- <sect1 id="ch-system-glibc" role="wrap">
- <?dbhtml filename="glibc.html"?>
- <sect1info condition="script">
- <productname>glibc</productname>
- <productnumber>&glibc-version;</productnumber>
- <address>&glibc-url;</address>
- </sect1info>
- <title>Glibc-&glibc-version;</title>
- <indexterm zone="ch-system-glibc">
- <primary sortas="a-Glibc">Glibc</primary>
- </indexterm>
- <sect2 role="package">
- <title/>
- <!--para>The Glibc package contains the main C library. This library provides
- the basic routines for allocating memory, searching directories, opening and
- closing files, reading and writing files, string handling, pattern matching,
- arithmetic, and so on.</para-->
- <para>Glibc 软件包包含主要的 C 语言库。它提供用于分配内存、检索目录、
- 打开和关闭文件、读写文件、字符串处理、模式匹配、
- 算术等用途的基本子程序。</para>
- <segmentedlist>
- <segtitle>&buildtime;</segtitle>
- <segtitle>&diskspace;</segtitle>
- <seglistitem>
- <seg>&glibc-ch6-sbu;</seg>
- <seg>&glibc-ch6-du;</seg>
- </seglistitem>
- </segmentedlist>
- </sect2>
- <sect2 role="installation">
- <title>安装 Glibc</title>
- <note><!--para>The Glibc build system is self-contained and will install
- perfectly, even though the compiler specs file and linker are still
- pointing to <filename class="directory">/tools</filename>. The specs
- and linker cannot be adjusted before the Glibc install because the
- Glibc autoconf tests would give false results and defeat the goal
- of achieving a clean build.</para-->
- <para> Glibc 构建系统是自给自足的,
- 即使编译器 specs 文件和链接器仍然指向
- <filename class="directory">/tools</filename>,
- 也能完美地安装 Glibc 。在安装 Glibc 之前不能调整工具链,
- 否则 Glibc 的 autoconf 测试会给出错误结果,
- 结果无法达成干净地构建 Glibc 这一目的。</para>
- </note>
- <!--para>Some of the Glibc programs use the non-FHS compilant
- <filename class="directory">/var/db</filename> directory to store
- their runtime data. Apply the following patch to make such programs
- store their runtime data in the FHS-compliant locations:</para-->
- <para>某些 Glibc 程序使用与 FHS 不兼容的
- <filename class="directory">/var/db</filename>
- 目录存放运行时数据。应用下列补丁,
- 使得这些程序在 FHS 兼容的位置存储运行时数据:</para>
- <screen><userinput remap="pre">patch -Np1 -i ../&glibc-fhs-patch;</userinput></screen>
- <!--
- <para>Fix a minor security issue with glob functions:</para>
- <screen><userinput remap="pre">patch -Np1 -i ../&glibc-glob-patch;</userinput></screen>
- --><!--
- <para>First create a compatibility symlink to avoid references to /tools in
- our final glibc:</para>
- <screen><userinput remap="pre">ln -sfv /tools/lib/gcc /usr/lib</userinput></screen>
- -->
- <!--para>Create a symlink for LSB
- compliance. Additionally, for x86_64, create a compatibility symlink
- required for the dynamic loader to function correctly:</para-->
- <para>为了兼容 LSB 创建一个符号链接。另外,
- 对于 x86_64 ,还要创建一个动态链接器的兼容性符号链接,
- 使它能够正常工作:</para>
- <screen><userinput remap="pre">case $(uname -m) in
- i?86) ln -sfv ld-linux.so.2 /lib/ld-lsb.so.3
- ;;
- x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64
- ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3
- ;;
- esac</userinput></screen>
- <!--
- <para>删除上次编译时可能留下的文件:</para>
- <note><title>译注</title>
- <para>译者的惨痛教训表明,如果存在这个文件,
- 构建系统会无限循环。</para>
- </note>
- <screen><userinput remap="pre">rm -f /usr/include/limits.h</userinput></screen>
- -->
- <!--para>The Glibc documentation recommends building Glibc
- in a dedicated build directory:</para-->
- <para>Glibc 文档推荐在专用目录中构建它:</para>
- <screen><userinput remap="pre">mkdir -v build
- cd build</userinput></screen>
- <para>准备安装 Glibc:</para>
- <screen><userinput remap="configure">CC="gcc -ffile-prefix-map=/tools=/usr" \
- ../configure --prefix=/usr \
- --disable-werror \
- --enable-kernel=&min-kernel; \
- --enable-stack-protector=strong \
- --with-headers=/usr/include \
- libc_cv_slibdir=/lib</userinput></screen>
- <variablelist>
- <title>新的配置选项和参数的含义:</title>
- <varlistentry>
- <term><parameter>CC="gcc -ffile-prefix-map=/tools=/usr"</parameter></term>
- <listitem>
- <para>使 GCC 在编译结果中记录文件的路径时,
- 将 /tools 中的文件记录为 /usr 中的对应路径。
- 这可以避免调试符号中出现无效路径。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>--disable-werror</parameter></term>
- <listitem>
- <!--para>This option disables the -Werror option passed to
- GCC. This is necessary for running the test suite.</para-->
- <para>该选项禁用 GCC 的 -Werror 选项,
- 这对于运行测试套件来说是必须的。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>--enable-stack-protector=strong</parameter></term>
- <listitem>
- <!--para>This option increases system security by adding
- extra code to check for buffer overflows, such as stack
- smashing attacks.</para-->
- <para>该选项通过加入额外代码,
- 对栈溢出攻击等导致的缓冲区溢出进行检查,以提高系统安全性。
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>--with-headers=/usr/include</parameter></term>
- <listitem>
- <para>该选项指定构建系统搜索内核 API 头文件的位置。
- 默认情况下,该位置是
- <filename class="directory">/tools/include</filename>。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>libc_cv_slibdir=/lib</parameter></term>
- <listitem>
- <para>这个变量纠正库文件安装位置,
- 我们不希望使用 lib64 目录。</para>
- </listitem>
- </varlistentry>
- </variablelist>
- <para>编译该软件包:</para>
- <screen><userinput remap="make">make</userinput></screen>
- <important>
- <!--para>In this section, the test suite for Glibc is considered critical.
- Do not skip it under any circumstance.</para-->
- <para>在本节中, Glibc 的测试套件十分关键,在任何情况下都不能跳过。
- </para>
- </important>
- <!--para>Generally a few tests do not pass. The test failures listed below
- are usually safe to ignore.</para-->
- <para>通常来说,可能会有极少数测试不能通过,
- 下面列出的失败结果一般可以安全地忽略。执行以下命令进行测试:
- </para>
- <!-- Use remap="make" here to work around a jhalfs issue. -->
- <screen><userinput remap="make">case $(uname -m) in
- i?86) ln -sfnv $PWD/elf/ld-linux.so.2 /lib ;;
- x86_64) ln -sfnv $PWD/elf/ld-linux-x86-64.so.2 /lib ;;
- esac</userinput></screen>
- <note><para>我们需要上面的符号链接,以便在当前的 chroot
- 构建环境中运行测试套件。下面的安装过程将会覆盖它。</para></note>
- <screen><userinput remap="test">make check</userinput></screen>
- <!--para>You may see some test failures. The Glibc test suite is
- somewhat dependent on the host system. This is a list of the most common
- issues seen for some versions of LFS:</para-->
- <para>您可能看到一些失败结果。
- Glibc 的测试套件和宿主系统之间有某种依赖关系,以下是在一些版本的
- LFS 上最常见的问题:</para>
- <itemizedlist>
- <listitem>
- <para>已知 <emphasis>misc/check-installed-headers-c</emphasis>
- 由于内核头文件的变化而失败。</para>
- </listitem>
- <listitem>
- <para>已知 <emphasis>misc/tst-ttyname</emphasis>
- 在 LFS chroot 环境中会失败。</para>
- </listitem>
- <listitem>
- <para>已知 <emphasis>inet/tst-idna_name_classify</emphasis>
- 在 LFS chroot 环境中会失败。</para>
- </listitem>
- <listitem>
- <para>已知 <emphasis>posix/tst-getaddrinfo4</emphasis> 和
- <emphasis>posix/tst-getaddrinfo5</emphasis>
- 在某些硬件架构上会失败。</para>
- </listitem>
- <listitem>
- <para>已知 <emphasis>nss/tst-nss-files-hosts-multi</emphasis>
- 可能失败,原因尚未查明。</para>
- </listitem>
- <listitem>
- <para><emphasis>rt/tst-cputimer{1,2,3}</emphasis>
- 测试依赖于宿主系统的内核。已知内核版本 4.14.91–4.14.96,
- 4.19.13–4.19.18,以及 4.20.0–4.20.5 会导致它们失败。
- </para>
- </listitem>
- <listitem>
- <para>如果 CPU 不是较新的 Intel 或 AMD 处理器,
- 数学测试有时会失败。</para>
- </listitem>
- <!--
- <listitem>
- <para>The
- <emphasis>nptl/tst-thread-affinity-{pthread,pthread2,sched}</emphasis>
- tests may fail for reasons that have not been determined. </para>
- </listitem>
- <listitem>
- <para>Other tests known to fail on some architectures are
- malloc/tst-malloc-usable and nptl/tst-cleanupx4. </para>
- </listitem>
- -->
- </itemizedlist>
- <!--para>Though it is a harmless message, the install stage of Glibc will
- complain about the absence of <filename>/etc/ld.so.conf</filename>.
- Prevent this warning with:</para-->
- <para>在安装 Glibc 时,它会抱怨文件 <filename>/etc/ld.so.conf</filename>
- 不存在。尽管这是一条无害的消息,执行以下命令即可防止这个警告:
- </para>
- <screen><userinput remap="install">touch /etc/ld.so.conf</userinput></screen>
- <!--para>Fix the generated Makefile to skip an unneeded sanity check
- that fails in the LFS partial environment:
- </para-->
- <para>修正生成的 Makefile ,
- 跳过一个在 LFS 的不完整环境中会失败的完整性检查:</para>
- <screen><userinput remap="install">sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile</userinput></screen>
- <para>安装该软件包:</para>
- <screen><userinput remap="install">make install</userinput></screen>
- <!--para>Install the configuration file and runtime directory for
- <command>nscd</command>:</para-->
- <para>安装 <command>nscd</command> 的配置文件和运行时目录:</para>
- <screen><userinput remap="install">cp -v ../nscd/nscd.conf /etc/nscd.conf
- mkdir -pv /var/cache/nscd</userinput></screen>
- <para revision="systemd">安装
- <command>nscd</command> 的 systemd 支持文件:</para>
- <screen revision="systemd"><userinput remap="install">install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
- install -v -Dm644 ../nscd/nscd.service /lib/systemd/system/nscd.service</userinput></screen>
- <!--para>Next, install the locales that can make the system respond in a
- different language. None of the locales are required, but if some of them
- are missing, the test suites of future packages would skip important
- testcases.</para-->
- <para>下面,安装一些 locale ,它们可以使得系统用不同语言响应用户请求。
- 这些 locale 都不是必须的,但是如果缺少了它们中的某些,
- 在将来运行软件包的测试套件时,可能跳过重要的测试。</para>
- <!--para>Individual locales can be installed using the
- <command>localedef</command> program. E.g., the first
- <command>localedef</command> command below combines the
- <filename>/usr/share/i18n/locales/cs_CZ</filename>
- charset-independent locale definition with the
- <filename>/usr/share/i18n/charmaps/UTF-8.gz</filename>
- charmap definition and appends the result to the
- <filename>/usr/lib/locale/locale-archive</filename> file.
- The following instructions will install the minimum set of
- locales necessary for the optimal coverage of tests:</para-->
- <para>可以用 <command>localedef</command> 程序安装单独的 locale 。
- 例如,下面的第一个 <command>localedef</command> 命令将
- <filename>/usr/share/i18n/locales/cs_CZ</filename>
- 中的字符集无关 locale 定义和
- <filename>/usr/share/i18n/charmaps/UTF-8.gz</filename>
- 中的字符映射定义组合起来,并附加到
- <filename>/usr/lib/locale/locale-archive</filename> 文件。
- 以下命令将会安装能够覆盖测试所需的最小 locale 集合:</para>
- <screen role="nodump"><userinput remap="locale-test">mkdir -pv /usr/lib/locale
- localedef -i POSIX -f UTF-8 C.UTF-8 2> /dev/null || true
- localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
- localedef -i de_DE -f ISO-8859-1 de_DE
- localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
- localedef -i de_DE -f UTF-8 de_DE.UTF-8
- localedef -i el_GR -f ISO-8859-7 el_GR
- localedef -i en_GB -f UTF-8 en_GB.UTF-8
- localedef -i en_HK -f ISO-8859-1 en_HK
- localedef -i en_PH -f ISO-8859-1 en_PH
- localedef -i en_US -f ISO-8859-1 en_US
- localedef -i en_US -f UTF-8 en_US.UTF-8
- localedef -i es_MX -f ISO-8859-1 es_MX
- localedef -i fa_IR -f UTF-8 fa_IR
- localedef -i fr_FR -f ISO-8859-1 fr_FR
- localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
- localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
- localedef -i it_IT -f ISO-8859-1 it_IT
- localedef -i it_IT -f UTF-8 it_IT.UTF-8
- localedef -i ja_JP -f EUC-JP ja_JP
- localedef -i ja_JP -f SHIFT_JIS ja_JP.SIJS 2> /dev/null || true
- localedef -i ja_JP -f UTF-8 ja_JP.UTF-8
- localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
- localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
- localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
- localedef -i zh_CN -f GB18030 zh_CN.GB18030
- localedef -i zh_HK -f BIG5-HKSCS zh_HK.BIG5-HKSCS</userinput></screen>
- <!--para>In addition, install the locale for your own country, language and
- character set.</para-->
- <para>另外,安装适合您自己国家、语言和字符集的 locale 。</para>
- <note><title>译注</title><para>
- 建议中文用户安装 zh_CN.UTF-8 作为日常使用的 locale。GB18030
- 是为了后向兼容古老的 GB2312 而设计的编码,
- 在现代 Linux 系统和互联网使用时会引起一些奇怪的问题。
- 中华人民共和国国家标准化管理委员会的官方网站已经切换到 UTF-8。
- </para></note>
- <!--para>Alternatively, install all locales listed in the
- <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
- (it includes every locale listed above and many more) at once with the
- following time-consuming command:</para-->
- <para>或者,也可以一次安装
- <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename>
- 中列出的所有 locale (包括上面列出的所有 locale,以及其他很多)。
- 执行下面这个需要很长时间的命令:</para>
- <screen><userinput remap="locale-full">make localedata/install-locales</userinput></screen>
- <!--para>Then use the <command>localedef</command> command to create and
- install locales not listed in the
- <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
- in the unlikely case you need them.</para-->
- <para>如果需要,再使用 <command>localedef</command> 命令创建和安装
- <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename>
- 中没有列出的 locale ,当然您不太可能需要它们。</para>
- <note><para>目前 glibc 在解析国际化域名时使用 libidn2,
- 形成了一个运行时依赖关系。如果需要使用解析国际化域名的功能,参阅
- <ulink url="&blfs-book;general/libidn2.html">BLFS libidn2 页面</ulink>
- 安装 libidn2。
- </para></note>
- </sect2>
- <sect2 id="conf-glibc" role="configuration">
- <title>配置 Glibc</title>
- <indexterm zone="conf-glibc">
- <primary sortas="e-/etc/nsswitch.conf">/etc/nsswitch.conf</primary>
- </indexterm>
- <indexterm zone="conf-glibc">
- <primary sortas="e-/etc/localtime">/etc/localtime</primary>
- </indexterm>
- <sect3>
- <title>添加 nsswitch.conf</title>
- <!--para>The <filename>/etc/nsswitch.conf</filename> file needs to be created
- because the Glibc defaults do not work well in a networked environment.
- </para-->
- <para>由于 Glibc 的默认值在网络环境下不能很好地工作,
- 需要创建配置文件 <filename>/etc/nsswitch.conf</filename>。</para>
- <!--para>Create a new file <filename>/etc/nsswitch.conf</filename> by running the
- following:</para-->
- <para>执行以下命令创建新的 <filename>/etc/nsswitch.conf</filename>:
- </para>
- <screen><userinput>cat > /etc/nsswitch.conf << "EOF"
- <literal># Begin /etc/nsswitch.conf
- passwd: files
- group: files
- shadow: files
- hosts: files dns
- networks: files
- protocols: files
- services: files
- ethers: files
- rpc: files
- # End /etc/nsswitch.conf</literal>
- EOF</userinput></screen>
- </sect3>
- <sect3 id="conf-zone">
- <title>添加时区数据</title>
- <!--para>Install and set up the time zone data with the following:</para-->
- <para>输入以下命令,安装并设置时区数据:</para>
- <screen><userinput>tar -xf ../../tzdata&tzdata-version;.tar.gz
- ZONEINFO=/usr/share/zoneinfo
- mkdir -pv $ZONEINFO/{posix,right}
- for tz in etcetera southamerica northamerica europe africa antarctica \
- asia australasia backward pacificnew systemv; do
- zic -L /dev/null -d $ZONEINFO ${tz}
- zic -L /dev/null -d $ZONEINFO/posix ${tz}
- zic -L leapseconds -d $ZONEINFO/right ${tz}
- done
- cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
- zic -d $ZONEINFO -p America/New_York
- unset ZONEINFO</userinput></screen>
- <variablelist>
- <title>zic 命令的含义:</title>
- <varlistentry>
- <term><parameter>zic -L /dev/null ...</parameter></term>
- <listitem>
- <!--para>This creates posix time zones, without any leap seconds. It is
- conventional to put these in both
- <filename class="directory">zoneinfo</filename> and
- <filename class="directory">zoneinfo/posix</filename>. It is
- necessary to put the POSIX time zones in
- <filename class="directory">zoneinfo</filename>, otherwise various
- test-suites will report errors. On an embedded system, where space is
- tight and you do not intend to ever update the time zones, you could save
- 1.9MB by not using the <filename class="directory">posix</filename>
- directory, but some applications or test-suites might produce some
- failures.</para-->
- <para>该命令创建没有闰秒的 POSIX 时区。一般的惯例是将它们安装在
- <filename class="directory">zoneinfo</filename> 和
- <filename class="directory">zoneinfo/posix</filename>
- 两个目录中。前者是必须的,否则若干测试套件会报告错误。
- 在嵌入式系统上,如果存储空间十分紧张,
- 而且您永远不会更新时区信息,您可以不使用
- <filename class="directory">posix</filename> 目录,
- 以节约 1.9 MB,但个别程序或测试套件可能会失败。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>zic -L leapseconds ...</parameter></term>
- <listitem>
- <!--para>This creates right time zones, including leap seconds. On an
- embedded system, where space is tight and you do not intend to
- ever update the time zones, or care about the correct time, you could
- save 1.9MB by omitting the <filename class="directory">right</filename>
- directory.</para-->
- <para>该命令创建正确的,包含闰秒的时区。在嵌入式系统上,
- 如果存储空间十分紧张,而且您永远不会更新时区信息,
- 也不关心系统时间是否正确,您可以跳过
- <filename class="directory">right</filename> 目录,
- 以节约 1.9 MB。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>zic ... -p ...</parameter></term>
- <listitem>
- <!--para>This creates the <filename>posixrules</filename> file. We use
- New York because POSIX requires the daylight savings time rules
- to be in accordance with US rules.</para-->
- <para>该命令创建 <filename>posixrule</filename> 文件。
- 我们使用纽约时区,因为 POSIX 要求与美国一致的夏令时规则。
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- <!--para>One way to determine the local time zone is to run the following
- script:</para-->
- <para>一种确定本地时区的方法是运行脚本:</para>
- <screen role="nodump"><userinput>tzselect</userinput></screen>
- <!--para>After answering a few questions about the location, the script will
- output the name of the time zone (e.g.,
- <emphasis>America/Edmonton</emphasis>). There are also some other possible
- time zones listed in <filename
- class='directory'>/usr/share/zoneinfo</filename> such as
- <emphasis>Canada/Eastern</emphasis> or <emphasis>EST5EDT</emphasis> that
- are not identified by the script but can be used.</para>
- <para>Then create the <filename>/etc/localtime</filename> file by
- running:</para-->
- <para>在回答关于当前位置的若干问题后,脚本会输出对应时区的名字
- (例如<emphasis>America/Edmonton</emphasis>)。
- 在 <filename class="directory">/usr/share/zoneinfo</filename>
- 中还有一些该脚本不能识别,但可以使用的时区,如
- <emphasis>Canada/Eastern</emphasis> 或者
- <emphasis>EST5EDT</emphasis>。</para>
- <para>确定时区后,执行以下命令,创建
- <filename>/etc/localtime</filename>:</para>
- <screen revision="sysv"><userinput>cp -v /usr/share/zoneinfo/<replaceable><xxx></replaceable> /etc/localtime</userinput></screen>
- <screen revision="systemd"><userinput>ln -sfv /usr/share/zoneinfo/<replaceable><xxx></replaceable> /etc/localtime</userinput></screen>
- <!--para>Replace <replaceable><xxx></replaceable> with the name of the
- time zone selected (e.g., Canada/Eastern).</para-->
- <para>将 <replaceable><xxx></replaceable> 替换成选定时区的名称
- (例如 Canada/Eastern)。</para>
- </sect3>
- <sect3 id="conf-ld" role="configuration">
- <title>配置动态加载器</title>
- <indexterm zone="conf-ld">
- <primary sortas="e-/etc/ld.so.conf">/etc/ld.so.conf</primary>
- </indexterm>
- <!--para>By default, the dynamic loader (<filename
- class="libraryfile">/lib/ld-linux.so.2</filename>) searches through
- <filename class="directory">/lib</filename> and <filename
- class="directory">/usr/lib</filename> for dynamic libraries that are
- needed by programs as they are run. However, if there are libraries in
- directories other than <filename class="directory">/lib</filename> and
- <filename class="directory">/usr/lib</filename>, these need to be added
- to the <filename>/etc/ld.so.conf</filename> file in order for the
- dynamic loader to find them. Two directories that are commonly known
- to contain additional libraries are <filename
- class="directory">/usr/local/lib</filename> and <filename
- class="directory">/opt/lib</filename>, so add those directories to the
- dynamic loader's search path.</para-->
- <para>默认情况下,动态加载器
- (<filename class="libraryfile">/lib/ld-linux.so.2</filename>)
- 在 <filename class="directory">/lib</filename> 和
- <filename class="directory">/usr/lib</filename>
- 中搜索程序运行时需要的动态库。然而,如果在其他目录中有动态库,
- 为了使动态加载器能够找到它们,需要把这些目录添加到文件
- <filename>/etc/ld.so.conf</filename> 中。
- 有两个目录 <filename class="directory">/usr/local/lib</filename>
- 和 <filename class="directory">/opt/lib</filename>
- 经常包含附加的共享库,所以现在将它们添加到动态加载器的搜索目录中。
- </para>
- <!--para>Create a new file <filename>/etc/ld.so.conf</filename> by running the
- following:</para-->
- <para>运行以下命令,创建一个新的 <filename>/etc/ld.so.conf</filename>:
- </para>
- <screen><userinput>cat > /etc/ld.so.conf << "EOF"
- <literal># Begin /etc/ld.so.conf
- /usr/local/lib
- /opt/lib
- </literal>
- EOF</userinput></screen>
- <!--para>If desired, the dynamic loader can also search a directory and
- include the contents of files found there. Generally the files in
- this include directory are one line specifying the desired library path.
- To add this capability run the following commands:</para-->
- <para>如果希望的话,动态加载器也可以搜索一个目录,并将其中的文件包含在
- <filename>ld.so.conf</filename> 中。
- 通常包含文件目录中的文件只有一行,指定一个期望的库文件目录。
- 如果需要这项功能,执行以下命令:</para>
- <screen role="nodump"><userinput>cat >> /etc/ld.so.conf << "EOF"
- <literal># Add an include directory
- include /etc/ld.so.conf.d/*.conf
- </literal>
- EOF
- mkdir -pv /etc/ld.so.conf.d</userinput></screen>
- </sect3>
- </sect2>
- <sect2 id="contents-glibc" role="content">
- <title>Glibc 的内容</title>
- <segmentedlist>
- <segtitle>安装的程序</segtitle>
- <segtitle>安装的库</segtitle>
- <segtitle>安装的目录</segtitle>
- <seglistitem>
- <seg>catchsegv, gencat, getconf, getent, iconv, iconvconfig, ldconfig,
- ldd, lddlibc4, locale, localedef, makedb, mtrace, nscd,
- pcprofiledump, pldd, sln, sotruss, sprof, tzselect, xtrace,
- zdump, 以及 zic</seg>
- <seg>ld-&glibc-version;.so, libBrokenLocale.{a,so}, libSegFault.so, libanl.{a,so},
- libc.{a,so}, libc_nonshared.a,
- libcrypt.{a,so}, libdl.{a,so}, libg.a, libm.{a,so},
- libmcheck.a, libmemusage.so, libmvec.{a,so}, libnsl.{a,so},
- libnss_compat.so, libnss_dns.so, libnss_files.so, libnss_hesiod.so,
- libpcprofile.so, libpthread.{a,so},
- libpthread_nonshared.a, libresolv.{a,so}, librt.{a,so},
- libthread_db.so, 以及 libutil.{a,so}</seg>
- <seg>/usr/include/arpa, /usr/include/bits, /usr/include/gnu,
- /usr/include/net, /usr/include/netash, /usr/include/netatalk,
- /usr/include/netax25, /usr/include/neteconet, /usr/include/netinet,
- /usr/include/netipx, /usr/include/netiucv, /usr/include/netpacket,
- /usr/include/netrom, /usr/include/netrose, /usr/include/nfs,
- /usr/include/protocols, /usr/include/rpc,
- /usr/include/sys, /usr/lib/audit, /usr/lib/gconv, /usr/lib/locale,
- /usr/libexec/getconf, /usr/share/i18n, /usr/share/zoneinfo,
- /var/cache/nscd, 以及 /var/lib/nss_db</seg>
- </seglistitem>
- </segmentedlist>
- <variablelist>
- <bridgehead renderas="sect3">简要描述</bridgehead>
- <?dbfo list-presentation="list"?>
- <?dbhtml list-presentation="table"?>
- <varlistentry id="catchsegv">
- <term><command>catchsegv</command></term>
- <listitem>
- <para>在程序因为段错误而终止时创建栈跟踪</para>
- <indexterm zone="ch-system-glibc catchsegv">
- <primary sortas="b-catchsegv">catchsegv</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="gencat">
- <term><command>gencat</command></term>
- <listitem>
- <para>生成消息目录</para>
- <indexterm zone="ch-system-glibc gencat">
- <primary sortas="b-gencat">gencat</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="getconf">
- <term><command>getconf</command></term>
- <listitem>
- <para>显示文件系统指定的系统配置变量值</para>
- <indexterm zone="ch-system-glibc getconf">
- <primary sortas="b-getconf">getconf</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="getent">
- <term><command>getent</command></term>
- <listitem>
- <para>从管理数据库取得条目</para>
- <indexterm zone="ch-system-glibc getent">
- <primary sortas="b-getent">getent</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="iconv">
- <term><command>iconv</command></term>
- <listitem>
- <para>转换给定文件的编码</para>
- <indexterm zone="ch-system-glibc iconv">
- <primary sortas="b-iconv">iconv</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="iconvconfig">
- <term><command>iconvconfig</command></term>
- <listitem>
- <para>创建快速装入 <command>iconv</command> 模块配置文件</para>
- <indexterm zone="ch-system-glibc iconvconfig">
- <primary sortas="b-iconvconfig">iconvconfig</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="ldconfig">
- <term><command>ldconfig</command></term>
- <listitem>
- <para>设置运行时动态链接</para>
- <indexterm zone="ch-system-glibc ldconfig">
- <primary sortas="b-ldconfig">ldconfig</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="ldd">
- <term><command>ldd</command></term>
- <listitem>
- <para>报告给定程序或共享库依赖于哪些共享库</para>
- <indexterm zone="ch-system-glibc ldd">
- <primary sortas="b-ldd">ldd</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="lddlibc4">
- <term><command>lddlibc4</command></term>
- <listitem>
- <para>辅助 <command>ldd</command> 处理对象文件</para>
- <indexterm zone="ch-system-glibc lddlibc4">
- <primary sortas="b-lddlibc4">lddlibc4</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="locale">
- <term><command>locale</command></term>
- <listitem>
- <para>给出当前区域的一些信息</para>
- <indexterm zone="ch-system-glibc locale">
- <primary sortas="b-locale">locale</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="localedef">
- <term><command>localedef</command></term>
- <listitem>
- <para>编译 locale 规范</para>
- <indexterm zone="ch-system-glibc localedef">
- <primary sortas="b-localedef">localedef</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="makedb">
- <term><command>makedb</command></term>
- <listitem>
- <para>从文本输入创建简单的数据库</para>
- <indexterm zone="ch-system-glibc makedb">
- <primary sortas="b-makedb">makedb</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="mtrace">
- <term><command>mtrace</command></term>
- <listitem>
- <para>读取并解析内存跟踪文件,以人类可读的形式输出内存跟踪信息
- </para>
- <indexterm zone="ch-system-glibc mtrace">
- <primary sortas="b-mtrace">mtrace</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="nscd">
- <term><command>nscd</command></term>
- <listitem>
- <para>一个缓存最常见命名服务请求的守护进程</para>
- <indexterm zone="ch-system-glibc nscd">
- <primary sortas="b-nscd">nscd</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="pcprofiledump">
- <term><command>pcprofiledump</command></term>
- <listitem>
- <para>显示基于程序计数器的性能剖析数据</para>
- <indexterm zone="ch-system-glibc pcprofiledump">
- <primary sortas="b-pcprofiledump">pcprofiledump</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="pldd">
- <term><command>pldd</command></term>
- <listitem>
- <para>列出正在运行的进程使用的共享库</para>
- <indexterm zone="ch-system-glibc pldd">
- <primary sortas="b-pldd">pldd</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="sln">
- <term><command>sln</command></term>
- <listitem>
- <para>静态链接的 <command>ln</command> 程序</para>
- <indexterm zone="ch-system-glibc sln">
- <primary sortas="b-sln">sln</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="sotruss">
- <term><command>sotruss</command></term>
- <listitem>
- <para>跟踪特定命令对共享库中子程序的调用</para>
- <indexterm zone="ch-system-glibc sotruss">
- <primary sortas="b-sotruss">sotruss</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="sprof">
- <term><command>sprof</command></term>
- <listitem>
- <para>读取并显示共享库性能剖析数据</para>
- <indexterm zone="ch-system-glibc sprof">
- <primary sortas="b-sprof">sprof</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="tzselect">
- <term><command>tzselect</command></term>
- <listitem>
- <para>询问用户系统所在的位置并报告对应的时区</para>
- <indexterm zone="ch-system-glibc tzselect">
- <primary sortas="b-tzselect">tzselect</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="xtrace">
- <term><command>xtrace</command></term>
- <listitem>
- <para>显示正在执行的函数以跟踪程序执行</para>
- <indexterm zone="ch-system-glibc xtrace">
- <primary sortas="b-xtrace">xtrace</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="zdump">
- <term><command>zdump</command></term>
- <listitem>
- <para>输出当前时间在多个时区中的表示</para>
- <indexterm zone="ch-system-glibc zdump">
- <primary sortas="b-zdump">zdump</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="zic">
- <term><command>zic</command></term>
- <listitem>
- <para>时区编译器</para>
- <indexterm zone="ch-system-glibc zic">
- <primary sortas="b-zic">zic</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="ld.so">
- <term><filename class="libraryfile">ld-&glibc-version;.so</filename></term>
- <listitem>
- <para>动态链接器/加载器</para>
- <indexterm zone="ch-system-glibc ld.so">
- <primary sortas="c-ld.so">ld-&glibc-version;.so</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libBrokenLocale">
- <term><filename class="libraryfile">libBrokenLocale</filename></term>
- <listitem>
- <para>被 Glibc 内部用作使某些不正确的程序(例如某些 Motif 程序)
- 正常运行的粗糙手段,参阅
- <filename>glibc-&glibc-version;/locale/broken_cur_max.c</filename>
- 中的注释了解更多信息</para>
- <indexterm zone="ch-system-glibc libBrokenLocale">
- <primary sortas="c-libBrokenLocale">libBrokenLocale</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libSegFault">
- <term><filename class="libraryfile">libSegFault</filename></term>
- <listitem>
- <para><command>catchsegv</command> 使用的段错误信号处理程序
- </para>
- <indexterm zone="ch-system-glibc libSegFault">
- <primary sortas="c-libSegFault">libSegFault</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libanl">
- <term><filename class="libraryfile">libanl</filename></term>
- <listitem>
- <para>异步的命名查找库</para>
- <indexterm zone="ch-system-glibc libanl">
- <primary sortas="c-libanl">libanl</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libc">
- <term><filename class="libraryfile">libc</filename></term>
- <listitem>
- <para>主要的 C 运行库</para>
- <indexterm zone="ch-system-glibc libc">
- <primary sortas="c-libc">libc</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libcrypt">
- <term><filename class="libraryfile">libcrypt</filename></term>
- <listitem>
- <para>密码学库</para>
- <indexterm zone="ch-system-glibc libcrypt">
- <primary sortas="c-libcrypt">libcrypt</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libdl">
- <term><filename class="libraryfile">libdl</filename></term>
- <listitem>
- <para>动态链接接口库</para>
- <indexterm zone="ch-system-glibc libdl">
- <primary sortas="c-libdl">libdl</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libg">
- <term><filename class="libraryfile">libg</filename></term>
- <listitem>
- <para>没有功能的空库,曾经是 <command>g++</command> 的运行库。
- </para>
- <indexterm zone="ch-system-glibc libg">
- <primary sortas="c-libg">libg</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libm">
- <term><filename class="libraryfile">libm</filename></term>
- <listitem>
- <para>数学库</para>
- <indexterm zone="ch-system-glibc libm">
- <primary sortas="c-libm">libm</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libmcheck">
- <term><filename class="libraryfile">libmcheck</filename></term>
- <listitem>
- <para>链接到该库时启用内存分配检查</para>
- <indexterm zone="ch-system-glibc libmcheck">
- <primary sortas="c-libmcheck">libmcheck</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libmemusage">
- <term><filename class="libraryfile">libmemusage</filename></term>
- <listitem>
- <para>被 <command>memusage</command> 用于收集程序内存使用信息
- </para>
- <indexterm zone="ch-system-glibc libmemusage">
- <primary sortas="c-libmemusage">libmemusage</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libnsl">
- <term><filename class="libraryfile">libnsl</filename></term>
- <listitem>
- <para>网络服务库</para>
- <indexterm zone="ch-system-glibc libnsl">
- <primary sortas="c-libnsl">libnsl</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libnss">
- <term><filename class="libraryfile">libnss</filename></term>
- <listitem>
- <para>命名服务开关库,包含用于解析域名、用户名、组名、代号、
- 服务、协议等的函数。</para>
- <indexterm zone="ch-system-glibc libnss">
- <primary sortas="c-libnss">libnss</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libpcprofile">
- <term><filename class="libraryfile">libpcprofile</filename></term>
- <listitem>
- <para>可以预加载它,以对程序进行基于程序计数器的性能剖析</para>
- <indexterm zone="ch-system-glibc libpcprofile">
- <primary sortas="c-libpcprofile">libpcprofile</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libpthread">
- <term><filename class="libraryfile">libpthread</filename></term>
- <listitem>
- <para>POSIX 线程库</para>
- <indexterm zone="ch-system-glibc libpthread">
- <primary sortas="c-libpthread">libpthread</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libresolv">
- <term><filename class="libraryfile">libresolv</filename></term>
- <listitem>
- <para>包含用于创建、发送和解析因特网域名服务数据包的函数。</para>
- <indexterm zone="ch-system-glibc libresolv">
- <primary sortas="c-libresolv">libresolv</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="librt">
- <term><filename class="libraryfile">librt</filename></term>
- <listitem>
- <para>包含 POSIX.1b 实时扩展要求的多数接口</para>
- <indexterm zone="ch-system-glibc librt">
- <primary sortas="c-librt">librt</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libthread_db">
- <term><filename class="libraryfile">libthread_db</filename></term>
- <listitem>
- <para>包含用于构建多线程程序调试的函数器</para>
- <indexterm zone="ch-system-glibc libthread_db">
- <primary sortas="c-libthread_db">libthread_db</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- <varlistentry id="libutil">
- <term><filename class="libraryfile">libutil</filename></term>
- <listitem>
- <para>包含许多 Unix 工具使用的 <quote>标准</quote> 函数</para>
- <indexterm zone="ch-system-glibc libutil">
- <primary sortas="c-libutil">libutil</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- </variablelist>
- </sect2>
- </sect1>
|