Subject: bug#30222: the generated run path order is incorrect, yielding failures with "make check"

From: Roumen Petrov <[email-masked]>
Date: Tue, 23 Jan 2018 20:00:37 +0200

Hello ,
Vincent Lefevre wrote:
> Hi,
>
> I've generated a MPFR 4.0.1-rc1 tarball from Debian and tested it
> on Solaris. The result: all tests from "make check" fail because
> the tested MPFR version is the one installed on the system instead
> of the local one. I've looked at one of the "link" commands:

Sound like know issue.
Let see order of libraries in LIBADD (or LDADD).
Let order is $(LIBFOO) $(LIBBAR) and $(LIBFOO) is resolved to library 
located in some system path.
If path is not recognized by libtool as "system library path" libtool 
will add path flags.

In some cases change of order could resolve issue ...... with a number 
of constraints.

> /bin/bash ../libtool  --tag=CC    --mode=link gcc  -Wall -Wmissing-prototypes -Wpointer-arith -g -O2 -ffloat-store  -no-install -L../src/.libs  -o tadd tadd.o libfrtests.la -lm -lquadmath ../src/libmpfr.la -lgmp
> libtool: link: gcc -Wall -Wmissing-prototypes -Wpointer-arith -g -O2 -ffloat-store -o tadd tadd.o  -L../src/.libs ./.libs/libfrtests.a /opt/csw/lib/libquadmath.so -lm ../src/.libs/libmpfr.so -lgmp -R/opt/csw/lib -R/tmp/mpfrtests-vincent-15114/obj/src/.libs -R/opt/csw/lib -R/usr/local/lib

So this is build of test program.
In this situation first in LDADD could be listed project library(-ies) 
then dependent (external) libraries if any.

Using proper dependency order may resolve issues with static builds 
where library order is more important.

> [SNIP]
>
> Note: MPFR was configured with
>
>    ../mpfr-4.0.1-rc1/configure --enable-assert=full
>
> In the generated "libtool" script:
>
> # Compile-time system search path for libraries.
> sys_lib_search_path_spec="/opt/csw/lib/gcc/i386-pc-solaris2.10/5.5.0 /opt/csw/i386-pc-solaris2.10/lib /opt/csw/lib /lib /usr/lib "

Ok libtool recognize /opt/csw/lib as system library search path , so 
missing -L /opt/csw/lib on build line is expected.

> # Detected run-time system search path for libraries.
> sys_lib_dlsearch_path_spec="/lib /usr/lib"

This is not good.
/opt/csw/lib is not recognized as system path for shared libraries. As 
result is extected libtool to provide flag that point to such location. 
It could be -Wl,-rpath or -R (Solaris or BSD) and etc.

You could avoid runtime flag at configure time with 
lt_cv_sys_lib_dlsearch_path_spec . Work-around if not universal.

Dunno what is status of an enhancement that allows management of 
sys_lib_dlsearch_path_spec in all cases - prepend or append extra paths. 
Perhaps is only in repository :(.

> and the environment doesn't contain anything that would cause the
> error.
>

Regards,
Roumen