diff --git a/configure.ac b/configure.ac index ff37794f..e59a2f84 100644 --- a/configure.ac +++ b/configure.ac @@ -105,6 +105,41 @@ AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory]) # Enable GNU extensions on systems that have them. AC_GNU_SOURCE +# Taken from mpfr-4.0.1, then modified for LDADD_FOR_TESTS_KLUDGE +dnl Under Linux, make sure that the old dtags are used if LD_LIBRARY_PATH +dnl is defined. The issue is that with the new dtags, LD_LIBRARY_PATH has +dnl the precedence over the run path, so that if a compatible MPFR library +dnl is installed in some directory from $LD_LIBRARY_PATH, then the tested +dnl MPFR library will be this library instead of the MPFR library from the +dnl build tree. Other OS with the same issue might be added later. +dnl +dnl References: +dnl https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859732 +dnl http://lists.gnu.org/archive/html/libtool/2017-05/msg00000.html +dnl +dnl We need to check whether --disable-new-dtags is supported as alternate +dnl linkers may be used (e.g., with tcc: CC=tcc LD=tcc). +dnl +case $host in + *-*-linux*) + if test -n "$LD_LIBRARY_PATH"; then + saved_LDFLAGS="$LDFLAGS" + LDADD_FOR_TESTS_KLUDGE="-Wl,--disable-new-dtags" + LDFLAGS="$LDFLAGS $LDADD_FOR_TESTS_KLUDGE" + AC_MSG_CHECKING(whether --disable-new-dtags is supported by the linker) + AC_LINK_IFELSE([AC_LANG_SOURCE([[ +int main (void) { return 0; } + ]])], + [AC_MSG_RESULT(yes (use it since LD_LIBRARY_PATH is set))], + [AC_MSG_RESULT(no) + LDADD_FOR_TESTS_KLUDGE="" + ]) + LDFLAGS="$saved_LDFLAGS" + fi + ;; +esac +AC_SUBST([LDADD_FOR_TESTS_KLUDGE]) + AH_VERBATIM([_REENTRANT], [/* To allow the use of GPGME in multithreaded programs we have to use special features from the library. diff --git a/lang/cpp/tests/Makefile.am b/lang/cpp/tests/Makefile.am index 67dd3d3c..0b275955 100644 --- a/lang/cpp/tests/Makefile.am +++ b/lang/cpp/tests/Makefile.am @@ -22,7 +22,7 @@ AM_LDFLAGS = -no-install LDADD = ../../cpp/src/libgpgmepp.la \ ../../../src/libgpgme.la @GPG_ERROR_LIBS@ \ - -lstdc++ + @LDADD_FOR_TESTS_KLUDGE@ -lstdc++ AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/src \ @GPG_ERROR_CFLAGS@ @GPG_ERROR_CFLAGS@ \ diff --git a/lang/qt/tests/Makefile.am b/lang/qt/tests/Makefile.am index 6d543408..f75d64c4 100644 --- a/lang/qt/tests/Makefile.am +++ b/lang/qt/tests/Makefile.am @@ -37,7 +37,7 @@ AM_LDFLAGS = -no-install LDADD = ../../cpp/src/libgpgmepp.la ../src/libqgpgme.la \ ../../../src/libgpgme.la @GPGME_QT_LIBS@ @GPG_ERROR_LIBS@ \ - @GPGME_QTTEST_LIBS@ -lstdc++ + @GPGME_QTTEST_LIBS@ @LDADD_FOR_TESTS_KLUDGE@ -lstdc++ AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/src \ @GPG_ERROR_CFLAGS@ @GPGME_QT_CFLAGS@ @GPG_ERROR_CFLAGS@ \ diff --git a/tests/Makefile.am b/tests/Makefile.am index 8faa05ad..8950e965 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -29,7 +29,7 @@ EXTRA_DIST = start-stop-agent t-data-1.txt t-data-2.txt ChangeLog-2011 AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@ AM_LDFLAGS = -no-install -LDADD = ../src/libgpgme.la @GPG_ERROR_LIBS@ +LDADD = ../src/libgpgme.la @GPG_ERROR_LIBS@ @LDADD_FOR_TESTS_KLUDGE@ noinst_HEADERS = run-support.h @@ -37,7 +37,8 @@ noinst_PROGRAMS = $(TESTS) run-keylist run-export run-import run-sign \ run-verify run-encrypt run-identify run-decrypt run-genkey \ run-keysign run-tofu run-swdb run-threaded -run_threaded_LDADD = ../src/libgpgme.la -lpthread @GPG_ERROR_LIBS@ +run_threaded_LDADD = ../src/libgpgme.la -lpthread @GPG_ERROR_LIBS@ \ + @LDADD_FOR_TESTS_KLUDGE@ if RUN_GPG_TESTS gpgtests = gpg json diff --git a/tests/gpg/Makefile.am b/tests/gpg/Makefile.am index b8d15165..be842902 100644 --- a/tests/gpg/Makefile.am +++ b/tests/gpg/Makefile.am @@ -65,11 +65,11 @@ BUILT_SOURCES = gpg.conf gpg-agent.conf pubring-stamp \ gpg-sample.stamp AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@ AM_LDFLAGS = -no-install -LDADD = ../../src/libgpgme.la -t_thread1_LDADD = ../../src/libgpgme.la -lpthread -t_thread_keylist_LDADD = ../../src/libgpgme.la -lpthread -t_thread_keylist_verify_LDADD = ../../src/libgpgme.la -lpthread -t_cancel_LDADD = ../../src/libgpgme.la -lpthread +LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@ +t_thread1_LDADD = ../../src/libgpgme.la -lpthread @LDADD_FOR_TESTS_KLUDGE@ +t_thread_keylist_LDADD = ../../src/libgpgme.la -lpthread @LDADD_FOR_TESTS_KLUDGE@ +t_thread_keylist_verify_LDADD = ../../src/libgpgme.la -lpthread @LDADD_FOR_TESTS_KLUDGE@ +t_cancel_LDADD = ../../src/libgpgme.la -lpthread @LDADD_FOR_TESTS_KLUDGE@ # We don't run t-genkey and t-cancel in the test suite, because it # takes too long diff --git a/tests/gpgsm/Makefile.am b/tests/gpgsm/Makefile.am index 37068400..63de7477 100644 --- a/tests/gpgsm/Makefile.am +++ b/tests/gpgsm/Makefile.am @@ -38,7 +38,7 @@ EXTRA_DIST = cert_dfn_pca01.der cert_dfn_pca15.der cert_g10code_test1.der \ AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@ AM_LDFLAGS = -no-install -LDADD = ../../src/libgpgme.la +LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@ # We don't run t-genkey in the test suite, because it takes too long # and needs a working pinentry. diff --git a/tests/json/Makefile.am b/tests/json/Makefile.am index f4db8400..9b2cf71c 100644 --- a/tests/json/Makefile.am +++ b/tests/json/Makefile.am @@ -67,8 +67,9 @@ BUILT_SOURCES = gpg.conf gpg-agent.conf pubring-stamp \ gpg-sample.stamp t_json_SOURCES = t-json.c AM_LDFLAGS = -no-install -LDADD = ../../src/libgpgme.la -t_json_LDADD = ../../src/cJSON.o -lm ../../src/libgpgme.la @GPG_ERROR_LIBS@ +LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@ +t_json_LDADD = ../../src/cJSON.o -lm ../../src/libgpgme.la @GPG_ERROR_LIBS@ \ + @LDADD_FOR_TESTS_KLUDGE@ AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@ diff --git a/tests/opassuan/Makefile.am b/tests/opassuan/Makefile.am index 47686eb1..b62751d6 100644 --- a/tests/opassuan/Makefile.am +++ b/tests/opassuan/Makefile.am @@ -27,7 +27,7 @@ TESTS = EXTRA_DIST = AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@ -LDADD = ../../src/libgpgme.la +LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@ noinst_PROGRAMS = $(TESTS) t-command