diff options
author | Fedora Python maintainers <python-devel@lists.fedoraproject.org> | 2020-07-15 13:19:56 (GMT) |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2020-09-29 13:59:05 (GMT) |
commit | c44c76028d28dcfe4a4cc70cd692c3df6a0951f7 (patch) | |
tree | 4c3ad27c8145ee7f5caf4168b277f28fb6a4e7bb /Python | |
parent | 16a5ec7d9dce422935163f5b901def310d7d4dc9 (diff) | |
download | cpython-c44c76028d28dcfe4a4cc70cd692c3df6a0951f7.zip cpython-c44c76028d28dcfe4a4cc70cd692c3df6a0951f7.tar.gz cpython-c44c76028d28dcfe4a4cc70cd692c3df6a0951f7.tar.bz2 |
00112-2.7.13-debug-build.patch
00112 #
Patch to support building both optimized vs debug stacks DSO ABIs, sharing
the same .py and .pyc files, using "_d.so" to signify a debug build of an
extension module.
Based on Debian's patch for the same,
http://patch-tracker.debian.org/patch/series/view/python2.6/2.6.5-2/debug-build.dpatch
(which was itself based on the upstream Windows build), but with some
changes:
* Debian's patch to dynload_shlib.c looks for module_d.so, then module.so,
but this can potentially find a module built against the wrong DSO ABI. We
instead search for just module_d.so in a debug build
* We remove this change from configure.in's build of the Makefile:
SO=$DEBUG_EXT.so
so that sysconfig.py:customize_compiler stays with shared_lib_extension='.so'
on debug builds, so that UnixCCompiler.find_library_file can find system
libraries (otherwise "make sharedlibs" fails to find system libraries,
erroneously looking e.g. for "libffi_d.so" rather than "libffi.so")
* We change Lib/distutils/command/build_ext.py:build_ext.get_ext_filename
to add the _d there, when building an extension. This way, "make sharedlibs"
can build ctypes, by finding the sysmtem libffi.so (rather than failing to
find "libffi_d.so"), and builds the module as _ctypes_d.so
* Similarly, update build_ext:get_libraries handling of Py_ENABLE_SHARED by
appending "_d" to the python library's name for the debug configuration
* We modify Modules/makesetup to add the "_d" to the generated Makefile
rules for the various Modules/*.so targets
This may introduce issues when building an extension that links directly
against another extension (e.g. users of NumPy?), but seems more robust when
searching for external libraries
* We don't change Lib/distutils/command/build.py: build.build_purelib to
embed plat_specifier, leaving it as is, as pure python builds should be
unaffected by these differences (we'll be sharing the .py and .pyc files)
* We introduce DEBUG_SUFFIX as well as DEBUG_EXT:
- DEBUG_EXT is used by ELF files (names and SONAMEs); it will be "_d" for
a debug build
- DEBUG_SUFFIX is used by filesystem paths; it will be "-debug" for a
debug build
Both will be empty in an optimized build. "_d" contains characters that
are valid ELF metadata, but this leads to various ugly filesystem paths (such
as the include path), and DEBUG_SUFFIX allows these paths to have more natural
names. Changing this requires changes elsewhere in the distutils code.
* We add DEBUG_SUFFIX to PYTHON in the Makefile, so that the two
configurations build parallel-installable binaries with different names
("python-debug" vs "python").
* Similarly, we add DEBUG_SUFFIX within python-config and
python$(VERSION)-config, so that the two configuration get different paths
for these.
See also patch 130 below
Diffstat (limited to 'Python')
-rw-r--r-- | Python/dynload_shlib.c | 11 | ||||
-rw-r--r-- | Python/sysmodule.c | 6 |
2 files changed, 14 insertions, 3 deletions
diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 17ebab1..02a94aa 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -46,11 +46,16 @@ const struct filedescr _PyImport_DynLoadFiletab[] = { {"module.exe", "rb", C_EXTENSION}, {"MODULE.EXE", "rb", C_EXTENSION}, #else +#ifdef Py_DEBUG + {"_d.so", "rb", C_EXTENSION}, + {"module_d.so", "rb", C_EXTENSION}, +#else {".so", "rb", C_EXTENSION}, {"module.so", "rb", C_EXTENSION}, -#endif -#endif -#endif +#endif /* Py_DEBUG */ +#endif /* __VMS */ +#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */ +#endif /* __CYGWIN__ */ {0, 0} }; diff --git a/Python/sysmodule.c b/Python/sysmodule.c index fdb7af2..22238ba 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1524,6 +1524,12 @@ _PySys_Init(void) PyString_FromString("legacy")); #endif +#ifdef Py_DEBUG + PyDict_SetItemString(sysdict, "pydebug", Py_True); +#else + PyDict_SetItemString(sysdict, "pydebug", Py_False); +#endif + #undef SET_SYS_FROM_STRING if (PyErr_Occurred()) return NULL; |