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

@ -1020,26 +1020,33 @@ if test "$shared_modules" = yes; then
], ],
dnl !shl_load: dnl !shl_load:
[ [
dnl standard dlopen dnl standard dlopen
AC_SEARCH_LIBS(dlopen, [dl c_r], AC_SEARCH_LIBS(dlopen, [dl c_r],
[ [
AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.]) AC_SEARCH_LIBS(dlsym, [dl c_r],
SUFFIX=".so" [
MOD_TARGET=shared_modules if
SEDOBJ="s/\.o/.so/g" test "$ac_cv_search_dlopen" != "none required" &&
if test "$AppleGCC" = yes; then test "$ac_cv_search_dlsym" != "none required" &&
AC_CHECK_HEADERS([mach-o/dyld.h]) test "$ac_cv_search_dlopen" != "$ac_cv_search_dlsym"; then
fi AC_MSG_WARN([dlopen and dlsym from different sources])
AC_CHECK_FUNC(dlsym, , fi
[ AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.])
AC_MSG_WARN([dlsym is not available, shared modules disabled]) SUFFIX=".so"
shared_modules=no MOD_TARGET=shared_modules
]) SEDOBJ="s/\.o/.so/g"
AC_CHECK_FUNCS(dlfunc) if test "$AppleGCC" = yes; then
], AC_CHECK_HEADERS([mach-o/dyld.h])
[ fi
shared_modules=no AC_CHECK_FUNCS(dlfunc)
]) ],
[
shared_modules=no
])
],
[
shared_modules=no
])
]) ])
fi fi