Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-111225: Link extension modules against libpython on Android #115780

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ AR= @AR@
READELF= @READELF@
SOABI= @SOABI@
LDVERSION= @LDVERSION@
LIBPYTHON= @LIBPYTHON@
MODULE_LDFLAGS=@MODULE_LDFLAGS@
GITVERSION= @GITVERSION@
GITTAG= @GITTAG@
GITBRANCH= @GITBRANCH@
Expand Down Expand Up @@ -2917,7 +2917,7 @@ Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h

# force rebuild when header file or module build flavor (static/shared) is changed
MODULE_DEPS_STATIC=Modules/config.c
MODULE_DEPS_SHARED=$(MODULE_DEPS_STATIC) $(EXPORTSYMS)
MODULE_DEPS_SHARED=@MODULE_DEPS_SHARED@

MODULE__CURSES_DEPS=$(srcdir)/Include/py_curses.h
MODULE__CURSES_PANEL_DEPS=$(srcdir)/Include/py_curses.h
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Link extension modules against libpython on Android.
14 changes: 1 addition & 13 deletions Modules/makesetup
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,6 @@ esac
NL='\
'

# Setup to link with extra libraries when making shared extensions.
# Currently, only Cygwin needs this baggage.
case `uname -s` in
CYGWIN*) if test $libdir = .
then
ExtraLibDir=.
else
ExtraLibDir='$(LIBPL)'
fi
ExtraLibs="-L$ExtraLibDir -lpython\$(LDVERSION)";;
esac

erlend-aasland marked this conversation as resolved.
Show resolved Hide resolved
# Main loop
for i in ${*-Setup}
do
Expand Down Expand Up @@ -286,7 +274,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
;;
esac
rule="$file: $objs"
rule="$rule; \$(BLDSHARED) $objs $libs $ExtraLibs -o $file"
rule="$rule; \$(BLDSHARED) $objs $libs \$(MODULE_LDFLAGS) -o $file"
echo "$rule" >>$rulesf
done
done
Expand Down
13 changes: 8 additions & 5 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ if test $enable_shared = "yes"; then
case $ac_sys_system in
CYGWIN*)
LDLIBRARY='libpython$(LDVERSION).dll.a'
BLDLIBRARY='-L. -lpython$(LDVERSION)'
DLLLIBRARY='libpython$(LDVERSION).dll'
;;
SunOS*)
Expand Down Expand Up @@ -3333,7 +3334,6 @@ then
then CCSHARED="-fPIC";
else CCSHARED="+z";
fi;;
Linux-android*) ;;
Linux*|GNU*) CCSHARED="-fPIC";;
Emscripten*|WASI*)
AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
Expand Down Expand Up @@ -5888,11 +5888,13 @@ LDVERSION='$(VERSION)$(ABIFLAGS)'
AC_MSG_RESULT([$LDVERSION])

# On Android and Cygwin the shared libraries must be linked with libpython.
AC_SUBST([LIBPYTHON])
AC_SUBST([MODULE_DEPS_SHARED])
AC_SUBST([MODULE_LDFLAGS])
MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)'
MODULE_LDFLAGS=''
if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin"); then
LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
else
LIBPYTHON=''
MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(LDLIBRARY)"
MODULE_LDFLAGS="\$(BLDLIBRARY)"
fi


Expand Down
Loading