How to prevent libtool to add system path (i.e. /usr/lib) to RUNPATH (rpath)?
During testing (checking) MPFR libtool adds system path to rpath before testing path, i.e.:
0x000000000000001d (RUNPATH) Library runpath: [/usr/lib:/LFSC/native/src/bmpfr/src/.libs]
As a result, tests can run installed libs (in the first path (system)) instead of testing ones. This happens usually when reinstalling software. Maybe this affects installing of upgrades.
This is because of existing dependency’s .la file, e.g. libquadmath.la
Removing .la files resolves this problem.
But there is no reason at all to add system path into hardcoded RUNPATH.
Is there any way to resolve this problem without deleting .la files? Of course I know that I can change generated libtool script.
This is about hardcoded runpath in ELF file that has high priority against system path and LD_LIBRARY_PATH. You can ease understand this by compiling MPFR from source without installing. After make check run this in the source folder root:
readelf -a tests/tversion | grep PATH
You will see RPATH without system path.
Then add libquadmath.la into gcc lib home e.g. /usr/lib/gcc/x86_64-linux-gnu/6/ remove tests and make check again, then check PATH in tversion again
# libquadmath.la - a libtool library file
# Generated by libtool (GNU libtool 1.3134 2009-11-29) 2.2.7a
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='libquadmath.so.0'
# Names of this library.
library_names='libquadmath.so.0.0.0 libquadmath.so.0 libquadmath.so'
# The name of the static archive.
old_library='libquadmath.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=' -lm'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libquadmath.
current=0
age=0
revision=0
# Is this an already installed library?
installed=yes
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/usr/lib/../lib'