Details on this package are located in Section 10.7.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.
It should be noted that compiling Glibc in any way other than the method suggested in this book puts the stability of the system at risk.
Disable linking to libgcc_eh
:
patch -Np1 -i ../glibc-2.7-libgcc_eh-1.patch
The following patch fixes an issue that can cause localdef to segfault:
patch -Np1 -i ../glibc-2.7-localedef_segfault-1.patch
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
Prepare Glibc for compilation:
BUILD_CC="gcc" CC="${CLFS_TARGET}-gcc ${BUILD64}" \ AR="${CLFS_TARGET}-ar" RANLIB="${CLFS_TARGET}-ranlib" \ ../glibc-2.7/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:
BUILD_CC="gcc"
This sets Glibc to use the current compiler on our system. This is used to create the tools Glibc uses during its build.
CC="${CLFS_TARGET}-gcc
${BUILD64}"
Forces Glibc to build using our target architecture GCC utilizing the 64 Bit flags.
AR="${CLFS_TARGET}-ar"
This forces Glibc to use the ar utility we made for our target architecture.
RANLIB="${CLFS_TARGET}-ranlib"
This forces Glibc to use the ranlib utility we made for our target architecture.
--disable-profile
This builds the libraries without profiling information. Omit this option if profiling on the temporary tools is necessary.
--enable-add-ons
This tells Glibc to utilize all add-ons that are available.
--with-tls
This tells Glibc to use Thread Local Storage.
--enable-kernel=2.6.0
This tells Glibc to compile the library with support for 2.6.x Linux kernels.
--with-__thread
This tells Glibc to use use the __thread for libc and libpthread builds.
--with-binutils=/cross-tools/bin
This tells Glibc to use the Binutils that are specific to our target architecture.
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
Details on this package are located in Section 10.7.5, “Contents of Glibc.”