summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorxdegaye <xdegaye@gmail.com>2019-04-29 07:27:40 (GMT)
committerVictor Stinner <vstinner@redhat.com>2019-04-29 07:27:40 (GMT)
commit254b309c801f82509597e3d7d4be56885ef94c11 (patch)
treeae96f759a67bfb4aaea873da5a488fb1e4e80ab6 /Lib/distutils
parentb021ba50284cdfc200b5d18dc4dea80218fcbe91 (diff)
downloadcpython-254b309c801f82509597e3d7d4be56885ef94c11.zip
cpython-254b309c801f82509597e3d7d4be56885ef94c11.tar.gz
cpython-254b309c801f82509597e3d7d4be56885ef94c11.tar.bz2
bpo-21536: On Android, C extensions are linked to libpython (GH-12989)
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/command/build_ext.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 1672d02..c3b9602 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -714,5 +714,20 @@ class build_ext(Command):
# don't extend ext.libraries, it may be shared with other
# extensions, it is a reference to the original list
return ext.libraries + [pythonlib]
+ # On Android only the main executable and LD_PRELOADs are considered
+ # to be RTLD_GLOBAL, all the dependencies of the main executable
+ # remain RTLD_LOCAL and so the shared libraries must be linked with
+ # libpython when python is built with a shared python library (issue
+ # bpo-21536).
+ else:
+ from distutils.sysconfig import get_config_var
+ if get_config_var('Py_ENABLE_SHARED'):
+ # Either a native build on an Android device or the
+ # cross-compilation of Python.
+ if (hasattr(sys, 'getandroidapilevel') or
+ ('_PYTHON_HOST_PLATFORM' in os.environ and
+ get_config_var('ANDROID_API_LEVEL') != 0)):
+ ldversion = get_config_var('LDVERSION')
+ return ext.libraries + ['python' + ldversion]
return ext.libraries