Skip to content

Commit 5918085

Browse files
thunder-codingambvmhsmith
authored
GH-138800: Fix variable substitution in python3.pc for Android (#144776)
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>
1 parent 204feba commit 5918085

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
@@ -285,6 +285,7 @@ DIST= $(DISTFILES) $(DISTDIRS)
285285
LIBRARY= @LIBRARY@
286286
LDLIBRARY= @LDLIBRARY@
287287
BLDLIBRARY= @BLDLIBRARY@
288+
MODULE_LDFLAGS_SHARED=$(if $(LIBPYTHON),$(BLDLIBRARY))
288289
PY3LIBRARY= @PY3LIBRARY@
289290
DLLLIBRARY= @DLLLIBRARY@
290291
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
@@ -6669,18 +6669,21 @@ LDVERSION='$(VERSION)$(ABIFLAGS)'
66696669
AC_MSG_RESULT([$LDVERSION])
66706670

66716671
# Configure the flags and dependencies used when compiling shared modules.
6672-
# Do not rename LIBPYTHON - it's accessed via sysconfig by package build
6673-
# systems (e.g. Meson) to decide whether to link extension modules against
6674-
# libpython.
66756672
AC_SUBST([MODULE_DEPS_SHARED])
66766673
AC_SUBST([LIBPYTHON])
66776674
MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)'
6675+
6676+
# On most platforms, extension modules aren't linked against libpython, so
6677+
# LIBPYTHON must be empty.
66786678
LIBPYTHON=''
66796679

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

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

0 commit comments

Comments
 (0)