I have custom built gcc-4.7.2
in my environment. The system gcc is gcc-4.3.4
.
I have patched the RUNPATH for all my custom gcc's binaries and shared libraries using patchelf --set-rpath
However, when I run ldd
on my 4.7.2 cc1
it picks up the system libstdc++
instead of the one pointed to by the RUNPATH:
$ ldd /sdk/x86_64/2.11.1/gcc-4.7.2/libexec/gcc/x86_64-suse-linux/4.7.2/cc1
libcloog-isl.so.1 => /sdk/x86_64/2.11.1/gcc-4.7.2/lib/libcloog-isl.so.1 (0x00007f072dce8000)
...
libc.so.6 => /lib64/libc.so.6 (0x00007f072bfe0000)
--> libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f072bcd5000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f072babe000)
/lib64/ld-linux-x86-64.so.2 (0x00007f072df0d000)
As can be seen the RUNPATH specifies the gcc-4.7.2
library locations:
$ readelf -a /sdk/x86_64/2.11.1/gcc-4.7.2/libexec/gcc/x86_64-suse-linux/4.7.2/cc1 | grep PATH
0x000000000000001d (RUNPATH) Library runpath: \
[/sdk/x86_64/2.11.1/gcc-4.7.2/lib64: \
/sdk/x86_64/2.11.1/gcc-4.7.2/lib: \
/sdk/x86_64/2.11.1/gcc-4.7.2/libexec/gcc/x86_64-suse-linux/lib64: \
/sdk/x86_64/2.11.1/gcc-4.7.2/lib/gcc/x86_64-suse-linux/4.7.2: \
/hostname/sig/lib64: \
/hostname/sig/lib]
I know that libstdc++.so.6
exists in the first entry in the RUNPATH:
$ ls -l /sdk/x86_64/2.11.1/gcc-4.7.2/lib64/libstdc++.so*
lrwxrwxrwx .../sdk/x86_64/2.11.1/gcc-4.7.2/lib64/libstdc++.so -> libstdc++.so.6.0.17
lrwxrwxrwx .../sdk/x86_64/2.11.1/gcc-4.7.2/lib64/libstdc++.so.6 -> libstdc++.so.6.0.17
-rwxr-x--- .../sdk/x86_64/2.11.1/gcc-4.7.2/lib64/libstdc++.so.6.0.17
-rwxr-x--- .../sdk/x86_64/2.11.1/gcc-4.7.2/lib64/libstdc++.so.6.0.17-gdb.py
I don't have an LD_LIBRARY_PATH set in my environment:
$ echo $LD_LIBRARY_PATH
$
- How come it doesn't pick up the library found in RUNPATH?
- How can I force it to use the
gcc-4.7.2
libraries?