This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Stripping debugging symbols from compiled C extensions
Type: enhancement Stage: resolved
Components: Distutils2 Versions: 3rd party
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: tarek Nosy List: complex, eric.araujo, loewis, tarek
Priority: normal Keywords:

Created on 2007-04-01 23:00 by complex, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg55053 - (view) Author: Viktor Ferenczi (complex) Date: 2007-04-01 23:00
It would be nice to automatically strip debugging symbols from compiled library files (such as .so files) if a C extension module is not build in debug mode. This could somehow reduce memory footprint and storage requirements for extension modules.

Distutils already does this for cygwin and emx compilers with the following code in cygwinccompiler.py and emxccompiler.py:

# who wants symbols and a many times larger output file
# should explicitly switch the debug mode on
# otherwise we let dllwrap/ld strip the output file
# (On my machine: 10KB < stripped_file < ??100KB
#   unstripped_file = stripped_file + XXX KB
#  ( XXX=254 for a typical python extension))
if not debug:
    extra_preargs.append("-s")

This code should be somehow integrated into base compiler classes such as UnixCCompiler. I've added the following at the beginning of UnixCCompiler.link function:

if not debug:
    if extra_preargs is None:
        extra_preargs = []
    extra_preargs.append("-s")

This works for me with gcc under Linux (Debian Sarge). I does not provide a patch, since this could be the best solution for this.
msg55054 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-04-26 07:57
Just for the record: stripping symbols does *not* reduce memory footprint. It does (only) reduce storage requirements.

One problem with implementing the feature is to make it work portably on all systems. Adding -s to the linker command line is most likely not portable, i.e. some systems may not support that. Python currently ignores the concept of stripping entirely (not just for extension modules, but also for the interpreter itself, partially due to the problem that adding that further complicates portability. 

On Linux, this problem is commonly solved by distributors performing the stripping as part of the packaging utilities. E.g. for Debian, just add dh_strip into the debian/rules file, and the packaging
will strip all binaries according to the Debian policy.
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44792
2014-03-13 10:45:24eric.araujosetstatus: open -> closed
resolution: rejected
stage: patch review -> resolved
2010-10-22 14:58:27eric.araujosetversions: + 3rd party, - Python 3.2
nosy: + eric.araujo, tarek

assignee: tarek
components: + Distutils2, - Distutils
stage: test needed -> patch review
2010-08-09 03:21:42terry.reedysetstage: test needed
versions: + Python 3.2, - Python 3.1, Python 2.7
2009-02-16 16:27:06akitadasetversions: + Python 3.1, Python 2.7, - Python 2.6
2008-01-05 20:18:21christian.heimessetversions: + Python 2.6
2007-04-01 23:00:56complexcreate