I built a new glibc
in ~/glibc/git/glibc/build
. I know that I can use it to start programs after embedding a path to it and and a corresponding path to loader like this:
$ gcc main.c -o main -Wl,--rpath=$HOME/glibc/git/glibc/build -Wl,--dynamic-linker=$HOME/glibc/git/glibc/build/elf/ld-linux-x86-64.so.2
main
will be started by a new libc:
$ objdump -p main
RPATH /home/user/glibc/git/glibc/build
and new loader:
$ LD_TRACE_LOADED_OBJECTS=1 ./main
linux-vdso.so.1 (0x00007fff92df2000)
libc.so.6 => /home/user/glibc/git/glibc/build/libc.so.6 (0x00007f1097055000)
/home/user/glibc/git/glibc/build/elf/ld-linux-x86-64.so.2 (0x00007f10973f5000)
I installed a new glibc
version 2.22 to ~/glibc-destdir1
. I have 2.17 installed in /lib64
. I want to use some pthread
functions that are only available in 2.22 and therefore I try to point gcc
to use new libpthread.so
but it doesn't work. This command fails:
$ LIBRARY_PATH=$HOME/glibc-destdir1/usr/local/lib gcc -std=c99 -Wl,--rpath=$HOME/glibc/git/glibc/build -Wl,--dynamic-linker=$HOME/glibc/git/glibc/build/elf/ld-linux-x86-64.so.2 thread.c -o thread -pthread
/tmp/ccSxKt9O.o: In function `thr':
thread.c:(.text+0x2f): undefined reference to `pthread_getattr_default_np'
/tmp/ccSxKt9O.o: In function `run_threads':
thread.c:(.text+0x153): undefined reference to `pthread_setattr_default_np'
/tmp/ccSxKt9O.o: In function `verify_affinity_result':
thread.c:(.text+0x4eb): undefined reference to `CPU_ISSET'
/tmp/ccSxKt9O.o: In function `do_affinity_test':
thread.c:(.text+0x571): undefined reference to `CPU_ZERO'
thread.c:(.text+0x58a): undefined reference to `CPU_SET'
/tmp/ccSxKt9O.o: In function `do_guardsize_test':
thread.c:(.text+0xa20): undefined reference to `pthread_getattr_default_np'
collect2: error: ld returned 1 exit status
Is this even possible to use a new pthread
and libc
here? I know that an old libc
is still used to build this program and that libc
as a whole contains a lot of packages and they all have to match but maybe there is a way to do what I want or my understating is incorrect?