From 64d81b4dd7a84ab046ec0026d51a662ccd2d0e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 27 Apr 2025 12:12:23 +0200 Subject: [PATCH 1/7] ensure `-ldl` is passed to the linker when `dladdr1` is found --- configure | 26 +++++++++++++------------- configure.ac | 8 ++++++-- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/configure b/configure index 8b91d1d871a971..0f1b5b704f6b72 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 backtrace_symbols 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..e116247a73ebd7 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 backtrace_symbols 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 From 3d22310d3fec1132b6afe9c34c64caef8aaecbcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 27 Apr 2025 12:46:55 +0200 Subject: [PATCH 2/7] cosmetics --- configure | 4 ++-- configure.ac | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 0f1b5b704f6b72..cd7cd458087de9 100755 --- a/configure +++ b/configure @@ -11899,8 +11899,8 @@ then : #define `printf "%s\n" "HAVE_$ac_func" | sed "$as_sed_cpp"` 1 _ACEOF - # dladdr1 requires -ldl - as_fn_append LDFLAGS " -ldl" + # dladdr1 requires -ldl + as_fn_append LDFLAGS " -ldl" fi diff --git a/configure.ac b/configure.ac index e116247a73ebd7..2854d30d2fd4a9 100644 --- a/configure.ac +++ b/configure.ac @@ -2987,10 +2987,10 @@ AC_HEADER_MAJOR # for faulthandler AC_CHECK_HEADERS([execinfo.h link.h dlfcn.h], [ - AC_CHECK_FUNCS([backtrace backtrace_symbols dladdr1], [ - # dladdr1 requires -ldl - AS_VAR_APPEND([LDFLAGS], [" -ldl"]) - ]) + AC_CHECK_FUNCS([backtrace backtrace_symbols dladdr1], [ + # dladdr1 requires -ldl + AS_VAR_APPEND([LDFLAGS], [" -ldl"]) + ]) ]) # bluetooth/bluetooth.h has been known to not compile with -std=c99. From 49f20722d1823c803bd043e6b1804055dc2cdd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 27 Apr 2025 17:27:04 +0200 Subject: [PATCH 3/7] Update configure.ac Co-authored-by: Victor Stinner --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2854d30d2fd4a9..04ce606845daca 100644 --- a/configure.ac +++ b/configure.ac @@ -2987,7 +2987,7 @@ AC_HEADER_MAJOR # for faulthandler AC_CHECK_HEADERS([execinfo.h link.h dlfcn.h], [ - AC_CHECK_FUNCS([backtrace backtrace_symbols dladdr1], [ + AC_CHECK_FUNCS([backtrace dladdr1], [ # dladdr1 requires -ldl AS_VAR_APPEND([LDFLAGS], [" -ldl"]) ]) From 91ec0409dd0e62d2d2ce32e2855c2949b73991a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 27 Apr 2025 17:27:33 +0200 Subject: [PATCH 4/7] Update configure --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index cd7cd458087de9..26e6fb1e6b679c 100755 --- a/configure +++ b/configure @@ -11889,7 +11889,7 @@ then : _ACEOF - for ac_func in backtrace backtrace_symbols dladdr1 + 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" From a47958496f01fe6ca54a0a3cdabdec5b4623698a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 27 Apr 2025 17:30:13 +0200 Subject: [PATCH 5/7] Update pyconfig.h.in --- pyconfig.h.in | 3 --- 1 file changed, 3 deletions(-) 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 From 549ba624be72832dbd9b284d31d89da4d371ee19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 27 Apr 2025 17:35:11 +0200 Subject: [PATCH 6/7] Update faulthandler.rst --- Doc/library/faulthandler.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst index 8823c8f8edf567..61926318164555 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:`dladdr(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 ` implementation of C stack dumps. As a result, a different error may be printed From f73ed0bf82d9e81048c86f7be54d9b94552856b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 27 Apr 2025 22:51:21 +0200 Subject: [PATCH 7/7] Update Doc/library/faulthandler.rst Co-authored-by: Peter Bierma --- Doc/library/faulthandler.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst index 61926318164555..e34b067aea52e3 100644 --- a/Doc/library/faulthandler.rst +++ b/Doc/library/faulthandler.rst @@ -85,7 +85,7 @@ C Stack Compatibility ********************* If the system does not support the C-level :manpage:`backtrace(3)` -or :manpage:`dladdr(3)`, then C stack dumps will not work. +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 `