Skip to content

Shrink NSIS stubs and plugins with gc-sections, size-optimize makensis - #423

Merged
skeeto merged 1 commit into
skeeto:masterfrom
MarcroSoft:nsis-size
Oct 20, 2026
Merged

skeeto merged 1 commit into
skeeto:masterfrom
MarcroSoft:nsis-size

Conversation

@MarcroSoft

Copy link
Copy Markdown
Contributor

GCC-built NSIS stubs are ~116 KB versus ~38 KB for the official MSVC builds, and every generated installer carries one. Most of the gap is mingw-w64's monolithic libuuid.a; -ffunction-sections + -Wl,--gc-sections plus -Oz, -fno-ident and -fno-asynchronous-unwind-tables bring stubs to ~50 KB on x86. Plugins get the same flags except the unwind one (NSISdl uses C++ exceptions). makensis switches from -O2 to -Os. -fdata-sections is deliberately left out; see the patch header.

Verified on x86: zlib/lzma/bzip2 installers built with the patched stubs install correctly.

@MarcroSoft

Copy link
Copy Markdown
Contributor Author

Since this PR has no checks here: the same branch (d9f00c1, upstream master plus only this patch) built successfully for both x64 and x86 on my fork's CI: https://github.com/MarcroSoft/w64devkit/actions/runs/39411671387

@Peter0x44

Copy link
Copy Markdown
Collaborator

I approved your workflow so it should now run, and also any future PRs you make

@skeeto

skeeto commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Thanks, @MarcroSoft! I pushed a fixup that backs off some of your changes, being a little more conservative. -fno-asynchronous-unwind-tables is definitely unsafe for programs linking the CRT, including this one, and it's caused problems with busybox-w32. -Oz makes the stubs 1-3% slower on my systems, and makesis 6%-38% slower on my systems, for very small size improvements. -Wl,--gc-sections is the real heavy hitter, and I kept -ffunction-sections for free, modest gains on x86.

More important for makensis is that it wasn't stripped! So I just pushed that: 9ad0368. While investigating Claude also found an NSIS+Mingw-w64 bug (f915d8e).

I'm ready to merge this if you're satisfied. Any thoughts, @Peter0x44, since you're here?

@MarcroSoft

Copy link
Copy Markdown
Contributor Author

Thanks, that all makes sense — happy with the more conservative version, and good catch on stripping makensis. Fine to merge from my side.

MarcroSoft added a commit to MarcroSoft/w64devkit that referenced this pull request Oct 20, 2026
-fno-asynchronous-unwind-tables is unsafe for the stubs on x64, and -Oz costs speed for little size. A more conservative version is pending upstream as skeeto#423 and will arrive with the next upstream merge.
Stubs drop from ~117 KB to ~52 KB on x86 and from ~133 KB to ~51 KB on
x64, mostly by discarding unreferenced libuuid.a constants, and every
installer shrinks by as much. See the patch header for details.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skeeto
skeeto merged commit c91d60b into skeeto:master Oct 20, 2026
@MarcroSoft
MarcroSoft deleted the nsis-size branch October 20, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants