Strip debug info from the release binary (-s -w)#333
Open
gecube wants to merge 1 commit into
Open
Conversation
The binary is built and shipped unstripped, so releases carry the full symbol and DWARF tables. Adding -s -w to the existing -ldflags drops the .symtab/.strtab and .debug_* sections and shrinks the amd64 binary by ~29% (locally: 140.1 MB -> 99.8 MB) without touching any functional section: .text, .gopclntab and .rodata are byte-identical, so runtime panic stack traces remain symbolized. The only thing lost is attaching gdb/delve to the shipped binary, which needs DWARF. The -X version injection still works alongside -s -w (verified with --version on the resulting binary). Refs coroot#249 Signed-off-by: Gaál György <gb12335@gmail.com>
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.
What
Add
-s -wto the build-ldflagsso the shipped binary no longer carries the full symbol and DWARF tables.Why
Related to #249. The binary is currently built and released unstripped (
filereportswith debug_info, not stripped), so every release ships the.symtab/.strtaband.debug_*sections.This doesn't fix the underlying growth from the
cilium/ciliumbump (that's genuinely more compiled code —.text/.gopclntab/.rodata), but it's a cheap, low-risk win on the packaging side.Verification
Built current
maintwice (Go 1.24.9), identical flags except-s -w:file-ldflagsnot stripped+ -s -wstripped(-28.8%)Section diff — only debug/symbol tables are removed, no functional section is touched:
Checked on the resulting binary:
--versionprints the injected version, so-ldflags -Xstill works alongside-s -w;--helpparses fine;.gopclntabis retained, so runtime panic stack traces stay symbolized.The only capability lost is attaching gdb/delve to the shipped binary (those need DWARF).