Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
254b309c
Commit
254b309c
authored
Apr 29, 2019
by
xdegaye
Committed by
Victor Stinner
Apr 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-21536: On Android, C extensions are linked to libpython (GH-12989)
parent
b021ba50
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
47 additions
and
10 deletions
+47
-10
Doc/distutils/apiref.rst
Doc/distutils/apiref.rst
+2
-1
Doc/whatsnew/3.8.rst
Doc/whatsnew/3.8.rst
+6
-6
Lib/distutils/command/build_ext.py
Lib/distutils/command/build_ext.py
+15
-0
Makefile.pre.in
Makefile.pre.in
+1
-0
Misc/NEWS.d/next/Build/2019-04-25-01-51-52.bpo-21536.ACQkiC.rst
...EWS.d/next/Build/2019-04-25-01-51-52.bpo-21536.ACQkiC.rst
+1
-1
Misc/python-config.in
Misc/python-config.in
+4
-1
Misc/python-config.sh.in
Misc/python-config.sh.in
+1
-1
configure
configure
+9
-0
configure.ac
configure.ac
+8
-0
No files found.
Doc/distutils/apiref.rst
View file @
254b309c
...
@@ -279,7 +279,8 @@ the full reference.
...
@@ -279,7 +279,8 @@ the full reference.
.. versionchanged:: 3.8
.. versionchanged:: 3.8
On Unix, C extensions are no longer linked to libpython.
On Unix, C extensions are no longer linked to libpython except on
Android.
.. class:: Distribution
.. class:: Distribution
...
...
Doc/whatsnew/3.8.rst
View file @
254b309c
...
@@ -883,12 +883,12 @@ Changes in the Python API
...
@@ -883,12 +883,12 @@ Changes in the Python API
Changes in the C API
Changes in the C API
--------------------
--------------------
* On Unix, C extensions are no longer linked to libpython
. When Python is
* On Unix, C extensions are no longer linked to libpython
except on
embedded, ``libpython`` must not be loaded with ``RTLD_LOCAL``, but
Android. When Python is embedded, ``libpython`` must not be loaded with
``RTLD_
GLOBAL`` instead. Previously, using ``RTLD_LOCAL``, it was already not
``RTLD_
LOCAL``, but ``RTLD_GLOBAL`` instead. Previously, using
possible to load C extensions which were not linked to ``libpython``, like C
``RTLD_LOCAL``, it was already not possible to load C extensions which were
extensions of the standard library built by the ``*shared*`` section of
not linked to ``libpython``, like C extensions of the standard library built
``Modules/Setup``.
by the ``*shared*`` section of
``Modules/Setup``.
* Use of ``#`` variants of formats in parsing or building value (e.g.
* Use of ``#`` variants of formats in parsing or building value (e.g.
:c:func:`PyArg_ParseTuple`, :c:func:`Py_BuildValue`, :c:func:`PyObject_CallFunction`,
:c:func:`PyArg_ParseTuple`, :c:func:`Py_BuildValue`, :c:func:`PyObject_CallFunction`,
...
...
Lib/distutils/command/build_ext.py
View file @
254b309c
...
@@ -714,5 +714,20 @@ class build_ext(Command):
...
@@ -714,5 +714,20 @@ class build_ext(Command):
# don't extend ext.libraries, it may be shared with other
# don't extend ext.libraries, it may be shared with other
# extensions, it is a reference to the original list
# extensions, it is a reference to the original list
return
ext
.
libraries
+
[
pythonlib
]
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
return
ext
.
libraries
Makefile.pre.in
View file @
254b309c
...
@@ -41,6 +41,7 @@ AR= @AR@
...
@@ -41,6 +41,7 @@ AR= @AR@
READELF
=
@READELF@
READELF
=
@READELF@
SOABI
=
@SOABI@
SOABI
=
@SOABI@
LDVERSION
=
@LDVERSION@
LDVERSION
=
@LDVERSION@
LIBPYTHON
=
@LIBPYTHON@
GITVERSION
=
@GITVERSION@
GITVERSION
=
@GITVERSION@
GITTAG
=
@GITTAG@
GITTAG
=
@GITTAG@
GITBRANCH
=
@GITBRANCH@
GITBRANCH
=
@GITBRANCH@
...
...
Misc/NEWS.d/next/Build/2019-04-25-01-51-52.bpo-21536.ACQkiC.rst
View file @
254b309c
On Unix, C extensions are no longer linked to libpython.
On Unix, C extensions are no longer linked to libpython
except on Android
.
It is now possible for a statically linked Python to load a C extension built
It is now possible for a statically linked Python to load a C extension built
using a shared library Python.
using a shared library Python.
...
...
Misc/python-config.in
View file @
254b309c
...
@@ -47,7 +47,10 @@ for opt in opt_flags:
...
@@ -47,7 +47,10 @@ for opt in opt_flags:
print
(
' '
.
join
(
flags
))
print
(
' '
.
join
(
flags
))
elif
opt
in
(
'--libs'
,
'--ldflags'
):
elif
opt
in
(
'--libs'
,
'--ldflags'
):
libs
=
getvar
(
'LIBS'
).
split
()
+
getvar
(
'SYSLIBS'
).
split
()
libpython
=
getvar
(
'LIBPYTHON'
)
libs
=
[
libpython
]
if
libpython
else
[]
libs
.
extend
(
getvar
(
'LIBS'
).
split
()
+
getvar
(
'SYSLIBS'
).
split
())
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
# shared library in prefix/lib/.
# shared library in prefix/lib/.
if
opt
==
'--ldflags'
:
if
opt
==
'--ldflags'
:
...
...
Misc/python-config.sh.in
View file @
254b309c
...
@@ -41,7 +41,7 @@ LIBM="@LIBM@"
...
@@ -41,7 +41,7 @@ LIBM="@LIBM@"
LIBC
=
"@LIBC@"
LIBC
=
"@LIBC@"
SYSLIBS
=
"
$LIBM
$LIBC
"
SYSLIBS
=
"
$LIBM
$LIBC
"
ABIFLAGS
=
"@ABIFLAGS@"
ABIFLAGS
=
"@ABIFLAGS@"
LIBS
=
"@LIBS@
$SYSLIBS
"
LIBS
=
"@LIB
PYTHON@ @LIB
S@
$SYSLIBS
"
BASECFLAGS
=
"@BASECFLAGS@"
BASECFLAGS
=
"@BASECFLAGS@"
LDLIBRARY
=
"@LDLIBRARY@"
LDLIBRARY
=
"@LDLIBRARY@"
OPT
=
"@OPT@"
OPT
=
"@OPT@"
...
...
configure
View file @
254b309c
...
@@ -631,6 +631,7 @@ SRCDIRS
...
@@ -631,6 +631,7 @@ SRCDIRS
THREADHEADERS
THREADHEADERS
LIBPL
LIBPL
PY_ENABLE_SHARED
PY_ENABLE_SHARED
LIBPYTHON
EXT_SUFFIX
EXT_SUFFIX
ALT_SOABI
ALT_SOABI
SOABI
SOABI
...
@@ -15154,6 +15155,14 @@ LDVERSION='$(VERSION)$(ABIFLAGS)'
...
@@ -15154,6 +15155,14 @@ LDVERSION='$(VERSION)$(ABIFLAGS)'
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: result:
$LDVERSION
"
>
&5
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: result:
$LDVERSION
"
>
&5
$as_echo
"
$LDVERSION
"
>
&6
;
}
$as_echo
"
$LDVERSION
"
>
&6
;
}
# On Android the shared libraries must be linked with libpython.
if
test
-z
"
$ANDROID_API_LEVEL
"
;
then
LIBPYTHON
=
''
else
LIBPYTHON
=
"-lpython
${
VERSION
}${
ABIFLAGS
}
"
fi
if
test
x
$PLATFORM_TRIPLET
=
x
;
then
if
test
x
$PLATFORM_TRIPLET
=
x
;
then
LIBPL
=
'$(prefix)'
"/lib/python
${
VERSION
}
/config-
${
LDVERSION
}
"
LIBPL
=
'$(prefix)'
"/lib/python
${
VERSION
}
/config-
${
LDVERSION
}
"
...
...
configure.ac
View file @
254b309c
...
@@ -4648,6 +4648,14 @@ AC_MSG_CHECKING(LDVERSION)
...
@@ -4648,6 +4648,14 @@ AC_MSG_CHECKING(LDVERSION)
LDVERSION='$(VERSION)$(ABIFLAGS)'
LDVERSION='$(VERSION)$(ABIFLAGS)'
AC_MSG_RESULT($LDVERSION)
AC_MSG_RESULT($LDVERSION)
# On Android the shared libraries must be linked with libpython.
AC_SUBST(LIBPYTHON)
if test -z "$ANDROID_API_LEVEL"; then
LIBPYTHON=''
else
LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
fi
dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
AC_SUBST(PY_ENABLE_SHARED)
AC_SUBST(PY_ENABLE_SHARED)
if test x$PLATFORM_TRIPLET = x; then
if test x$PLATFORM_TRIPLET = x; then
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment