📄 glibc.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content= "application/xhtml+xml; charset=iso-8859-1" /> <title> 10.6. Glibc-2.4 </title> <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /> <link rel="stylesheet" href="../stylesheets/lfs-print.css" type= "text/css" media="print" /> </head> <body id="lfs" class="CLFS-SVN-20060417-MIPS"> <div class="navheader"> <div class="headertitles"> <h4> Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-MIPS </h4> <h3> Chapter 10. Installing Basic System Software </h3> </div> <ul class="headerlinks"> <li class="prev"> <a accesskey="p" href="linux-libc-headers.html" title= "Linux-Libc-Headers-2.6.12.0">Prev</a> <p> Linux-Libc-Headers-2.6.12.0 </p> </li> <li class="next"> <a accesskey="n" href="adjusting.html" title= "Adjusting the Toolchain">Next</a> <p> Adjusting the Toolchain </p> </li> <li class="up"> <a accesskey="u" href="chapter.html" title= "Chapter 10. Installing Basic System Software">Up</a>. </li> <li class="home"> <a accesskey="h" href="../index.html" title= "Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-MIPS"> Home</a> </li> </ul> </div> <div class="wrap" lang="en" xml:lang="en"> <div class="titlepage"> <h1 class="sect1"> 10.6. Glibc-2.4 </h1> </div> <div class="package" lang="en" xml:lang="en"> <p> 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. </p> <div class="segmentedlist"> <div class="seglistitem"> <div class="seg"> <strong><span class="segtitle">Installation depends on:</span></strong> <span class="seg">Bash, Binutils, Coreutils, Diffutils, Gawk, GCC, Gettext, Grep, Make, Patch, Perl, Sed, and Texinfo</span> </div> </div> </div> </div> <div class="installation" lang="en" xml:lang="en"> <div class="titlepage"> <h2 class="sect2"> 10.6.1. Installation of Glibc </h2> </div> <div class="note"> <div class="admonhead"> <img alt="[Note]" src="../images/note.png" /> <h3 class="admontitle"> Note </h3> </div> <div class="admonbody"> <p> Some packages outside of LFS suggest installing GNU libiconv in order to translate data from one encoding to another. The project's home page (<a href= "http://www.gnu.org/software/libiconv/"><i>http://www.gnu.org/software/libiconv/</i></a>) says “<span class="quote">This library provides an <tt class="function">iconv()</tt> implementation, for use on systems which don't have one, or whose implementation cannot convert from/to Unicode.</span>” Glibc provides an <tt class="function">iconv()</tt> implementation and can convert from/to Unicode, therefore libiconv is not required on an LFS system. </p> </div> </div> <p> The Glibc build system is self-contained and will install perfectly, even though the compiler specs file and linker are still pointing at <tt class="filename">/tools</tt>. 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. </p> <p> MIPS is no longer supported in the main glibc tree, so we have to extract the glibc-ports-2.4 into our glibc-2.4 directory. Then we move ports to the location expected by our build and patches. </p> <pre class="userinput"><kbd class="command">tar -jxvf glibc-ports-2.4.tar.bz2mv -v glibc-ports-2.4 ports</kbd></pre> <p> The following patch fixes a link issues when building MIPS glibc: </p> <pre class="userinput"><kbd class="command">patch -Np1 -i ../glibc-2.4-mips_fixes-1.patch</kbd></pre> <p> The following patch removes the potential of localdef segfaulting: </p> <pre class="userinput"><kbd class="command">patch -Np1 -i ../glibc-2.4-localedef_segfault-1.patch</kbd></pre> <p> The following sed fixes a build issue with Glibc. This will prevent nscd from trying to link to libraries that don't exist: </p> <pre class="userinput"><kbd class="command">cp nscd/Makefile{,.orig}sed -e "/nscd_stat.o: sysincludes = # nothing/d" nscd/Makefile.orig > \nscd/Makefile</kbd></pre> <p> The Glibc documentation recommends building Glibc outside of the source directory in a dedicated build directory: </p> <pre class="userinput"><kbd class="command">mkdir -v ../glibc-buildcd ../glibc-build</kbd></pre> <p> Prepare Glibc for compilation: </p> <pre class="userinput"><kbd class="command">../glibc-2.4/configure --prefix=/usr \ --disable-profile --enable-add-ons --enable-kernel=2.6.0 \ --libexecdir=/usr/lib/glibc</kbd></pre> <div class="variablelist"> <p class="title"> <b>The meaning of the new configure option:</b> </p> <dl> <dt> <span class="term"><em class= "parameter"><tt>--libexecdir=/usr/lib/glibc</tt></em></span> </dt> <dd> <p> This changes the location of the <span><strong class= "command">pt_chown</strong></span> program from its default of <tt class="filename">/usr/libexec</tt> to <tt class= "filename">/usr/lib/glibc</tt>. </p> </dd> </dl> </div> <p> Compile the package: </p> <pre class="userinput"><kbd class="command">make</kbd></pre> <div class="important"> <div class="admonhead"> <img alt="[Important]" src="../images/important.png" /> <h3 class="admontitle"> Important </h3> </div> <div class="admonbody"> <p> In this section, the test suite for Glibc is considered critical. Do not skip it under any circumstance. </p> </div> </div> <p> Test the results: </p> <pre class="userinput"><kbd class="command">make check</kbd></pre> <p> The Glibc test suite is highly dependent on certain functions of the host system, in particular the kernel. In general, the Glibc test suite is always expected to pass. However, in certain circumstances, some failures are unavoidable. This is a list of the most common issues: </p> <div class="itemizedlist"> <ul> <li> <p> The <span class="emphasis"><em>math</em></span> tests sometimes fail. Certain optimization settings are known to be a factor here. </p> </li> <li> <p> The <span class="emphasis"><em>gettext</em></span> test sometimes fails due to host system issues. The exact reasons are not yet clear. </p> </li> <li> <p> If you have mounted the LFS partition with the <em class= "parameter"><tt>noatime</tt></em> option, the <span class= "emphasis"><em>atime</em></span> test will fail. As mentioned in <a href="../partitioning/mounting.html" title= "2.4. Mounting the New Partition">Section 2.4, “Mounting the New Partition”</a>, do not use the <em class="parameter"><tt>noatime</tt></em> option while building LFS. </p> </li> <li> <p> When running on older and slower hardware, some tests can fail because of test timeouts being exceeded. </p> </li> </ul> </div> <p> Though it is a harmless message, the install stage of Glibc will complain about the absence of <tt class= "filename">/etc/ld.so.conf</tt>. Prevent this warning with: </p> <pre class="userinput"><kbd class="command">touch /etc/ld.so.conf</kbd></pre> <p> Install the package: </p> <pre class="userinput"><kbd class="command">make install</kbd></pre> </div> <div class="configuration" lang="en" xml:lang="en"> <div class="titlepage"> <a id="i18n-glibc" name="i18n-glibc"></a> <h2 class="sect2"> 10.6.2. Internationalization </h2> </div> <p> The locales that can make the system respond in a different language were not installed by the above command. Install them with: </p> <pre class="userinput"><kbd class="command">make localedata/install-locales</kbd></pre> <p> To save time, an alternative to running the previous command (which generates and installs every locale listed in the glibc-2.4/localedata/SUPPORTED file) is to install only those locales that are wanted and needed. This can be achieved by using the <span><strong class="command">localedef</strong></span> command. Information on this command is located in the <tt class= "filename">INSTALL</tt> file in the Glibc source. However, there are a number of locales that are essential in order for the tests of future packages to pass, in particular, the <span class= "emphasis"><em>libstdc++</em></span> tests from GCC. The following instructions, instead of the <em class= "parameter"><tt>install-locales</tt></em> target used above, will install the minimum set of locales necessary for the tests to run successfully: </p> <pre class="userinput"><kbd class="command">mkdir -pv /usr/lib/localelocaledef -i de_DE -f ISO-8859-1 de_DElocaledef -i de_DE@euro -f ISO-8859-15 de_DE@eurolocaledef -i en_HK -f ISO-8859-1 en_HKlocaledef -i en_PH -f ISO-8859-1 en_PHlocaledef -i en_US -f ISO-8859-1 en_USlocaledef -i es_MX -f ISO-8859-1 es_MXlocaledef -i fa_IR -f UTF-8 fa_IRlocaledef -i fr_FR -f ISO-8859-1 fr_FRlocaledef -i fr_FR@euro -f ISO-8859-15 fr_FR@eurolocaledef -i it_IT -f ISO-8859-1 it_ITlocaledef -i ja_JP -f EUC-JP ja_JP</kbd></pre> <p> Some locales installed by the <span><strong class="command">make localedata/install-locales</strong></span> command above are not properly supported by some applications that are in the LFS and BLFS books. Because of the various problems that arise due to application programmers making assumptions that break in such locales, LFS should not be used in locales that utilize multibyte character sets (including UTF-8) or right-to-left writing order. Numerous unofficial and unstable patches are required to fix these problems, and it has been decided by the LFS developers not to support such complex locales at this time. This applies to the ja_JP and fa_IR locales as well—they have been installed only for GCC and Gettext tests to pass, and the <span><strong class= "command">watch</strong></span> program (part of the Procps package) does not work properly in them. Various attempts to circumvent these restrictions are documented in internationalization-related hints. </p> </div> <div class="configuration" lang="en" xml:lang="en"> <div class="titlepage"> <a id="conf-glibc" name="conf-glibc"></a> <h2 class="sect2"> 10.6.3. Configuring Glibc </h2> </div> <p> The <tt class="filename">/etc/nsswitch.conf</tt> file needs to be created because, although Glibc provides defaults when this file is missing or corrupt, the Glibc defaults do not work well in a networked environment. The time zone also needs to be configured. </p> <p> Create a new file <tt class="filename">/etc/nsswitch.conf</tt> by running the following: </p> <pre class="userinput"><kbd class="command">cat > /etc/nsswitch.conf << "EOF"<tt class="literal"># Begin /etc/nsswitch.confpasswd: filesgroup: filesshadow: fileshosts: files dnsnetworks: filesprotocols: filesservices: filesethers: filesrpc: files# End /etc/nsswitch.conf</tt>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -