Details on this package are located in Section 6.10.4, “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.
This package is known to have issues when its default optimization flags (including the -march and -mtune options) are changed. If any environment variables that override default optimizations have been defined, such as CFLAGS and CXXFLAGS, unset them when building Glibc.
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.
The following patch is a glibc-2.5 branch update from Glibc's cvs server. It includes various bug fixes that were discovered after the glibc-2.5 release:
patch -Np1 -i ../glibc-2.5-branch_update-2.patch
This patch fixes a problem with the dynamic loader for kernels with PaX:
patch -Np1 -i ../glibc-2.5-dl_execstack_PaX-1.patch
This patch moves nested function to a static one to avoid generating a trampoline. This is usefull for PaX kernels:
patch -Np1 -i ../glibc-2.5-iconv_unnest-1.patch
This patch keeps localedef from crashing while running a kernel with PaX:
patch -Np1 -i ../glibc-2.5-localedef_segfault-1.patch
This patch adds PT_PAX_FLAGS program header support, related to the Binutils PT_PAX_FLAGS patch, to Glibc:
patch -Np1 -i ../glibc-2.5-pt_pax-1.patch
This sed command configures Glibc to use PIC assembly code in the utility programs, in order to use ASLR with Glibc's utilities:
cp -vi sysdeps/unix/sysv/linux/i386/sysdep.h{,.orig}
sed 's/^# if defined I386_USE_SYSENTER$/& \&\& defined SHARED/' \
sysdeps/unix/sysv/linux/i386/sysdep.h.orig \
> sysdeps/unix/sysv/linux/i386/sysdep.h
The Glibc documentation recommends building Glibc outside of the source directory in a dedicated build directory:
mkdir -v ../glibc-build cd ../glibc-build
Prepare Glibc for compilation:
../glibc-2.5/configure --prefix=/tools \
--with-binutils=/tools/bin --with-headers=/tools/include \
--enable-kernel=2.6.0 --enable-bind-now --enable-add-ons \
--without-gd --disable-profile
The meaning of the configure options:
While not required, this switch ensures that there are no errors pertaining to which Binutils programs get used during the Glibc build.
This tells Glibc 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.
This tells Glibc to compile the library with support for 2.6.x Linux kernels.
This tells Glibc to enable non-lazy runtime bindings.
This prevents the build of the memusagestat program, which insists on linking against the host's libraries (libgd, libpng, libz, etc.).
This tells Glibc to use the NPTL threading library, and LibIDN, add-ons.
This builds the libraries without profiling information.
Compile the package:
make
Install the package:
install -vd /tools/etc touch /tools/etc/ld.so.conf make install
Details on this package are located in Section 6.10.4, “Contents of Glibc.”