6.9.1. Installation of Glibc
Note
Some packages outside of LFS 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.” Glibc provides an
iconv()
implementation and can
convert from/to Unicode, therefore libiconv is not required on an
LFS system.
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.
Fix a problem that causes the build to fail in the LFS environment:
sed -i 's#<rpc/types.h>#"rpc/types.h"#' sunrpc/rpc_clntout.c
When running make
install, a script called test-installation.pl
performs a small sanity test
on our newly installed Glibc. However, it contains a bug that
causes it to fail, so prevent it from running by issuing the
following command:
sed -i '/test-installation.pl/d' Makefile
The ldd shell script
contains Bash-specific syntax. Change its default program
interpreter to /bin/bash in case another
/bin/sh is installed
as described in the
Shells chapter of the BLFS book:
sed -i 's|@BASH@|/bin/bash|' elf/ldd.bash.in
Now fix a problem that causes some applications to crash when
utilizing problem nameservers:
patch -Np1 -i ../glibc-2.16.0-res_query_fix-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
Prepare Glibc for compilation:
../glibc-2.16.0/configure \
--prefix=/usr \
--disable-profile \
--enable-add-ons \
--enable-kernel=2.6.25 \
--libexecdir=/usr/lib/glibc
The meaning of the new configure options:
-
--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.
Generally a few tests do not pass, but you can generally ignore any
of the test failures listed below. Now test the build results:
make -k check 2>&1 | tee glibc-check-log
grep Error glibc-check-log
You will probably see an expected (ignored) failure in the
posix/annexc and
conform/run-conformtest
tests. In addition the Glibc test suite is somewhat dependent on
the host system. This is a list of the most common issues:
-
The nptl/tst-clock2,
nptl/tst-attr3,
tst/tst-cputimer1, and
rt/tst-cpuclock2 tests
have been known to fail. The reason is not completely
understood, but indications are that minor timing issues can
trigger these failures.
-
The math tests sometimes fail when running on systems where
the CPU is not a relatively new genuine Intel or authentic
AMD processor.
-
When running on older and slower hardware or on systems under
load, some tests can fail because of test timeouts being
exceeded. Modifying the make check command to set a
TIMEOUTFACTOR is reported to help eliminate these errors
(e.g. TIMEOUTFACTOR=16 make -k
check).
-
Other tests known to fail on some architectures are
posix/bug-regex32, misc/tst-writev, elf/check-textrel,
nptl/tst-getpid2, and stdio-common/bug22.
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
Install NIS and RPC related headers that are not installed by
default; these are required to rebuild glibc and by several BLFS
packages:
cp -v ../glibc-2.16.0/sunrpc/rpc/*.h /usr/include/rpc
cp -v ../glibc-2.16.0/sunrpc/rpcsvc/*.h /usr/include/rpcsvc
cp -v ../glibc-2.16.0/nis/rpcsvc/*.h /usr/include/rpcsvc
The locales that can make the system respond in a different
language were not installed by the above command. None of the
locales are required, but if some of them are missing, test suites
of the future packages would skip important testcases.
Individual locales can be installed using the localedef program. E.g., the
first localedef
command below combines the /usr/share/i18n/locales/cs_CZ
charset-independent
locale definition with the /usr/share/i18n/charmaps/UTF-8.gz
charmap
definition and appends the result to the /usr/lib/locale/locale-archive
file. The
following instructions will install the minimum set of locales
necessary for the optimal coverage of tests:
mkdir -pv /usr/lib/locale
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 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 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
In addition, install the locale for your own country, language and
character set.
Alternatively, install all locales listed in the glibc-2.16.0/localedata/SUPPORTED
file (it
includes every locale listed above and many more) at once with the
following time-consuming command:
make localedata/install-locales
Then use the localedef command to create and
install locales not listed in the glibc-2.16.0/localedata/SUPPORTED
file in the
unlikely case you need them.
6.9.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 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
EOF
Install timezone data:
tar -xf ../tzdata2012e.tar.gz
ZONEINFO=/usr/share/zoneinfo
mkdir -pv $ZONEINFO/{posix,right}
for tz in etcetera southamerica northamerica europe africa antarctica \
asia australasia backward pacificnew solar87 solar88 solar89 \
systemv; do
zic -L /dev/null -d $ZONEINFO -y "sh yearistype.sh" ${tz}
zic -L /dev/null -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}
zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}
done
cp -v zone.tab iso3166.tab $ZONEINFO
zic -d $ZONEINFO -p America/New_York
unset ZONEINFO
The meaning of the zic commands:
-
zic -L /dev/null
...
-
This creates posix timezones, without any leap seconds. It is
conventional to put these in both zoneinfo
and zoneinfo/posix
. It is necessary to put the
POSIX timezones in zoneinfo
,
otherwise various test-suites will report errors. On an
embedded system, where space is tight and you do not intend
to ever update the timezones, you could save 1.9MB by not
using the posix
directory, but
some applications or test-suites might give less good results
-
zic -L
leapseconds ...
-
This creates right timezones, including leap seconds. On an
embedded system, where space is tight and you do not intend
to ever update the timezones, or care about the correct time,
you could save 1.9MB by omitting the right
directory.
-
zic ... -p
...
-
This creates the posixrules
file. We use New York because POSIX requires the daylight
savings time rules to be in accordance with US rules,
One way to determine the local time zone is to 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., America/Edmonton). There are also some
other possible timezones listed in /usr/share/zoneinfo
such as Canada/Eastern or EST5EDT that are not identified by the
script but can be used.
Then create the /etc/localtime
file
by running:
cp -v --remove-destination /usr/share/zoneinfo/<xxx>
\
/etc/localtime
Replace <xxx>
with
the name of the time zone selected (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.9.3. 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 > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
EOF
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:
cat >> /etc/ld.so.conf << "EOF"
# Add an include directory
include /etc/ld.so.conf.d/*.conf
EOF
mkdir /etc/ld.so.conf.d