Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e71c76f

Browse files
committed
configure: check for dlsym instead of dlopen.
When building with sanitizers the sanitizer library provides dlopen, but not dlsym(), making configure think that -ldl isn't needed. Just checking for dlsym() ought to suffice, hard to see dlsym() being provided without dlopen() also being provided. Backpatch to all branches, for the same reasons as 46ab07f. Reviewed-By: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20220323173537.ll7klrglnp4gn2um@alap3.anarazel.de Backpatch: 10-
1 parent c97e4bd commit e71c76f

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

configure

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11856,9 +11856,12 @@ if test "$ac_res" != no; then :
1185611856

1185711857
fi
1185811858

11859-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
11860-
$as_echo_n "checking for library containing dlopen... " >&6; }
11861-
if ${ac_cv_search_dlopen+:} false; then :
11859+
# gcc/clang's sanitizer helper library provides dlopen but not dlsym, thus
11860+
# when enabling asan the dlopen check doesn't notice that -ldl is actually
11861+
# required. Just checking for dlsym() ought to suffice.
11862+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlsym" >&5
11863+
$as_echo_n "checking for library containing dlsym... " >&6; }
11864+
if ${ac_cv_search_dlsym+:} false; then :
1186211865
$as_echo_n "(cached) " >&6
1186311866
else
1186411867
ac_func_search_save_LIBS=$LIBS
@@ -11871,11 +11874,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1187111874
#ifdef __cplusplus
1187211875
extern "C"
1187311876
#endif
11874-
char dlopen ();
11877+
char dlsym ();
1187511878
int
1187611879
main ()
1187711880
{
11878-
return dlopen ();
11881+
return dlsym ();
1187911882
;
1188011883
return 0;
1188111884
}
@@ -11888,25 +11891,25 @@ for ac_lib in '' dl; do
1188811891
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
1188911892
fi
1189011893
if ac_fn_c_try_link "$LINENO"; then :
11891-
ac_cv_search_dlopen=$ac_res
11894+
ac_cv_search_dlsym=$ac_res
1189211895
fi
1189311896
rm -f core conftest.err conftest.$ac_objext \
1189411897
conftest$ac_exeext
11895-
if ${ac_cv_search_dlopen+:} false; then :
11898+
if ${ac_cv_search_dlsym+:} false; then :
1189611899
break
1189711900
fi
1189811901
done
11899-
if ${ac_cv_search_dlopen+:} false; then :
11902+
if ${ac_cv_search_dlsym+:} false; then :
1190011903

1190111904
else
11902-
ac_cv_search_dlopen=no
11905+
ac_cv_search_dlsym=no
1190311906
fi
1190411907
rm conftest.$ac_ext
1190511908
LIBS=$ac_func_search_save_LIBS
1190611909
fi
11907-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
11908-
$as_echo "$ac_cv_search_dlopen" >&6; }
11909-
ac_res=$ac_cv_search_dlopen
11910+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlsym" >&5
11911+
$as_echo "$ac_cv_search_dlsym" >&6; }
11912+
ac_res=$ac_cv_search_dlsym
1191011913
if test "$ac_res" != no; then :
1191111914
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
1191211915

configure.ac

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,10 @@ AC_SUBST(PTHREAD_LIBS)
12291229

12301230
AC_CHECK_LIB(m, main)
12311231
AC_SEARCH_LIBS(setproctitle, util)
1232-
AC_SEARCH_LIBS(dlopen, dl)
1232+
# gcc/clang's sanitizer helper library provides dlopen but not dlsym, thus
1233+
# when enabling asan the dlopen check doesn't notice that -ldl is actually
1234+
# required. Just checking for dlsym() ought to suffice.
1235+
AC_SEARCH_LIBS(dlsym, dl)
12331236
AC_SEARCH_LIBS(socket, [socket ws2_32])
12341237
AC_SEARCH_LIBS(shl_load, dld)
12351238
AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])

0 commit comments

Comments
 (0)