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

gh-127604: ensure `-ldl` is passed only once to the linker (#133071)

files:
M Python/traceback.c
M configure
M configure.ac

diff --git a/Python/traceback.c b/Python/traceback.c
index ff8d29fa5207be..0ac0b28201c483 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -33,9 +33,9 @@
 #ifdef HAVE_LINK_H
 #    include <link.h>               // struct DL_info
 #endif
-#  if defined(__APPLE__) && defined(HAVE_BACKTRACE) && 
defined(HAVE_BACKTRACE_SYMBOLS) && defined(HAVE_DLADDR)
+#  if defined(__APPLE__) && defined(HAVE_BACKTRACE) && defined(HAVE_DLADDR)
 #    define CAN_C_BACKTRACE
-#  elif defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS) && 
defined(HAVE_DLADDR1)
+#  elif defined(HAVE_BACKTRACE) && defined(HAVE_DLADDR1)
 #    define CAN_C_BACKTRACE
 #  endif
 #endif
diff --git a/configure b/configure
index 26e6fb1e6b679c..205f196a25af2d 100755
--- a/configure
+++ b/configure
@@ -11900,7 +11900,7 @@ then :
 _ACEOF
 
     # dladdr1 requires -ldl
-    as_fn_append LDFLAGS " -ldl"
+    ac_cv_require_ldl=yes
 
 fi
 
@@ -11909,6 +11909,10 @@ done
 fi
 
 done
+if test "x$ac_cv_require_ldl" = xyes
+then :
+  as_fn_append LDFLAGS " -ldl"
+fi
 
 # bluetooth/bluetooth.h has been known to not compile with -std=c99.
 # http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
diff --git a/configure.ac b/configure.ac
index 04ce606845daca..f0ae7fbec1cbfe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2989,9 +2989,10 @@ AC_HEADER_MAJOR
 AC_CHECK_HEADERS([execinfo.h link.h dlfcn.h], [
   AC_CHECK_FUNCS([backtrace dladdr1], [
     # dladdr1 requires -ldl
-    AS_VAR_APPEND([LDFLAGS], [" -ldl"])
+    ac_cv_require_ldl=yes
   ])
 ])
+AS_VAR_IF([ac_cv_require_ldl], [yes], [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

_______________________________________________
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