Disabling debugging information for MinGW portions of NSIS (was: Re: Debugging information in MinGW packages)

Kevin Kofler kevin.kofler at chello.at
Tue Mar 3 18:49:15 UTC 2009


I wrote:
> Currently, mingw32-nsis builds everything with debugging information (due
> to the debian-debug-opt patch), even the MinGW parts, but the MinGW
> debugging information is not extracted, so it's included within the
> binaries. This is particularly annoying for NSIS installers as it bloats
> the installer stubs. For example, the lzma_solid stub is 210185 bytes,
> running a MinGW strip on it reduces it to 55296 bytes.

An additional issue with NSIS in particular is that when debugging
information is present in the stubs, NSIS corrupts their symbol table,
which also affects the names of the debugging sections in the section table
because they are long section names and thus stored in the symbol table,
and thus !packhdr doesn't work: if I use:
!packhdr tmpexe.tmp "upx --best -q tmpexe.tmp"
UPX complains about "superfluous data between sections". If I try:
!packhdr tmpexe.tmp "i686-pc-mingw32-strip tmpexe.tmp; upx --best -q
tmpexe.tmp"
I even get a crash in i686-pc-mingw32-strip. (Note that this is on x86_64, I
haven't tested what happens with the 32-bit version, but I suspect that
it'll be the same thing.)

I think the "resource editor" in NSIS
(CResourceEditor::AddExtraVirtualSize2PESection, which is what is used on
the stubs, in particular) somehow does not support symbol tables.

If I strip the stub I use (/usr/share/nsis/Stubs/lzma_solid) beforehand, UPX
works on the generated tmpexe.tmp just fine.

I think that we'll want to build at least the NSIS stubs without debugging
information as upstream does. Actually, I'd like to drop the
debian-debug-opt patch entirely. That patch does 5 things:
* adds -g for the cross-platform executables - this is redundant with our
rpm-opt patch, we already inherit -g from RPM_OPT_FLAGS.
* adds -g for the MinGW executables - this is what is causing the packhdr
problem above and wastes space in the installers with little benefit (you
rarely need to debug an installer), as I previously mentioned in this
thread.
* makes optimization optional - useless, we set OPT=1 in the specfile
anyway.
* replaces -Os with -O2 for the MinGW portions - why? Upstream intentionally
uses -Os to keep the installers as small as possible. An installer is
something you execute once and there's nothing in them which needs a high
performance.
* disables stripping if DEBUG_SYMBOLS is true - we can simply pass
STRIP=false or STRIP_CP=false (the latter only disabling stripping for the
native binaries and not the MinGW ones - that said, I'm not sure whether
stripping makes any difference for the MinGW binaries if they're already
built without debugging information) to get that same effect.

The details of what I want to do:
* remove nsis-2.43-debian-debug-opt.patch
* rediff nsis-2.43-rpm-opt.patch so it applies without that patch being
applied first
* change the SCons options to remove DEBUG_SYMBOLS=1 OPTS=1 (options added
by the patch) and use STRIP_CP=false instead (the upstream way to disable
stripping).

Any objections?

        Kevin Kofler




More information about the mingw mailing list