gh-127604: ensure -ldl is passed to the linker when dladdr1 is found (#133040)

This commit is contained in:
Bénédikt Tran 2025-04-28 00:28:42 +02:00 committed by GitHub
parent 3695ba93d5
commit 24436629ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 22 deletions

View file

@ -84,9 +84,9 @@ Dumping the C stack
C Stack Compatibility
*********************
If the system does not support the C-level :manpage:`backtrace(3)`,
:manpage:`backtrace_symbols(3)`, or :manpage:`dladdr(3)`, then C stack dumps
will not work. An error will be printed instead of the stack.
If the system does not support the C-level :manpage:`backtrace(3)`
or :manpage:`dladdr1(3)`, then C stack dumps will not work.
An error will be printed instead of the stack.
Additionally, some compilers do not support :term:`CPython's <CPython>`
implementation of C stack dumps. As a result, a different error may be printed

28
configure generated vendored
View file

@ -11887,24 +11887,24 @@ then :
cat >>confdefs.h <<_ACEOF
#define `printf "%s\n" "HAVE_$ac_header" | sed "$as_sed_cpp"` 1
_ACEOF
ac_fn_c_check_func "$LINENO" "backtrace" "ac_cv_func_backtrace"
if test "x$ac_cv_func_backtrace" = xyes
for ac_func in backtrace dladdr1
do :
as_ac_var=`printf "%s\n" "ac_cv_func_$ac_func" | sed "$as_sed_sh"`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"
then :
printf "%s\n" "#define HAVE_BACKTRACE 1" >>confdefs.h
cat >>confdefs.h <<_ACEOF
#define `printf "%s\n" "HAVE_$ac_func" | sed "$as_sed_cpp"` 1
_ACEOF
# dladdr1 requires -ldl
as_fn_append LDFLAGS " -ldl"
fi
ac_fn_c_check_func "$LINENO" "backtrace_symbols" "ac_cv_func_backtrace_symbols"
if test "x$ac_cv_func_backtrace_symbols" = xyes
then :
printf "%s\n" "#define HAVE_BACKTRACE_SYMBOLS 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "dladdr1" "ac_cv_func_dladdr1"
if test "x$ac_cv_func_dladdr1" = xyes
then :
printf "%s\n" "#define HAVE_DLADDR1 1" >>confdefs.h
fi
done
fi

View file

@ -2986,8 +2986,12 @@ AC_HEADER_DIRENT
AC_HEADER_MAJOR
# for faulthandler
AC_CHECK_HEADERS([execinfo.h link.h dlfcn.h],
[AC_CHECK_FUNCS(backtrace backtrace_symbols dladdr1)])
AC_CHECK_HEADERS([execinfo.h link.h dlfcn.h], [
AC_CHECK_FUNCS([backtrace dladdr1], [
# dladdr1 requires -ldl
AS_VAR_APPEND([LDFLAGS], [" -ldl"])
])
])
# bluetooth/bluetooth.h has been known to not compile with -std=c99.
# http://permalink.gmane.org/gmane.linux.bluez.kernel/22294

View file

@ -92,9 +92,6 @@
/* Define to 1 if you have the 'backtrace' function. */
#undef HAVE_BACKTRACE
/* Define to 1 if you have the 'backtrace_symbols' function. */
#undef HAVE_BACKTRACE_SYMBOLS
/* Define if you have the 'bind' function. */
#undef HAVE_BIND