10.8. Glibc-2.5 64-Bit

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.

10.8.1. Installation of Glibc

The Glibc build system is self-contained and will install perfectly, even though the compiler specs file and linker are still pointing at /tools. 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.

The following patch fixes an issue that can cause localdef to segfault:

patch -Np1 -i ../glibc-2.5-localedef_segfault-1.patch

The following patches merges all updates from the 2.5 Branch from the glibc developers:

patch -Np1 -i ../glibc-2.5-branch_update-1.patch

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

mkdir -v ../glibc-build
cd ../glibc-build

Tell Glibc to install its 64-bit libraries into /lib64:

echo "slibdir=/lib64" >> configparms

Prepare Glibc for compilation:

CC="gcc ${BUILD64}" CXX="g++ ${BUILD64}" \
    ../glibc-2.5/configure --prefix=/usr \
    --disable-profile --enable-add-ons --enable-kernel=2.6.0 \
    --libexecdir=/usr/lib64/glibc --libdir=/usr/lib64

The meaning of the new configure option:


This changes the location of the pt_chown program from its default of /usr/libexec to /usr/lib64/glibc.

Compile the package:



The test suite for Glibc is considered critical. Do not skip it under any circumstance.

Test the results:

make -k check >glibc-check-log 2>&1 ; grep Error glibc-check-log

The Glibc test suite is highly dependent on certain functions of the host system, in particular the kernel. The posix/annexc test normally fails and you should see Error 1 (ignored) in the output. Apart from this, the Glibc test suite is always expected to pass. However, in certain circumstances, some failures are unavoidable. If a test fails because of a missing program (or missing symbolic link), or a segfault, you will see an error code greater than 127 and the details will be in the log. More commonly, tests will fail with Error 2 - for these, the contents of the corresponding .out file, e.g. posix/annexc.out may be informative. Here is a list of the most common issues:

  • The math tests sometimes fail. Certain optimization settings are known to be a factor here.

  • If you have mounted the CLFS partition with the noatime option, the atime test will fail. As mentioned in Section 2.4, “Mounting the New Partition”, do not use the noatime option while building CLFS.

  • When running on older and slower hardware, some tests can fail because of test timeouts being exceeded.

Install the package:

make install

10.8.2. Internationalization

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

make localedata/install-locales

To save time, an alternative to running the previous command (which generates and installs every locale listed in the glibc-2.5/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 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 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:

mkdir -pv /usr/lib/locale
localedef -i de_DE -f ISO-8859-1 de_DE
localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
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 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 it_IT -f ISO-8859-1 it_IT
localedef -i ja_JP -f EUC-JP ja_JP

Some locales installed by the make localedata/install-locales command above are not properly supported by some applications that are in the CLFS and BLFS 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.

10.8.3. Configuring Glibc

The /etc/nsswitch.conf 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.

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

cat > /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

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


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 /usr/share/zoneinfo/[xxx] \

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

The meaning of the cp option:


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.

10.8.4. Configuring The Dynamic Loader

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

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

cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf


# End /etc/ld.so.conf

10.8.5. Contents of Glibc

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


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


Generates message catalogues


Displays the system configuration values for file system specific variables


Gets entries from an administrative database


Performs character set conversion


Creates fastloading iconv module configuration files


Configures the dynamic linker runtime bindings


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


Assists ldd with object files


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


Compiles locale specifications


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


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


Dumps information generated by PC profiling


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


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


Makes an RPC call to an RPC server


A statically linked program that creates symbolic links


Reads and displays shared object profiling data


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


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


The time zone dumper


The time zone compiler


The helper program for shared library executables


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


The segmentation fault signal handler


An asynchronous name lookup library


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


The main C library


The cryptography library


The dynamic linking interface library


A runtime library for g++


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


The mathematical library


Contains code run at boot


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


The network services library


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


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


The POSIX threads library


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


Contains functions providing miscellaneous RPC services


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


Contains functions useful for building debuggers for multi-threaded programs


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