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

Commit e52e9bd

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 9814c70 commit e52e9bd

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
@@ -11700,9 +11700,12 @@ if test "$ac_res" != no; then :
1170011700

1170111701
fi
1170211702

11703-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
11704-
$as_echo_n "checking for library containing dlopen... " >&6; }
11705-
if ${ac_cv_search_dlopen+:} false; then :
11703+
# gcc/clang's sanitizer helper library provides dlopen but not dlsym, thus
11704+
# when enabling asan the dlopen check doesn't notice that -ldl is actually
11705+
# required. Just checking for dlsym() ought to suffice.
11706+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlsym" >&5
11707+
$as_echo_n "checking for library containing dlsym... " >&6; }
11708+
if ${ac_cv_search_dlsym+:} false; then :
1170611709
$as_echo_n "(cached) " >&6
1170711710
else
1170811711
ac_func_search_save_LIBS=$LIBS
@@ -11715,11 +11718,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1171511718
#ifdef __cplusplus
1171611719
extern "C"
1171711720
#endif
11718-
char dlopen ();
11721+
char dlsym ();
1171911722
int
1172011723
main ()
1172111724
{
11722-
return dlopen ();
11725+
return dlsym ();
1172311726
;
1172411727
return 0;
1172511728
}
@@ -11732,25 +11735,25 @@ for ac_lib in '' dl; do
1173211735
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
1173311736
fi
1173411737
if ac_fn_c_try_link "$LINENO"; then :
11735-
ac_cv_search_dlopen=$ac_res
11738+
ac_cv_search_dlsym=$ac_res
1173611739
fi
1173711740
rm -f core conftest.err conftest.$ac_objext \
1173811741
conftest$ac_exeext
11739-
if ${ac_cv_search_dlopen+:} false; then :
11742+
if ${ac_cv_search_dlsym+:} false; then :
1174011743
break
1174111744
fi
1174211745
done
11743-
if ${ac_cv_search_dlopen+:} false; then :
11746+
if ${ac_cv_search_dlsym+:} false; then :
1174411747

1174511748
else
11746-
ac_cv_search_dlopen=no
11749+
ac_cv_search_dlsym=no
1174711750
fi
1174811751
rm conftest.$ac_ext
1174911752
LIBS=$ac_func_search_save_LIBS
1175011753
fi
11751-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
11752-
$as_echo "$ac_cv_search_dlopen" >&6; }
11753-
ac_res=$ac_cv_search_dlopen
11754+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlsym" >&5
11755+
$as_echo "$ac_cv_search_dlsym" >&6; }
11756+
ac_res=$ac_cv_search_dlsym
1175411757
if test "$ac_res" != no; then :
1175511758
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
1175611759

configure.ac

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

12011201
AC_CHECK_LIB(m, main)
12021202
AC_SEARCH_LIBS(setproctitle, util)
1203-
AC_SEARCH_LIBS(dlopen, dl)
1203+
# gcc/clang's sanitizer helper library provides dlopen but not dlsym, thus
1204+
# when enabling asan the dlopen check doesn't notice that -ldl is actually
1205+
# required. Just checking for dlsym() ought to suffice.
1206+
AC_SEARCH_LIBS(dlsym, dl)
12041207
AC_SEARCH_LIBS(socket, [socket ws2_32])
12051208
AC_SEARCH_LIBS(shl_load, dld)
12061209
AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])

0 commit comments

Comments
 (0)