5.6. Glibc-2.5 Headers

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.

5.6.1. Installation of Glibc Headers

The following sed removes a dependency of gcc 3.4.x from the Glibc we are using in Cross-LFS. The reason we are changing it is because this only installs the headers; no compiling takes place. In the next Glibc chapter, we use the GCC that's built right after this chapter.

cp configure{,.orig}
sed -e 's/3.4/3.[0-9]/g' configure.orig > configure

This architecture is no longer supported in the main glibc tree, so we have to extract the glibc-ports-2.5 package into our glibc-2.5 directory. Then we move ports to the location expected by our build and patches:

tar -jxvf ../glibc-ports-2.5.tar.bz2
mv -v glibc-ports-2.5 ports

The Glibc documentation recommends building Glibc outside of the source directory in a dedicated build directory:

mkdir -v ../glibc-build
cd ../glibc-build

The following lines need to be added to config.cache for Glibc to support NPTL:

echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes" >> config.cache
echo "libc_cv_arm_tls=yes" >> config.cache

The following line needs to be added to configparms to adjust installation paths:

echo "install_root=${CLFS}" > configparms

Prepare Glibc for compilation:

CC=gcc ../glibc-2.5/configure --prefix=/usr \
    --host=${CLFS_TARGET} --build=${CLFS_HOST} \
    --with-headers=${CLFS}/usr/include --cache-file=config.cache

The meaning of the configure options:


Tells Glibc to use the hosts GCC compiler.


This tells Glibc to compile itself against the headers recently installed to the ${CLFS}/usr/include directory, so that it knows exactly what features the kernel has and can optimize itself accordingly.

Now, install the headers:

make install-headers

Some files aren't installed by the above command, so we will copy the additional header files we need.

First we will copy a common file over to ${CLFS}/usr/include:

install -dv ${CLFS}/usr/include/bits
cp -v bits/stdio_lim.h ${CLFS}/usr/include/bits

Now we will create a blank stub file:

touch ${CLFS}/usr/include/gnu/stubs.h

Another header is needed for NPTL:

cp -v ../glibc-2.5/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h \

Details on this package are located in Section 5.8.5, “Contents of Glibc.”