]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127604: ensure `-ldl` is passed to the linker when `dladdr1` is found (#133040)
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Sun, 27 Apr 2025 22:28:42 +0000 (00:28 +0200)
committerGitHub <noreply@github.com>
Sun, 27 Apr 2025 22:28:42 +0000 (00:28 +0200)
Doc/library/faulthandler.rst
configure
configure.ac
pyconfig.h.in

index 8823c8f8edf5675262fe5127cdd5516425bb5f0a..e34b067aea52e3a01a022d0fd4c56588109d7e0f 100644 (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
index 8b91d1d871a971faee6071e2ff244a0e9fbdeb03..26e6fb1e6b679c394c10d1a7668b48468ec90afa 100755 (executable)
--- 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
index 1aedd54bd0c70d39e9ebc0d94d435cc34d53acc0..04ce606845daca841af9e74bab718b82a1a394e1 100644 (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
index c8a0174bd38aee06d6026d37931f2ad38f3bbbb5..6c17685e22a078510e781fb6ffd03ae900b400b2 100644 (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