I'm attempting to build an executable on a Debian Bookworm system to be run on Debian Bullseye.
I have downloaded and unpacked library packages for Bullseye in dedicated directories to link against.
However, despite I add the location for the old libgcc_s.so into the runtime path, the system-wide version is still preferred. What's wrong?
bodqhrohro@debian:~/git/td/build$ ldd tdutils/generate/generate_mime_types_gperf
tdutils/generate/generate_mime_types_gperf: /home/bodqhrohro/git/glibc/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by tdutils/generate/generate_mime_types_gperf)
tdutils/generate/generate_mime_types_gperf: /home/bodqhrohro/git/glibc/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_ABI_DT_RELR' not found (required by /lib/x86_64-linux-gnu/libm.so.6)
tdutils/generate/generate_mime_types_gperf: /home/bodqhrohro/git/glibc/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.35' not found (required by /lib/x86_64-linux-gnu/libgcc_s.so.1)
tdutils/generate/generate_mime_types_gperf: /home/bodqhrohro/git/glibc/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /lib/x86_64-linux-gnu/libgcc_s.so.1)
linux-vdso.so.1 (0x00007fffc6be8000)
libstdc++.so.6 => /home/bodqhrohro/git/libstdc++/usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd49918c000)
libc.so.6 => /home/bodqhrohro/git/glibc/lib/x86_64-linux-gnu/libc.so.6 (0x00007fd498fb8000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd498ebd000)
/home/bodqhrohro/git/glibc/lib64/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007fd499364000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd498e9d000)
bodqhrohro@debian:~/git/td/build$ objdump -p tdutils/generate/generate_mime_types_gperf |grep RUNPATH
RUNPATH /home/bodqhrohro/git/glibc/lib/x86_64-linux-gnu:/home/bodqhrohro/git/libstdc++/usr/lib/x86_64-linux-gnu:/home/bodqhrohro/git/libgcc-s1/lib/x86_64-linux-gnu:/home/bodqhrohro/git/libssl/usr/lib/x86_64-linux-gnu
bodqhrohro@debian:~/git/td/build$ ls -l /home/bodqhrohro/git/libgcc-s1/lib/x86_64-linux-gnu/
total 100
-rw-r--r-- 1 bodqhrohro bodqhrohro 100736 Jan 10 2021 libgcc_s.so.1
I attempted to use -static -Wl,-Bdynamic,-lgcc_s,-Bstatic, this way compilation succeeds somehow, and this small intermediate utility is run during the build process successfully on the same system, but ldd shows it's not a dynamic executable. Is it really how it is intended to work? And this approach is not suitable, as the primary executable needs to be dynamically linked against OpenSSL rather than to be completely static.
After inspecting the
lddcall withLD_DEBUG=all, I discovered thatlibgcc_s.so.1(and alsolibm.so.6) were in fact needed bylibstdc++.so.6, which is inaffected by the overriddenrpath. Compiling with-static-libstdc++helped to resolve this exact issue.