Testing a glibc build

So you want to test out a glibc build, and you don't want to install it over your existing system glibc. Not installing glibc over your existing system glibc is the normal process. Installing a new glibc over your system glibc may break your system, do not do this unless you really know what you're doing.

You need to do two things:

First we go through the two ways to build glibc:

Building glibc without installing

To build glibc without installing you can do the standard "configure" and "make" e.g.

$ mkdir $HOME/src
$ cd $HOME/src
$ git clone git://sourceware.org/git/glibc.git
$ mkdir -p $HOME/build/glibc
$ cd $HOME/build/glibc
$ $HOME/src/glibc/configure --prefix=/usr
$ make

Do not run "make install".

Building glibc with installing

Do "configure" with a --prefix install directory that you can write to, then "make" and "make install" e.g.

$ mkdir $HOME/src
$ cd $HOME/src
$ git clone git://sourceware.org/git/glibc.git
$ mkdir -p $HOME/build/glibc
$ cd $HOME/build/glibc
$ $HOME/src/glibc/configure --prefix=/install
$ make
$ make install

You now have the newly built glibc installed to /install and you can build applications that run against it.

Compile normally, run under new glibc

Use this if you want to be able to run your application easily with the newly built libc and then again with the system libc for comparison.

Compile your test program, and invoke it with the newly loader you built. This is also how the "make check" runs tests. Note: if the executable under test resides in the current directory, don't forget to use "./" before the name.

Use either testrun.sh in the build directory e.g.

$ cd $HOME/build/glibc
$ ./testrun.sh /path/to/test/application

Or do this manually like this:

GLIBC=<path to the GLIBC build directory>

GCONV_PATH=${GLIBC}/iconvdata LC_ALL=C     \
${GLIBC}/elf/ld.so.1 --library-path \
${GLIBC}:\
${GLIBC}/math:\
${GLIBC}/elf:\
${GLIBC}/dlfcn:\
${GLIBC}/nss:\
${GLIBC}/nis:\
${GLIBC}/rt:\
${GLIBC}/resolv:\
${GLIBC}/crypt:\
${GLIBC}/nptl:\
${GLIBC}/dfp \
<executable to test> <arguments>

Compile against glibc in fixed location

Use this method if you want to easily debug your application.

Compile your test program and give some extra options to gcc to use the install or build directory, and some options to the linker to set the shared library search path and dynamic linker. It is a good idea to verify the location of the dynamic linker using "readelf" and the library search paths with "ldd". (See loader tips and tricks)

SYSROOT=<path to the GLIBC install directory>

gcc ... \
  --sysroot=${SYSROOT} \
  -Wl,-rpath=${SYSROOT}/lib \
  -Wl,--dynamic-linker=${SYSROOT}/lib/ld.so.1

The built application will now *always* use the dynamic loader and libraries from the rpath you compiled it with.

None: Testing/Builds (last edited 2013-04-17 16:43:44 by CarlosODonell)