]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-138800: Fix variable substitution in python3.pc for Android (#144776) main
authorYaksh Bariya <yakshbari4@gmail.com>
Mon, 3 Aug 2026 06:52:26 +0000 (12:22 +0530)
committerGitHub <noreply@github.com>
Mon, 3 Aug 2026 06:52:26 +0000 (14:52 +0800)
Clarifies the difference between LIBPYTHON, which is the library name,
and the flags needed to build modules, which also need the linking path.

Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Co-authored-by: Malcolm Smith <smith@chaquo.com>
Makefile.pre.in
Misc/NEWS.d/next/Build/2026-03-07-02-09-57.gh-issue-138800.VD8qbz.rst [new file with mode: 0644]
Modules/makesetup
configure
configure.ac

index 465981f8fd4deda1234842a38f52e57326ad7a32..46fa26e01572cc2d7c5b58a503cd59e9d75ed806 100644 (file)
@@ -285,6 +285,7 @@ DIST=               $(DISTFILES) $(DISTDIRS)
 LIBRARY=       @LIBRARY@
 LDLIBRARY=      @LDLIBRARY@
 BLDLIBRARY=     @BLDLIBRARY@
+MODULE_LDFLAGS_SHARED=$(if $(LIBPYTHON),$(BLDLIBRARY))
 PY3LIBRARY=     @PY3LIBRARY@
 DLLLIBRARY=    @DLLLIBRARY@
 LDLIBRARYDIR=   @LDLIBRARYDIR@
diff --git a/Misc/NEWS.d/next/Build/2026-03-07-02-09-57.gh-issue-138800.VD8qbz.rst b/Misc/NEWS.d/next/Build/2026-03-07-02-09-57.gh-issue-138800.VD8qbz.rst
new file mode 100644 (file)
index 0000000..54b084d
--- /dev/null
@@ -0,0 +1 @@
+Fix library name in python3.pc on Android.
index 104c824b846540e31b7ac0a2f3612a3586445ebe..8b28946608b5762d9fff264097d9a94737028c1b 100755 (executable)
@@ -277,7 +277,7 @@ sed -e 's/[         ]*#.*//' -e '/^[        ]*$/d' |
                                ;;
                        esac
                        rule="$file: $objs \$(MODULE_${mods_upper}_LDEPS)"
-                       rule="$rule; \$(BLDSHARED) $objs $libs \$(LIBPYTHON) -o $file"
+                       rule="$rule; \$(BLDSHARED) $objs $libs \$(MODULE_LDFLAGS_SHARED) -o $file"
                        echo "$rule" >>$rulesf
                done
        done
index 2c82da923f68d4a1dd99a248a1a186ef01d610ef..836eb88e4cdb6e57d2ac655232301b9eb0a0d121 100755 (executable)
--- a/configure
+++ b/configure
@@ -27990,18 +27990,21 @@ LDVERSION='$(VERSION)$(ABIFLAGS)'
 printf "%s\n" "$LDVERSION" >&6; }
 
 # Configure the flags and dependencies used when compiling shared modules.
-# Do not rename LIBPYTHON - it's accessed via sysconfig by package build
-# systems (e.g. Meson) to decide whether to link extension modules against
-# libpython.
 
 
 MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)'
+
+# On most platforms, extension modules aren't linked against libpython, so
+# LIBPYTHON must be empty.
 LIBPYTHON=''
 
 # On Android and Cygwin the shared libraries must be linked with libpython.
+# LIBPYTHON is used by python-config, python3.pc, the commands for building the
+# stdlib's own extension modules, and external package build systems via
+# sysconfig, so its value must be suitable for all those contexts.
 if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin"); then
   MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(LDLIBRARY)"
-  LIBPYTHON="\$(BLDLIBRARY)"
+  LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
 fi
 
 # On iOS the shared libraries must be linked with the Python framework
index 771260c76b7f09491e1b423f1738b2c768c679e2..3a9841b1e7d0747ad1789896b9243647145ee726 100644 (file)
@@ -6669,18 +6669,21 @@ LDVERSION='$(VERSION)$(ABIFLAGS)'
 AC_MSG_RESULT([$LDVERSION])
 
 # Configure the flags and dependencies used when compiling shared modules.
-# Do not rename LIBPYTHON - it's accessed via sysconfig by package build
-# systems (e.g. Meson) to decide whether to link extension modules against
-# libpython.
 AC_SUBST([MODULE_DEPS_SHARED])
 AC_SUBST([LIBPYTHON])
 MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)'
+
+# On most platforms, extension modules aren't linked against libpython, so
+# LIBPYTHON must be empty.
 LIBPYTHON=''
 
 # On Android and Cygwin the shared libraries must be linked with libpython.
+# LIBPYTHON is used by python-config, python3.pc, the commands for building the
+# stdlib's own extension modules, and external package build systems via
+# sysconfig, so its value must be suitable for all those contexts.
 if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin"); then
   MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(LDLIBRARY)"
-  LIBPYTHON="\$(BLDLIBRARY)"
+  LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
 fi
 
 # On iOS the shared libraries must be linked with the Python framework