mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-111225: Link extension modules against libpython on Android (#115780)
Part of the work on PEP 738: Adding Android as a supported platform. * Rename the LIBPYTHON variable to MODULE_LDFLAGS, to more accurately reflect its purpose. * Edit makesetup to use MODULE_LDFLAGS when linking extension modules. * Edit the Makefile so that extension modules depend on libpython on Android and Cygwin. * Restore `-fPIC` on Android. It was removed several years ago with a note that the toolchain used it automatically, but this is no longer the case. Omitting it causes all linker commands to fail with an error like `relocation R_AARCH64_ADR_PREL_PG_HI21 cannot be used against symbol '_Py_FalseStruct'; recompile with -fPIC`.
This commit is contained in:
parent
113687a838
commit
7f5e3f04f8
5 changed files with 19 additions and 25 deletions
13
configure
generated
vendored
13
configure
generated
vendored
|
|
@ -834,7 +834,8 @@ LIBPL
|
|||
PY_ENABLE_SHARED
|
||||
PLATLIBDIR
|
||||
BINLIBDEST
|
||||
LIBPYTHON
|
||||
MODULE_LDFLAGS
|
||||
MODULE_DEPS_SHARED
|
||||
EXT_SUFFIX
|
||||
ALT_SOABI
|
||||
SOABI
|
||||
|
|
@ -7330,6 +7331,7 @@ printf "%s\n" "#define Py_ENABLE_SHARED 1" >>confdefs.h
|
|||
case $ac_sys_system in
|
||||
CYGWIN*)
|
||||
LDLIBRARY='libpython$(LDVERSION).dll.a'
|
||||
BLDLIBRARY='-L. -lpython$(LDVERSION)'
|
||||
DLLLIBRARY='libpython$(LDVERSION).dll'
|
||||
;;
|
||||
SunOS*)
|
||||
|
|
@ -12789,7 +12791,6 @@ then
|
|||
then CCSHARED="-fPIC";
|
||||
else CCSHARED="+z";
|
||||
fi;;
|
||||
Linux-android*) ;;
|
||||
Linux*|GNU*) CCSHARED="-fPIC";;
|
||||
Emscripten*|WASI*)
|
||||
if test "x$enable_wasm_dynamic_linking" = xyes
|
||||
|
|
@ -23959,10 +23960,12 @@ printf "%s\n" "$LDVERSION" >&6; }
|
|||
|
||||
# On Android and Cygwin the shared libraries must be linked with libpython.
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue