Skip to content

Commit f40ce64

Browse files
committed
gh-99942: correct the pkg-config/python-config flags for cygwin/android
On shared build configurations, Cygwin and Android need to link to libpython. See bpo-21536. This was corrected in distutils with an explicit check to only link when libpython is built shared, but implemented in configure.ac unconditionally. The correct approach is to follow distutils, which includes a comment regarding why: - on Android, a shared libpython is RTLD_LOCAL, and thus available only to the main executable, not exported to loaded modules, but a static libpython *is* the main executable and thus exported - on Cygwin, symbols in shared libraries must be resolved at link time It's actually not clear to me what to do for Cygwin. Cygwin doesn't actually build static libpython successfully. If it did, then extensions probably need to be linked to the import library for the executable, rather than the full static library. So omitting this here is probably correct, but incomplete. Either way, it won't matter until other fixes are made.
1 parent d9dff4c commit f40ce64

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
On Android, in a static build, python-config in embed mode no longer
2+
incorrectly reports a library to link to.

configure

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5830,7 +5830,7 @@ AC_MSG_RESULT($LDVERSION)
58305830

58315831
# On Android and Cygwin the shared libraries must be linked with libpython.
58325832
AC_SUBST(LIBPYTHON)
5833-
if test -n "$ANDROID_API_LEVEL" -o "$MACHDEP" = "cygwin"; then
5833+
if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin"); then
58345834
LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
58355835
else
58365836
LIBPYTHON=''

0 commit comments

Comments
 (0)