configure.ac: Adjust dlopen/dlsym checks

In modern gcc/clang, libasan (the address sanitizer runtime) exports a
weak definition of `dlopen` so that it can intercept certain flags. If
one tried to `./configure` with address sanitizer enabled, this would
cause AC_SEARCH_LIBS to conclude that dlopen doesn't require any link
flags to use. However libasan does not export `dlsym` and this caused
AC_CHECK_FUNC to fail because it didn't try linking with `-ldl`.
This commit is contained in:
mniip 2017-10-23 14:20:34 +03:00 committed by Aaron Jones
parent e1d4ebda4d
commit 5ce1252007
No known key found for this signature in database
GPG key ID: 8AF0737488AB3012

View file

@ -1023,6 +1023,14 @@ if test "$shared_modules" = yes; then
dnl standard dlopen dnl standard dlopen
AC_SEARCH_LIBS(dlopen, [dl c_r], AC_SEARCH_LIBS(dlopen, [dl c_r],
[ [
AC_SEARCH_LIBS(dlsym, [dl c_r],
[
if
test "$ac_cv_search_dlopen" != "none required" &&
test "$ac_cv_search_dlsym" != "none required" &&
test "$ac_cv_search_dlopen" != "$ac_cv_search_dlsym"; then
AC_MSG_WARN([dlopen and dlsym from different sources])
fi
AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.]) AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.])
SUFFIX=".so" SUFFIX=".so"
MOD_TARGET=shared_modules MOD_TARGET=shared_modules
@ -1030,12 +1038,11 @@ if test "$shared_modules" = yes; then
if test "$AppleGCC" = yes; then if test "$AppleGCC" = yes; then
AC_CHECK_HEADERS([mach-o/dyld.h]) AC_CHECK_HEADERS([mach-o/dyld.h])
fi fi
AC_CHECK_FUNC(dlsym, , AC_CHECK_FUNCS(dlfunc)
],
[ [
AC_MSG_WARN([dlsym is not available, shared modules disabled])
shared_modules=no shared_modules=no
]) ])
AC_CHECK_FUNCS(dlfunc)
], ],
[ [
shared_modules=no shared_modules=no