[Python-Dev] Use C extensions compiled in release mode on a Python compiled in debug mode

Antoine Pitrou solipsis at pitrou.net
Wed Apr 24 13:00:21 EDT 2019

On Wed, 24 Apr 2019 18:02:18 +0200
Victor Stinner <vstinner at redhat.com> wrote:
> I see 2 solutions:
> (1) Use a different directory. If "libpython" gets the same filename
> in release and debug mode, at least, they must be installed in
> different directories. If libpython build in debug mode is installed
> in /usr/lib64/python3.7-dbg/ for example, python3.7-dbg should be
> compiled with -rpath /usr/lib64/python3.7-dbg/ to get the debug
> libpython.
> (2) If "libpython" gets a different filename in debug mode, C
> extensions should not be linked to libpython explicitly but
> *implicitly* to avoid picking the wrong libpython. For example, remove
> "-lpython3.7m" from "python3.7-config --ldflags" output.
> The option (1) rely on rpath which is discouraged by Linux vendors and
> may not be supported by all operating systems.
> The option (2) is simpler and likely more portable.
> Currently, C extensions of the standard library may or may not be
> linked to libpython depending on they are built. In practice, both
> work since python3.7 is already linked to libpython: so libpython is
> already loaded in memory before C extensions are loaded.

You can participate in https://bugs.python.org/issue21536



More information about the Python-Dev mailing list