5.15. EGLIBC-2.15

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.15.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_gnu89_inline=yes
libc_cv_ssp=no
EOF

Prepare EGLIBC for compilation:

BUILD_CC="gcc" CC="${CLFS_TARGET}-gcc" \
    AR="${CLFS_TARGET}-ar" RANLIB="${CLFS_TARGET}-ranlib" \
    CFLAGS="-march=$(cut -d- -f1 <<< $CLFS_TARGET) -mtune=generic -g -O2" \
    ../eglibc-2.15/configure --prefix=/tools \
    --host=${CLFS_TARGET} --build=${CLFS_HOST} \
    --disable-profile --with-tls --enable-kernel=2.6.32 --with-__thread \
    --with-binutils=/cross-tools/bin --with-headers=/tools/include \
    --cache-file=config.cache

The meaning of the new configure options:

BUILD_CC="gcc"

This sets EGLIBC to use the current compiler on our system. This is used to create the tools EGLIBC uses during its build.

CC="${CLFS_TARGET}-gcc"

This forces EGLIBC to use the GCC compiler that we made for our target architecture.

AR="${CLFS_TARGET}-ar"

This forces EGLIBC to use the ar utility we made for our target architecture.

RANLIB="${CLFS_TARGET}-ranlib"

This forces EGLIBC to use the ranlib utility we made for our target architecture.

CFLAGS="-march=$(cut -d- -f1 <<< $CLFS_TARGET) -mtune=generic -g -O2"

Forces EGLIBC to optimize for our target system.

--disable-profile

This builds the libraries without profiling information. Omit this option if profiling on the temporary tools is necessary.

--with-tls

This tells EGLIBC to use Thread Local Storage.

--enable-kernel=2.6.32

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

--with-__thread

This tells EGLIBC to use use the __thread for libc and libpthread builds.

--with-binutils=/cross-tools/bin

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

--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.

--cache-file=config.cache

This tells EGLIBC to utilize a premade cache file.

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 inst_vardbdir=/tools/var/db

inst_vardbdir=... ensures that db-Makefile is not installed on the host system

Install NIS and RPC related headers that are not installed by default.

cp -v ../eglibc-2.15/sunrpc/rpc/*.h /tools/include/rpc
cp -v ../eglibc-2.15/sunrpc/rpcsvc/*.h /tools/include/rpcsvc
cp -v ../eglibc-2.15/nis/rpcsvc/*.h /tools/include/rpcsvc

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