https://github.com/python/cpython/commit/24436629efa3f90c52fc2e8d1d4613ed70f6d389
commit: 24436629efa3f90c52fc2e8d1d4613ed70f6d389
branch: main
author: Bénédikt Tran <10796600+picn...@users.noreply.github.com>
committer: picnixz <10796600+picn...@users.noreply.github.com>
date: 2025-04-28T00:28:42+02:00
summary:

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

files:
M Doc/library/faulthandler.rst
M configure
M configure.ac
M pyconfig.h.in

diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst
index 8823c8f8edf567..e34b067aea52e3 100644
--- a/Doc/library/faulthandler.rst
+++ b/Doc/library/faulthandler.rst
@@ -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
diff --git a/configure b/configure
index 8b91d1d871a971..26e6fb1e6b679c 100755
--- a/configure
+++ b/configure
@@ -11887,25 +11887,25 @@ 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
-then :
-  printf "%s\n" "#define HAVE_BACKTRACE 1" >>confdefs.h
 
-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
+  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_DLADDR1 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
 
+done
+
 fi
 
 done
diff --git a/configure.ac b/configure.ac
index 1aedd54bd0c70d..04ce606845daca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/pyconfig.h.in b/pyconfig.h.in
index c8a0174bd38aee..6c17685e22a078 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -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
 

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to