5.14. EGLIBC-2.15 Headers

The EGLIBC 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.14.1. Installation of EGLIBC Headers

It should be noted that compiling EGLIBC in any way other than the method suggested in this book puts the stability of the system at risk.

ALPHA is not supported in the main EGLIBC tree, so we need the eglibc-ports tarball. Unpack eglibc-ports-2.15-r21467:

tar -xvf ../eglibc-ports-2.15-r21467.tar.xz

Disable linking to libgcc_eh:

cp -v Makeconfig{,.orig}
sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig

EGLIBC's configure script checks the version of GCC, and will fail if it's less than 3.4. The next EGLIBC build will use the GCC that will be installed into /cross-tools in the next step. However, in this step only the EGLIBC headers are being installed - no compiling is taking place - so the GCC version isn't important. The following sed removes the dependency of GCC 3.4.x:

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

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

mkdir -v ../eglibc-build
cd ../eglibc-build

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

cat > config.cache << "EOF"
libc_cv_forced_unwind=yes
libc_cv_c_cleanup=yes
libc_cv_mlong_double_128=yes
libc_cv_alpha_tls=yes
libc_cv_gnu89_inline=yes
libc_cv_ssp=no
EOF

Prepare EGLIBC for compilation:

CC=gcc ../eglibc-2.15/configure --prefix=/tools \
   --host=${CLFS_TARGET} --build=${CLFS_HOST} \
   --disable-sanity-checks --enable-kernel=2.6.32 \
   --with-headers=/tools/include --cache-file=config.cache \
   --with-binutils=/cross-tools/${CLFS_TARGET}/bin
[Note]

Note

Any error message you see about nptl at this point can safely be ignored.

The meaning of the configure options:

CC=gcc

Tells EGLIBC to use the host's GCC compiler.

--prefix=/tools

This tells the configure script to prepare to install the package in the /tools directory.

--build=${CLFS_HOST}

When used with --host, this creates a cross-architecture executable that creates files for ${CLFS_TARGET} but runs on ${CLFS_HOST}.

--host=${CLFS_TARGET}

When used with --build, this creates a cross-architecture executable that creates files for ${CLFS_TARGET} but runs on ${CLFS_HOST}.

--disable-sanity-checks

This switch disables any checks that are in place.

--enable-kernel=2.6.32

This tells EGLIBC to compile the library with support for 2.6.32 and later Linux kernels.

--with-headers=/tools/include

This tells EGLIBC to compile itself against the headers recently installed to the /tools directory, so that it knows exactly what features the kernel has and can optimize itself accordingly.

--with-binutils=/cross-tools/${CLFS_TARGET}/bin

This tells EGLIBC to use the Binutils for our specific target architecture.

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 /tools/include:

install -dv /tools/include/bits
cp -v bits/stdio_lim.h /tools/include/bits

Now we will create a blank stub file:

touch /tools/include/gnu/stubs.h

Another header is needed for NPTL:

cp -v ../eglibc-2.15/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h \
    /tools/include/bits/

Details on this package are located in Section 10.7.5, “Contents of EGLIBC.”