Repository navigation
build: release-build size optimizations (unwind tables, LTO) - #499
Merged
Merged
Conversation
jow-
force-pushed
the
feat/build-flags
branch
from
October 19, 2026 15:57
2987c36 to
7aa19e5
Compare
ucode is pure C with no exceptions and implements its own bytecode-level stack traces, so the .eh_frame/.eh_frame_hdr unwind tables are dead weight in shipping builds: they only serve external native-stack unwinding (backtrace(), C-level crash reporters, profilers). Omitting them via -fno-asynchronous-unwind-tables removes about 23 KB from libucode. Bind the flag to Release and MinSizeRel via a generator expression so Debug and RelWithDebInfo keep their native stack traces, and gate it behind a BUILD_NO_UNWIND_TABLES option (ON by default) in the style of the other codegen options. Stripped MinSizeRel libucode drops from ~197 KB to ~173 KB (-12.5%), below origin/master's ~193 KB; the test suite passes unchanged. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Add a BUILD_LTO option that enables CMake's interprocedural optimization for the Release and MinSizeRel configurations only, leaving Debug and RelWithDebInfo (and every default/OpenWrt build) unchanged. IPO performs cross translation-unit dead code elimination and folds identical functions, trimming a further ~2.4% from libucode (172 KB -> 168 KB stripped on top of the unwind-tables change). Off by default because it lengthens builds and assumes a matching LTO toolchain. Guarded by check_ipo_supported() with a warning if unavailable. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
jow-
force-pushed
the
feat/build-flags
branch
from
October 19, 2026 16:27
7aa19e5 to
0dc287e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two complementary CMake build options to reduce release-build size:
build: drop async stack-unwind tables in release builds — ucode is pure C with no exceptions and implements its own bytecode-level stack traces, so
.eh_frame/.eh_frame_hdrunwind tables are dead weight in shipping builds. Omitted via-fno-asynchronous-unwind-tables(Release/MinSizeRel only, gated behindBUILD_NO_UNWIND_TABLES, ON by default). Stripped MinSizeRel libucode drops from ~197 KB to ~173 KB (-12.5%).build: add opt-in link-time optimization for release builds — new
BUILD_LTOoption enabling CMake's interprocedural optimization for Release/MinSizeRel only, trimming a further ~2.4% (172 KB -> 168 KB stripped). Off by default because it lengthens builds and assumes a matching LTO toolchain; guarded bycheck_ipo_supported().Debug and RelWithDebInfo (and every default/OpenWrt build) are unchanged. Test suite passes unchanged.