From aed69fb47150af89eb89b95fa438ecfca4f30a96 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 15 Jan 2020 10:13:54 -0700 Subject: [PATCH] We want to use DT_RUNPATH in preference to DT_RPATH in ELF binaries. Otherwise, LD_LIBRARY_PATH does not work when running the tests. The GNU linker's --enable-new-dtags can be used to do this. We don't do this on NetBSD where RPATH already supports LD_LIBRARY_PATH. --- configure | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 13 +++++++++ 2 files changed, 87 insertions(+) diff --git a/configure b/configure index a7a01bd6a..abda236f2 100755 --- a/configure +++ b/configure @@ -26631,6 +26631,80 @@ fi fi +case "$OS" in + netbsd) + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,--enable-new-dtags" >&5 +$as_echo_n "checking whether the linker accepts -Wl,--enable-new-dtags... " >&6; } +if ${ax_cv_check_ldflags___Wl___enable_new_dtags+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,--enable-new-dtags" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ax_cv_check_ldflags___Wl___enable_new_dtags=yes +else + ax_cv_check_ldflags___Wl___enable_new_dtags=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl___enable_new_dtags" >&5 +$as_echo "$ax_cv_check_ldflags___Wl___enable_new_dtags" >&6; } +if test x"$ax_cv_check_ldflags___Wl___enable_new_dtags" = xyes; then : + +if ${LDFLAGS+:} false; then : + + case " $LDFLAGS " in #( + *" -Wl,--enable-new-dtags "*) : + { { $as_echo "$as_me:${as_lineno-$LINENO}: : LDFLAGS already contains -Wl,--enable-new-dtags"; } >&5 + (: LDFLAGS already contains -Wl,--enable-new-dtags) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } ;; #( + *) : + + as_fn_append LDFLAGS " -Wl,--enable-new-dtags" + { { $as_echo "$as_me:${as_lineno-$LINENO}: : LDFLAGS=\"\$LDFLAGS\""; } >&5 + (: LDFLAGS="$LDFLAGS") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + ;; +esac + +else + + LDFLAGS=-Wl,--enable-new-dtags + { { $as_echo "$as_me:${as_lineno-$LINENO}: : LDFLAGS=\"\$LDFLAGS\""; } >&5 + (: LDFLAGS="$LDFLAGS") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + +fi + +else + : +fi + + ;; +esac + if test -n "$GCC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fvisibility=hidden" >&5 $as_echo_n "checking whether C compiler accepts -fvisibility=hidden... " >&6; } diff --git a/configure.ac b/configure.ac index f74c3b8b8..853a114fe 100644 --- a/configure.ac +++ b/configure.ac @@ -4170,6 +4170,19 @@ if test -n "$GCC" -a "$lt_cv_prog_gnu_ld" != "yes" -a -n "$GCC"; then AX_CHECK_COMPILE_FLAG([-static-libgcc], [AX_APPEND_FLAG([-Wc,-static-libgcc], [LT_LDFLAGS])]) fi +dnl +dnl We want to use DT_RUNPATH in preference to DT_RPATH in ELF binaries. +dnl Otherwise, LD_LIBRARY_PATH does not work when running the tests. +dnl We don't do this on NetBSD where RPATH already supports LD_LIBRARY_PATH. +dnl +case "$OS" in + netbsd) + ;; + *) + AX_CHECK_LINK_FLAG([-Wl,--enable-new-dtags], [AX_APPEND_FLAG([-Wl,--enable-new-dtags], [LDFLAGS])]) + ;; +esac + dnl dnl Check for symbol visibility support. dnl This test relies on AC_LANG_WERROR