[ python-Feature Requests-1692592 ] Stripping debugging symbols from compiled C extensions

SourceForge.net noreply at sourceforge.net
Thu Apr 26 09:57:10 CEST 2007


Feature Requests item #1692592, was opened at 2007-04-02 01:00
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1692592&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Viktor Ferenczi (complex)
Assigned to: Nobody/Anonymous (nobody)
Summary: Stripping debugging symbols from compiled C extensions

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2007-04-26 09:57

Message:
Logged In: YES 
user_id=21627
Originator: NO

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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1692592&group_id=5470


More information about the Python-bugs-list mailing list