Skip to content

Commit 6a767bc

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 8e0c76b commit 6a767bc

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

1132911329
fi
1133011330

11331-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
11332-
$as_echo_n "checking for library containing dlopen... " >&6; }
11333-
if ${ac_cv_search_dlopen+:} false; then :
11331+
# gcc/clang's sanitizer helper library provides dlopen but not dlsym, thus
11332+
# when enabling asan the dlopen check doesn't notice that -ldl is actually
11333+
# required. Just checking for dlsym() ought to suffice.
11334+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlsym" >&5
11335+
$as_echo_n "checking for library containing dlsym... " >&6; }
11336+
if ${ac_cv_search_dlsym+:} false; then :
1133411337
$as_echo_n "(cached) " >&6
1133511338
else
1133611339
ac_func_search_save_LIBS=$LIBS
@@ -11343,11 +11346,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1134311346
#ifdef __cplusplus
1134411347
extern "C"
1134511348
#endif
11346-
char dlopen ();
11349+
char dlsym ();
1134711350
int
1134811351
main ()
1134911352
{
11350-
return dlopen ();
11353+
return dlsym ();
1135111354
;
1135211355
return 0;
1135311356
}
@@ -11360,25 +11363,25 @@ for ac_lib in '' dl; do
1136011363
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
1136111364
fi
1136211365
if ac_fn_c_try_link "$LINENO"; then :
11363-
ac_cv_search_dlopen=$ac_res
11366+
ac_cv_search_dlsym=$ac_res
1136411367
fi
1136511368
rm -f core conftest.err conftest.$ac_objext \
1136611369
conftest$ac_exeext
11367-
if ${ac_cv_search_dlopen+:} false; then :
11370+
if ${ac_cv_search_dlsym+:} false; then :
1136811371
break
1136911372
fi
1137011373
done
11371-
if ${ac_cv_search_dlopen+:} false; then :
11374+
if ${ac_cv_search_dlsym+:} false; then :
1137211375

1137311376
else
11374-
ac_cv_search_dlopen=no
11377+
ac_cv_search_dlsym=no
1137511378
fi
1137611379
rm conftest.$ac_ext
1137711380
LIBS=$ac_func_search_save_LIBS
1137811381
fi
11379-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
11380-
$as_echo "$ac_cv_search_dlopen" >&6; }
11381-
ac_res=$ac_cv_search_dlopen
11382+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlsym" >&5
11383+
$as_echo "$ac_cv_search_dlsym" >&6; }
11384+
ac_res=$ac_cv_search_dlsym
1138211385
if test "$ac_res" != no; then :
1138311386
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
1138411387

configure.in

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

11961196
AC_CHECK_LIB(m, main)
11971197
AC_SEARCH_LIBS(setproctitle, util)
1198-
AC_SEARCH_LIBS(dlopen, dl)
1198+
# gcc/clang's sanitizer helper library provides dlopen but not dlsym, thus
1199+
# when enabling asan the dlopen check doesn't notice that -ldl is actually
1200+
# required. Just checking for dlsym() ought to suffice.
1201+
AC_SEARCH_LIBS(dlsym, dl)
11991202
AC_SEARCH_LIBS(socket, [socket ws2_32])
12001203
AC_SEARCH_LIBS(shl_load, dld)
12011204
AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])

0 commit comments

Comments
 (0)