Skip to content

Commit 847d099

Browse files
miss-islingtonthunder-codingambvmhsmith
authored
[3.15] GH-138800: Fix variable substitution in python3.pc for Android (GH-144776) (#155107)
Clarifies the difference between LIBPYTHON, which is the library name, and the flags needed to build modules, which also need the linking path. (cherry picked from commit 5918085) Co-authored-by: Yaksh Bariya <yakshbari4@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Malcolm Smith <smith@chaquo.com>
1 parent 07e73c0 commit 847d099

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ DIST= $(DISTFILES) $(DISTDIRS)
284284
LIBRARY= @LIBRARY@
285285
LDLIBRARY= @LDLIBRARY@
286286
BLDLIBRARY= @BLDLIBRARY@
287+
MODULE_LDFLAGS_SHARED=$(if $(LIBPYTHON),$(BLDLIBRARY))
287288
PY3LIBRARY= @PY3LIBRARY@
288289
DLLLIBRARY= @DLLLIBRARY@
289290
LDLIBRARYDIR= @LDLIBRARYDIR@
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix library name in python3.pc on Android.

Modules/makesetup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
277277
;;
278278
esac
279279
rule="$file: $objs \$(MODULE_${mods_upper}_LDEPS)"
280-
rule="$rule; \$(BLDSHARED) $objs $libs \$(LIBPYTHON) -o $file"
280+
rule="$rule; \$(BLDSHARED) $objs $libs \$(MODULE_LDFLAGS_SHARED) -o $file"
281281
echo "$rule" >>$rulesf
282282
done
283283
done

configure

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6657,18 +6657,21 @@ LDVERSION='$(VERSION)$(ABIFLAGS)'
66576657
AC_MSG_RESULT([$LDVERSION])
66586658

66596659
# Configure the flags and dependencies used when compiling shared modules.
6660-
# Do not rename LIBPYTHON - it's accessed via sysconfig by package build
6661-
# systems (e.g. Meson) to decide whether to link extension modules against
6662-
# libpython.
66636660
AC_SUBST([MODULE_DEPS_SHARED])
66646661
AC_SUBST([LIBPYTHON])
66656662
MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)'
6663+
6664+
# On most platforms, extension modules aren't linked against libpython, so
6665+
# LIBPYTHON must be empty.
66666666
LIBPYTHON=''
66676667

66686668
# On Android and Cygwin the shared libraries must be linked with libpython.
6669+
# LIBPYTHON is used by python-config, python3.pc, the commands for building the
6670+
# stdlib's own extension modules, and external package build systems via
6671+
# sysconfig, so its value must be suitable for all those contexts.
66696672
if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin"); then
66706673
MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(LDLIBRARY)"
6671-
LIBPYTHON="\$(BLDLIBRARY)"
6674+
LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
66726675
fi
66736676

66746677
# On iOS the shared libraries must be linked with the Python framework

0 commit comments

Comments
 (0)