5.11. EGLIBC-2.10.1

The EGLIBC 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.

5.11.1. Installation of EGLIBC

[Note]

Note

Some packages outside of CLFS suggest installing GNU libiconv in order to translate data from one encoding to another. The project's home page (http://www.gnu.org/software/libiconv/) says “This library provides an iconv() implementation, for use on systems which don't have one, or whose implementation cannot convert from/to Unicode.” EGLIBC provides an iconv() implementation and can convert from/to Unicode, therefore libiconv is not required on an CLFS system.

This architecture is no longer supported in the main eglibc tree, so we have to extract the eglibc-ports-2.10.1 package into our eglibc-2.10.1 directory:

tar -jxvf ../eglibc-ports-2.10.1-20090726-r8632.tar.bz2

EGLIBC has various issues addressed by the following patch:

patch -Np1 -i ../eglibc-2.10.1-fixes-2.patch

Disable linking to libgcc_eh:

cp -v Makeconfig{,.orig}
sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig

The EGLIBC documentation recommends building EGLIBC outside of the source directory in a dedicated build directory:

mkdir -v ../eglibc-build
cd ../eglibc-build

The following lines need to be added to config.cache for EGLIBC to support NPTL:

cat > config.cache << EOF
libc_cv_forced_unwind=yes
libc_cv_c_cleanup=yes
libc_cv_gnu89_inline=yes
EOF

The following line needs to be added to configparms to adjust installation paths:

cat > configparms << EOF
install_root=${CLFS}
EOF

Prepare EGLIBC for compilation:

BUILD_CC="gcc" CC="${CLFS_TARGET}-gcc" \
    AR="${CLFS_TARGET}-ar" RANLIB="${CLFS_TARGET}-ranlib" \
    ../eglibc-2.10.1/configure --prefix=/usr \
    --libexecdir=/usr/lib/eglibc --host=${CLFS_TARGET} --build=${CLFS_HOST} \
    --disable-profile --enable-add-ons --with-tls --enable-kernel=2.6.0 \
    --with-__thread --with-binutils=${CLFS}/cross-tools/bin \
    --with-headers=${CLFS}/usr/include --cache-file=config.cache

The meaning of the new configure options:

BUILD_CC="gcc"

This tells EGLIBC to use the compiler on the host system. This is used to create the tools EGLIBC uses during its build.

CC="${CLFS_TARGET}-gcc"

This forces EGLIBC to use the GCC compiler that we made for our target architecture.

AR="${CLFS_TARGET}-ar"

This forces EGLIBC to use the ar utility we made for our target architecture.

RANLIB="${CLFS_TARGET}-ranlib"

This forces EGLIBC to use the ranlib utility we made for our target architecture.

--disable-profile

This builds the libraries without profiling information. Omit this option if profiling on the temporary tools is necessary.

--enable-add-ons

This tells EGLIBC to utilize all add-ons that are available.

--with-tls

This tells EGLIBC to use Thread Local Storage.

--with-__thread

This tells EGLIBC to use use the __thread for libc and libpthread builds.

--with-binutils=${CLFS}/cross-tools/bin

This tells EGLIBC to use the Binutils that are specific to our target architecture.

--cache-file=config.cache

This tells EGLIBC to utilize a premade cache file.

During this stage the following warning might appear:

configure: WARNING:
*** These auxiliary programs are missing or
*** incompatible versions: msgfmt
*** some features will be disabled.
*** Check the INSTALL file for required versions.

The missing or incompatible msgfmt program is generally harmless. This msgfmt program is part of the Gettext package which the host distribution should provide.

Compile the package:

make

Install the package:

make install

5.11.2. Internationalization

To install locales we need to compile our own version of localedef to run nativly on the host system, so we have to extract the eglibc-localedef-2.10.1 package into our eglibc-2.10.1 directory:

tar -jxvf ../eglibc-localedef-2.10.1-20090726-r8632.tar.bz2
cd localedef

Prepare localedef for compilation:

./configure --prefix=${CLFS}/usr \
    --with-glibc=../../eglibc-2.10.1

Compile the package:

make

The locales that can make the system respond in a different language were not installed with EGLIBC. Install them with:

make install-locales

To save time, an alternative to running the previous command (which generates and installs every locale listed in the eglibc-2.10.1/localedata/SUPPORTED file) is to install only those locales that are wanted and needed. This can be achieved by using the localedef command. Information on this command is located in the INSTALL file in the EGLIBC source. However, there are a number of locales that are essential in order for the tests of future packages to pass, in particular, the libstdc++ tests from GCC. The following instructions, instead of the install-locales target used above, will install the minimum set of locales necessary for the tests to run successfully:

make SUPPORTED-LOCALES="de_DE.UTF-8/UTF-8 de_DE/ISO-8859-1 de_DE@euro/ISO-8859-15 \
    en_HK.UTF-8/UTF-8 en_HK/ISO-8859-1 \
    en_PH.UTF-8/UTF-8 en_PH/ISO-8859-1 \
    en_US.UTF-8/UTF-8 en_US/ISO-8859-1 \
    es_MX.UTF-8/UTF-8 es_MX/ISO-8859-1 \
    fa_IR/UTF-8 \
    fr_FR.UTF-8/UTF-8 fr_FR/ISO-8859-1 fr_FR@euro/ISO-8859-15 \
    it_IT.UTF-8/UTF-8 it_IT/ISO-8859-1 \
    ja_JP.EUC-JP/EUC-JP ja_JP.UTF-8/UTF-8" install-locales

Some locales installed by the make localedata/install-locales command above are not properly supported by some applications that are in the CLFS and CBLFS books. Because of the various problems that arise due to application programmers making assumptions that break in such locales, CLFS 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 CLFS 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 watch program (part of the Procps package) does not work properly in them. Various attempts to circumvent these restrictions are documented in internationalization-related hints.

5.11.3. Configuring EGLIBC

The /etc/nsswitch.conf file needs to be created because, although EGLIBC provides defaults when this file is missing or corrupt, the EGLIBC defaults do not work well in a networked environment. The time zone also needs to be configured.

Create a new file /etc/nsswitch.conf by running the following:

cat > ${CLFS}/etc/nsswitch.conf << "EOF"
# 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
EOF

To determine the local time zone, run the following script:

TZDIR="${CLFS}/usr/share/zoneinfo" ${CLFS}/usr/bin/tzselect

After answering a few questions about the location, the script will output the name of the time zone (e.g., EST5EDT or Canada/Eastern). Then create the /etc/localtime file by running:

cp -v --remove-destination ${CLFS}/usr/share/zoneinfo/[xxx] \
    ${CLFS}/etc/localtime

Replace [xxx] with the name of the time zone that tzselect provided (e.g., Canada/Eastern).

The meaning of the cp option:

--remove-destination

This is needed to force removal of the already existing symbolic link. The reason for copying the file instead of using a symlink is to cover the situation where /usr is on a separate partition. This could be important when booted into single user mode.

5.11.4. Configuring The Dynamic Loader

By default, the dynamic loader (/lib/ld-linux.so.2) searches through /lib and /usr/lib for dynamic libraries that are needed by programs as they are run. However, if there are libraries in directories other than /lib and /usr/lib, these need to be added to the /etc/ld.so.conf file in order for the dynamic loader to find them. Two directories that are commonly known to contain additional libraries are /usr/local/lib and /opt/lib, so add those directories to the dynamic loader's search path.

Create a new file /etc/ld.so.conf by running the following:

cat > ${CLFS}/etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf

/usr/local/lib
/opt/lib

# End /etc/ld.so.conf
EOF

5.11.5. Contents of EGLIBC

Installed programs: catchsegv, gencat, getconf, getent, iconv, iconvconfig, ldconfig, ldd, lddlibc4, locale, localedef, mtrace, nscd, pcprofiledump, pt_chown, rpcgen, rpcinfo, sln, sprof, tzselect, xtrace, zdump, and zic
Installed libraries: ld.so, libBrokenLocale.[a,so], libSegFault.so, libanl.[a,so], libbsd-compat.a, libc.[a,so], libcrypt.[a,so], libdl.[a,so], libg.a, libieee.a, libm.[a,so], libmcheck.a, libmemusage.so, libnsl.a, libnss_compat.so, libnss_dns.so, libnss_files.so, libnss_hesiod.so, libnss_nis.so, libnss_nisplus.so, libpcprofile.so, libpthread.[a,so], libresolv.[a,so], librpcsvc.a, librt.[a,so], libthread_db.so, and libutil.[a,so]

Short Descriptions

catchsegv

Can be used to create a stack trace when a program terminates with a segmentation fault

gencat

Generates message catalogues

getconf

Displays the system configuration values for file system specific variables

getent

Gets entries from an administrative database

iconv

Performs character set conversion

iconvconfig

Creates fastloading iconv module configuration files

ldconfig

Configures the dynamic linker runtime bindings

ldd

Reports which shared libraries are required by each given program or shared library

lddlibc4

Assists ldd with object files

locale

Tells the compiler to enable or disable the use of POSIX locales for built-in operations

localedef

Compiles locale specifications

mtrace

Reads and interprets a memory trace file and displays a summary in human-readable format

nscd

A daemon that provides a cache for the most common name service requests

pcprofiledump

Dumps information generated by PC profiling

pt_chown

A helper program for grantpt to set the owner, group and access permissions of a slave pseudo terminal

rpcgen

Generates C code to implement the Remote Procecure Call (RPC) protocol

rpcinfo

Makes an RPC call to an RPC server

sln

A statically linked program that creates symbolic links

sprof

Reads and displays shared object profiling data

tzselect

Asks the user about the location of the system and reports the corresponding time zone description

xtrace

Traces the execution of a program by printing the currently executed function

zdump

The time zone dumper

zic

The time zone compiler

ld.so

The helper program for shared library executables

libBrokenLocale

Used by programs, such as Mozilla, to solve broken locales

libSegFault

The segmentation fault signal handler

libanl

An asynchronous name lookup library

libbsd-compat

Provides the portability needed in order to run certain Berkey Software Distribution (BSD) programs under Linux

libc

The main C library

libcrypt

The cryptography library

libdl

The dynamic linking interface library

libg

A runtime library for g++

libieee

The Institute of Electrical and Electronic Engineers (IEEE) floating point library

libm

The mathematical library

libmcheck

Contains code run at boot

libmemusage

Used by memusage (included in EGLIBC, but not built in a base CLFS system as it has additional dependencies) to help collect information about the memory usage of a program

libnsl

The network services library

libnss

The Name Service Switch libraries, containing functions for resolving host names, user names, group names, aliases, services, protocols, etc.

libpcprofile

Contains profiling functions used to track the amount of CPU time spent in specific source code lines

libpthread

The POSIX threads library

libresolv

Contains functions for creating, sending, and interpreting packets to the Internet domain name servers

librpcsvc

Contains functions providing miscellaneous RPC services

librt

Contains functions providing most of the interfaces specified by the POSIX.1b Realtime Extension

libthread_db

Contains functions useful for building debuggers for multi-threaded programs

libutil

Contains code for “standard” functions used in many different Unix utilities