5.16. EGLIBC-2.13

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.16.1. Installation of EGLIBC

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.

Disable linking to libgcc_eh:

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

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_sparc64_tls=yes
libc_cv_gnu89_inline=yes
libc_cv_ssp=no
EOF

Prepare EGLIBC for compilation:

BUILD_CC="gcc" CC="${CLFS_TARGET}-gcc ${BUILD64}" \
      AR="${CLFS_TARGET}-ar" RANLIB="${CLFS_TARGET}-ranlib" \
      ../eglibc-2.13/configure --prefix=/tools \
      --host=${CLFS_TARGET} --build=${CLFS_HOST} \
      --disable-profile --enable-add-ons \
      --with-tls --enable-kernel=2.6.0 --with-__thread \
      --with-binutils=/cross-tools/bin --with-headers=/tools/include \
      --cache-file=config.cache

The meaning of the new configure options:

CC="${CLFS_TARGET}-gcc ${BUILD64}"

Forces EGLIBC to build using our target architecture GCC utilizing the 64 Bit flags.

--libdir=/tools/lib64

Puts EGLIBC into /tools/lib64 instead of /tools/lib.

During this stage the following warning might appear:

configure: WARNING:
*** These auxiliary programs are missing or
*** incompatible versions: msgfmt
*** some features will be disabled.
*** Check the INSTALL file for required versions.

The missing or incompatible msgfmt program is generally harmless. This msgfmt program is part of the Gettext package which the host distribution should provide.

Compile the package:

make

Install the package:

make install

The stubs.h header installed by eglibc looks for stubs-32.h and stubs-64.h. This configuration of eglibc only generates stubs-64.h. Fix this with the following:

mv -v /tools/include/gnu/stubs{-64,}.h

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