Skip to content

Commit 58a0f40

Browse files
authored
gh-127604: Optimize -ldl usage on platforms that use dlopen for libFFI. (#133081)
Optimize -ldl usage on platforms that use dlopen for libFFI.
1 parent c4b7f7c commit 58a0f40

File tree

2 files changed

+128
-110
lines changed

2 files changed

+128
-110
lines changed

configure

+112-101
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

+16-9
Original file line numberDiff line numberDiff line change
@@ -2985,15 +2985,6 @@ AC_CHECK_HEADERS([ \
29852985
AC_HEADER_DIRENT
29862986
AC_HEADER_MAJOR
29872987

2988-
# for faulthandler
2989-
AC_CHECK_HEADERS([execinfo.h link.h dlfcn.h], [
2990-
AC_CHECK_FUNCS([backtrace dladdr1], [
2991-
# dladdr1 requires -ldl
2992-
ac_cv_require_ldl=yes
2993-
])
2994-
])
2995-
AS_VAR_IF([ac_cv_require_ldl], [yes], [AS_VAR_APPEND([LDFLAGS], [" -ldl"])])
2996-
29972988
# bluetooth/bluetooth.h has been known to not compile with -std=c99.
29982989
# http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
29992990
SAVE_CFLAGS=$CFLAGS
@@ -3715,6 +3706,22 @@ AC_CHECK_LIB([dl], [dlopen]) # Dynamic linking for SunOS/Solaris and SYSV
37153706
AC_CHECK_LIB([dld], [shl_load]) # Dynamic linking for HP-UX
37163707

37173708

3709+
dnl for faulthandler
3710+
AC_CHECK_HEADERS([execinfo.h link.h dlfcn.h], [
3711+
AC_CHECK_FUNCS([backtrace dladdr1], [
3712+
# dladdr1 requires -ldl
3713+
ac_cv_require_ldl=yes
3714+
])
3715+
])
3716+
3717+
dnl only add -ldl to LDFLAGS if it isn't already part of LIBS (GH-133081)
3718+
AS_VAR_IF([ac_cv_require_ldl], [yes], [
3719+
AS_VAR_IF([ac_cv_lib_dl_dlopen], [yes], [], [
3720+
AS_VAR_APPEND([LDFLAGS], [" -ldl"])
3721+
])
3722+
])
3723+
3724+
37183725
dnl check for uuid dependencies
37193726
AH_TEMPLATE([HAVE_UUID_H], [Define to 1 if you have the <uuid.h> header file.])
37203727
AH_TEMPLATE([HAVE_UUID_UUID_H], [Define to 1 if you have the <uuid/uuid.h> header file.])

0 commit comments

Comments
 (0)