Compiling glibc

In a mixed computing environment, it’s sometimes useful to have heterogeneous machines use the same library collection. For example, when running on a cluster (e.g., managed by condor), software should run regardless of the underlying operating system distribution. My environment required glibc (version 2.15); it took a bit of fiddling to get it to work, so hopefully this will save you some time.

configure errors

checking for -z relro option... no
configure: error: linker with -z relro support required

Solution: install gawk. Problem was due to incorrect parsing of the output rather than lack of support.

make errors

Executive summary: run make -j8 CFLAGS=”-U_FORTIFY_SOURCE -O2 -fno-stack-protector”

In file included from ../sysdeps/unix/sysv/linux/syslog.c:10:0:
../misc/syslog.c: In function ‘__vsyslog_chk’:
../misc/syslog.c:123:1: sorry, unimplemented: inlining failed in call to ‘syslog’: function body not available
../misc/syslog.c:155:9: sorry, unimplemented: called from here

Solution: add -U_FORTIFY_SOURCE to CFLAGS. Note that -O2 is also required in CFLAGS.

./src/glibc-2.15/build/libc_pic.a(dl-addr.os): In function `_dl_addr_inside_object':
dl-addr.c:(.text+0x0): multiple definition of `_dl_addr_inside_object'
./src/glibc-2.15/build/elf/dl-allobjs.os:(.text+0x10ef0): first defined here

Solution: this was perhaps the trickiest. Adding -march=* or -DNDEBUG didn’t help, eventually adding -fno-stack-protector to CFLAGS did the trick.

echo libnss_db-2.15.so /home/yonch/lib/libnss_db.so.2 >> /home/yonch/src/glibc-2.15/build/elf/symlink.list
rm -f /home/yonch/lib/libnss_db.so.new
/bin/sh ../scripts/rellns-sh /home/yonch/lib/libnss_db.so.2 /home/yonch/lib/libnss_db.so.new
mv -f /home/yonch/lib/libnss_db.so.new /home/yonch/lib/libnss_db.so
.././scripts/mkinstalldirs /var/db
mkdir /var/db
mkdir: cannot create directory `/var/db': Permission denied
make[2]: *** [/var/db/Makefile] Error 1

Solution: nothing – the library seemed to work for me, even with this error. The software I run does not use libnss, though.

That’s it

a “make check” looked okay (although it took forever, so was killed half way).

Posted in Tech Blog.

Leave a Reply

Your email address will not be published. Required fields are marked *