
Linux From Scratch - Version 7.0
87
6.9. Glibc-2.14.1
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: 14.2 SBU
Required disk space: 856 MB
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.
When running make install, a script called test-installation.pl performs a small sanity test on our newly
installed Glibc. However, because our toolchain still points to the /tools directory, the sanity test would be carried
out against the wrong Glibc. We can force the script to check the Glibc we have just installed with the following:
DL=$(readelf -l /bin/sh | sed -n 's@.*interpret.*/tools\(.*\)]$@\1@p')
sed -i "s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$DL -o|" \
scripts/test-installation.pl
unset DL
In addition, there is a bug in the test-installation.pl script in that it tries to link a test program to a library
that isn't installed by make install. Issue the following sed command to fix it:
sed -i -e 's/"db1"/& \&\& $name ne "nss_test1"/' scripts/test-installation.pl
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
Fix a couple of bugs in Glibc that can cause crashes and core dumps:
patch -Np1 -i ../glibc-2.14.1-fixes-1.patch
Fix a bug that prevents Glibc from building with GCC-4.6.1:
patch -Np1 -i ../glibc-2.14.1-gcc_fix-1.patch
Fix a stack imbalance that occurs under some conditions:
sed -i '195,213 s/PRIVATE_FUTEX/FUTEX_CLOCK_REALTIME/' \
nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timed{rd,wr}lock.S
Comentarios a estos manuales