10.7.1. Installation of Glibc
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.” Glibc provides an
iconv()
implementation and can
convert from/to Unicode, therefore libiconv is not required on a
CLFS system.
At the end of the installation, the build system will run a sanity
test to make sure everything installed properly. This script
performs its tests by attempting to compile test programs against
certain libraries. However it does not specify the path to
ld.so
, and our toolchain is still
configured to use the one in /tools
.
The following set of commands will force the script to use the
complete path of the new ld.so
that
was just installed:
LINKER=$(readelf -l /tools/bin/bash | sed -n 's@.*interpret.*/tools\(.*\)]$@\1@p')
sed -i "s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=${LINKER} -o|" \
scripts/test-installation.pl
unset LINKER
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.
Apply the following sed so the tzselect script works properly:
sed -i 's/\\$$(pwd)/`pwd`/' timezone/Makefile
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 libraries into /lib
:
echo "slibdir=/lib" >> configparms
Prepare Glibc for compilation:
../glibc-2.19/configure --prefix=/usr \
--disable-profile --enable-kernel=2.6.32 \
--libexecdir=/usr/lib/glibc --libdir=/usr/lib \
--enable-obsolete-rpc
The meaning of the new configure option:
-
--libexecdir=/usr/lib/glibc
-
This changes the location of the getconf utility from its
default of /usr/libexec
to
/usr/lib/glibc
.
Compile the package:
make
Important
Due to Glibc's critical role in a properly functioning system,
the CLFS developers strongly recommend running the testsuite.
Use the following commands to run the test suite and output any
test failures:
make -k check 2>&1 | tee glibc-check-log; 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 and conform/run-conformtest tests normally
fail 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 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. 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.5,
“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. Modifying the
make check command to set a TIMEOUTFACTOR is reported to help
eliminate these errors (e.g. TIMEOUTFACTOR=16 make -k
check).
-
posix/tst-getaddrinfo4 will always fail due to not having a
network connection when the test is run.
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
The install will finish by checking that everything is correctly
installed. Unfortunately, it will test for a multilib installation.
On x86_64 Pure64 this means it will try to test the non-existent
32-bit loader which has a different name from the 64-bit loader
(unlike on other 64-bit architectures). We fool it by creating a
symlink to the real loader.
ln -sv ld-2.19.so /lib/ld-linux.so.2
Install the package, and remove unneeded files from /usr/include/rpcsvc
:
make install &&
rm -v /usr/include/rpcsvc/*.x
Now we can remove this symlink. We also need to correct the
/usr/bin/ldd script -
if you look at this, you will see it references not only the 32-bit
linker, but also /lib64 where it thinks the 64-bit linker is. The
following sed will
correct this:
rm -v /lib/ld-linux.so.2
sed -i.bak '/RTLDLIST/s%/ld-linux.so.2 /lib64%%' /usr/bin/ldd
Check the script to make sure the sed worked correctly, then delete
the backup.
rm -v /usr/bin/ldd.bak
Install the configuration file and runtime directory for
nscd:
cp -v ../glibc-2.19/nscd/nscd.conf /etc/nscd.conf
mkdir -pv /var/cache/nscd
Install the systemd support files for nscd:
install -v -Dm644 ../glibc-2.19/nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
install -v -Dm644 ../glibc-2.19/nscd/nscd.service /lib/systemd/system/nscd.service
10.7.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.19/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 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 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 CLFS and CBLFS.
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-ng package) does not work properly in them. Various attempts
to circumvent these restrictions are documented in
internationalization-related hints.
10.7.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
EOF
Install timezone data:
tar -xf ../tzdata2014d.tar.gz
ZONEINFO=/usr/share/zoneinfo
mkdir -pv $ZONEINFO/{posix,right}
for tz in etcetera southamerica northamerica europe africa antarctica \
asia australasia backward pacificnew \
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.
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 -v /usr/share/zoneinfo/[xxx]
\
/etc/localtime
Replace [xxx]
with the
name of the time zone that tzselect provided (e.g.,
Canada/Eastern).