From a8fc92d020aded8863b4f996fd7571b4969236e0 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 18 Sep 2020 09:52:30 -0700 Subject: [PATCH] Add -ldl library if needed for dladdr() It's possible for the dlopen() check to succeed without -ldl, but the dladdr() check fails without it. This happens with GCC's -fsanitize=address. --- configure | 7 +++++-- configure.in | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/configure b/configure index e070960091..67963c7733 100755 --- a/configure +++ b/configure @@ -33302,7 +33302,7 @@ if test "x$ac_cv_lib_dl_dlopen" = xyes; then : $as_echo "#define HAVE_DLOPEN 1" >>confdefs.h HAVE_DL_FUNCS=1 - DL_LINK="-ldl $DL_LINK" + DL_LINK="-ldl" fi @@ -33360,7 +33360,10 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dladdr" >&5 $as_echo "$ac_cv_lib_dl_dladdr" >&6; } if test "x$ac_cv_lib_dl_dladdr" = xyes; then : - $as_echo "#define HAVE_DLADDR 1" >>confdefs.h + + $as_echo "#define HAVE_DLADDR 1" >>confdefs.h + + DL_LINK="-ldl" fi diff --git a/configure.in b/configure.in index a70fbff49a..4168591a29 100644 --- a/configure.in +++ b/configure.in @@ -5565,7 +5565,7 @@ if test "$TOOLKIT" != "MSW"; then [ AC_DEFINE(HAVE_DLOPEN) HAVE_DL_FUNCS=1 - DL_LINK="-ldl $DL_LINK" + DL_LINK="-ldl" ]) ]) @@ -5574,7 +5574,11 @@ if test "$TOOLKIT" != "MSW"; then AC_CHECK_FUNCS(dladdr, AC_DEFINE(HAVE_DLADDR), [ - AC_CHECK_LIB(dl, dladdr, AC_DEFINE(HAVE_DLADDR)) + AC_CHECK_LIB(dl, dladdr, + [ + AC_DEFINE(HAVE_DLADDR) + DL_LINK="-ldl" + ]) ] ) fi