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.
Approximate build time: 12.3 SBU
Required disk space: 784 MB
Glibc installation depends on: Bash, Binutils, Coreutils,
Diffutils, Gawk, GCC, Gettext, Grep, Make, Perl, Sed, and Texinfo
6.11.1. Installation of Glibc
This package is known to have issues when its default optimization
flags (including the -march and
-mcpu options) are changed. If
any environment variables that override default optimizations have
been defined, such as CFLAGS and CXXFLAGS, unset them when building 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 Glibc documentation recommends building Glibc outside of the
source directory in a dedicated build directory:
mkdir ../glibc-build
cd ../glibc-build
Prepare Glibc for compilation:
../glibc-2.3.4-20040701/configure --prefix=/usr \
--disable-profile --enable-add-ons=nptl --with-tls \
--with-__thread --enable-kernel=2.6.0 --without-cvs \
--libexecdir=/usr/lib/glibc \
--with-headers=/tools/glibc-kernheaders
The meaning of the new configure option:
-
--libexecdir=/usr/lib/glibc
-
This changes the location of the pt_chown program from its default of
/usr/libexec to /usr/lib/glibc.
Compile the package:
make
Important
In this section, the test suite for Glibc is considered
critical. Do not skip it under any circumstance.
Test the results:
make check
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:
-
The math tests
sometimes fail when running on systems where the CPU is not a
relatively new genuine Intel or authentic AMD. Certain
optimization settings are also known to be a factor here.
-
The gettext test
sometimes fails due to host system issues. The exact reasons
are not yet clear.
-
The atime test
sometimes fails when the LFS partition is mounted with the
noatime option.
-
The shm test can fail
when the host system is using the devfs file system but does not have the
tmpfs file system mounted at
/dev/shm. This occurs because of a
lack of support for tmpfs in the
kernel.
-
When running on older and slower hardware, some tests can
fail because of test timeouts being exceeded.
Though it is a harmless message, the install stage of Glibc will
complain about the absence of /etc/ld.so.conf. Prevent this warning with:
touch /etc/ld.so.conf
Install the package:
make install
The locales that can make the system respond in a different
language were not installed by the above command. Install this
with:
make localedata/install-locales
To save time, an alternative to running the previous command (which
generates and installs every locale Glibc is aware of) 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 -p /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 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. 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.
Build the linuxthreads man pages, which are a great reference on
the threading API (applicable to NPTL as well):
make -C ../glibc-2.3.4-20040701/linuxthreads/man
Install these pages:
make -C ../glibc-2.3.4-20040701/linuxthreads/man install
6.11.2. 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 with
networking. The time zone also needs to be set up.
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
EOF
To determine the local time zone, run the following script:
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 --remove-destination /usr/share/zoneinfo/[xxx] \
/etc/localtime
Replace [xxx] with the name of
the time zone that the 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.
6.11.3. Configuring 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 > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
# End /etc/ld.so.conf
EOF
6.11.4. Contents of Glibc
Installed programs: catchsegv, gencat, getconf, getent,
iconv, iconvconfig, ldconfig, ldd, lddlibc4, locale, localedef,
mtrace, nscd, nscd_nischeck, 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 ouputs a summary
in human-readable format
-
nscd
-
A daemon that provides a cache for the most common name
service requests
-
nscd_nischeck
-
Checks whether or not secure mode is necessary for NIS+
lookup
-
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 ln
program
-
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 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