-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-21536: C extensions are no longer linked to libpython #12946
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
Conversation
This PR allows to load a C extension built by a shared libpython with a statically linked Python: https://bugs.python.org/issue21536#msg340819 It also allows to load C extension built in release mode with a Python built in debug mode: https://bugs.python.org/issue21536#msg340821 |
One potential issue: linking an application to libpython to embed Python, see discussion at https://bugs.python.org/issue21536#msg340837 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
On Unix, C extensions are no longer linked to libpython. It is now possible to load a C extension built using a shared library Python with a statically linked Python. When Python is embedded, libpython must not be loaded with RTLD_LOCAL, but RTLD_GLOBAL instead. Previously, using RTLD_LOCAL, it was already not possible to load C extensions which were not linked to libpython, like C extensions of the standard library built by the "*shared*" section of Modules/Setup. distutils, python-config and python-config.py have been modified.
As of Python 3.8, python C extensions modules should not link to libpython, unless they embed the interpreter in their code. Relevant upstream PR: python/cpython#12946 Signed-off-by: Gabriel Féron <[email protected]>
As of Python 3.8, python C extensions modules should not link to libpython, unless they embed the interpreter in their code. Relevant upstream PR: python/cpython#12946 Signed-off-by: Gabriel Féron <[email protected]>
This change causes strange bugs on Mac OS X due to the two-level namespace symbol resolution for dynamic libraries. A C extension that links against libpython will resolve symbols from libpython instead of the python executable (for example, PDAL/python#75 ). I believe linking C extensions on Mac OS X with "-flat_namespace" would be a reliable fix, as it would allow the python executable symbols to take precedence over those from libpython. |
Please don't comment closed PRs, but open a new issue at https://bugs.python.org/ Otherwise, your comment will simply be ignored. |
On Unix, C extensions are no longer linked to libpython.
It is now possible to load a C extension built using a shared library
Python with a statically linked Python.
When Python is embedded, libpython must not be loaded with
RTLD_LOCAL, but RTDL_GLOBAL instead. Previously, using RTLD_LOCAL, it
was already not possible to load C extensions which were not linked
to libpython, like C extensions of the standard library built by the
"shared" section of Modules/Setup.
distutils, python-config and python-config.py have been modified.
https://bugs.python.org/issue21536