Details on this package are located in Section 10.9.5, “Contents of Glibc.”
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.
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/lib32 -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.
The Glibc documentation recommends building Glibc outside of the source directory in a dedicated build directory:
mkdir -v ../glibc-build cd ../glibc-build
Configure Glibc to install its 32-bit libraries into /lib32
:
echo "libc_cv_slibdir=/lib32" >> config.cache
Prepare Glibc for compilation:
CC="gcc ${BUILDN32}" CXX="g++ ${BUILDN32}" \ ../glibc-2.25/configure \ --prefix=/usr \ --enable-kernel=3.12.0 \ --libexecdir=/usr/lib32/glibc \ --libdir=/usr/lib32 \ --enable-obsolete-rpc \ --enable-stack-protector=strong \ --cache-file=config.cache
The meaning of the new configure option:
--libexecdir=/usr/lib32/glibc
This changes the location for hard links to the getconf utility from their
default of /usr/libexec
to
/usr/lib32/glibc
.
Compile the package:
make
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 check
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.
Install the package, and remove unneeded files from /usr/include/rpcsvc
:
make install && rm -v /usr/include/rpcsvc/*.x
Details on this package are located in Section 10.9.5, “Contents of Glibc.”