Skip to content

ci: strip debug symbols from release binaries - #2243

Open
JulienTant wants to merge 3 commits into
masterfrom
ci/strip-debug-symbols
Open

ci: strip debug symbols from release binaries#2243
JulienTant wants to merge 3 commits into
masterfrom
ci/strip-debug-symbols

Conversation

@JulienTant

@JulienTant JulienTant commented Apr 21, 2026

Copy link
Copy Markdown
Member

Summary

Pass -ldflags="-s -w" via GO_BUILD_FLAGS in the dist and dist-fips CI jobs so release builds omit the Go symbol table (-s) and DWARF debug info (-w). Local developer builds (make dist run outside CI) are unaffected. Go's BuildInfo section is preserved, so go version -m still works on the stripped binaries.

Binary size impact

Measured locally by building each target with and without -ldflags="-s -w":

Target Unstripped Stripped Saved Reduction
linux/amd64 40.2 MiB 28.2 MiB 12.0 MiB 29.8%
linux/arm64 38.0 MiB 26.6 MiB 11.5 MiB 30.1%
darwin/amd64 41.6 MiB 29.1 MiB 12.5 MiB 30.0%
darwin/arm64 39.7 MiB 26.9 MiB 12.8 MiB 32.3%
windows/amd64 40.9 MiB 28.9 MiB 12.0 MiB 29.2%

Consistent ~30% reduction per binary; the bundle ships all five, so ~60 MiB off the uncompressed tarball.

Ticket Link

N/A

Checklist

  • Gated by experimental feature flag
  • Unit tests updated

🤖 Generated with Claude Code

Pass -ldflags="-s -w" via GO_BUILD_FLAGS in the dist and dist-fips
jobs so release builds omit the Go symbol table and DWARF debug info.
Local developer builds are unaffected.
@coderabbitai

coderabbitai Bot commented Apr 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09aa4745-3133-49a7-b06a-b4fb5641d254

📥 Commits

Reviewing files that changed from the base of the PR and between b0a0ef7 and b2d0fc3.

📒 Files selected for processing (1)
  • Makefile

📝 Walkthrough

Walkthrough

The Makefile has been modified to include Go linker flags (-s -w) for release builds through a GO_BUILD_LDFLAGS variable appended to go build commands for server plugin targets, whilst debug builds explicitly set this variable to empty.

Changes

Cohort / File(s) Summary
Build Configuration
Makefile
Added GO_BUILD_LDFLAGS variable definition with linker flags (-s -w) for release builds; applied to all server plugin build targets (developer-only path, linux-amd64, linux-arm64). Debug builds explicitly set the variable to empty, making the flag addition ineffective for debug compilation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: stripping debug symbols from release binaries via GO_BUILD_FLAGS in CI jobs.
Description check ✅ Passed The description is directly related to the changeset, providing clear rationale, implementation details, and quantified binary size impact measurements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/strip-debug-symbols

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yaml:
- Around line 108-109: Summary: GO_BUILD_FLAGS is set to '-ldflags=-s -w' which
gets word-split into two args; change the env value so the entire -ldflags
payload is preserved as one argument. Instruction: update both GO_BUILD_FLAGS
definitions in the workflow to embed the ldflags in an extra pair of quotes (so
the expanded value becomes a single quoted argument, e.g. "-ldflags=-s -w") and
verify the Makefile targets that use GO_BUILD_FLAGS (the build targets
referenced around the Makefile rule names that expand GO_BUILD_FLAGS) continue
to expand it as a single argument; this prevents the shell from splitting "-s
-w" into separate tokens during go build.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 106256ae-7aad-4b06-854a-5c5d9cba4896

📥 Commits

Reviewing files that changed from the base of the PR and between 4e8fb4d and dcb6d9d.

📒 Files selected for processing (1)
  • .github/workflows/ci.yaml

Comment thread .github/workflows/ci.yaml Outdated
Make performs textual substitution of $(GO_BUILD_FLAGS), leaving it to
the shell to tokenize. Without inner quotes the shell split the value
into "-ldflags=-s" and a bare "-w", which go build rejects. Quoting the
value as -ldflags="-s -w" preserves it as a single argument.
@JulienTant
JulienTant requested a review from pavelzeman April 21, 2026 18:00
@JulienTant JulienTant added 2: Dev Review Requires review by a core committer QA Deferred labels Apr 21, 2026
@JulienTant

Copy link
Copy Markdown
Member Author

@lindy65 this PR changes the binary generation - no code change so nothing to test

@pavelzeman pavelzeman left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

It doesn't look like we're doing anything FIPS specific to plugins, but it'd be good to have Eva confirm.

@JulienTant

Copy link
Copy Markdown
Member Author

Approved.

It doesn't look like we're doing anything FIPS specific to plugins, but it'd be good to have Eva confirm.

Right I'll add Eva as reviewer and Alejandro, as he's the one usually creating the FIPS build for playbooks

@JulienTant JulienTant added the 3: Security Review Review requested from Security Team label Apr 21, 2026

@esarafianou esarafianou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JulienTant shouldn't we change the Makefile server build step instead so that the debug symbols are stripped not only from the dev binaries created during CI but also from the final release artifact?

Plugins are released from our internal centralized delivery repo that triggers the plugin's makefile.

@agarciamontoro agarciamontoro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know how this affects the generation of stacktraces when we receive panic reports from Sentry?

@pavelzeman

Copy link
Copy Markdown

I think we'll want to co-ordinate this PR with the change in mattermost/mattermost, specifically when it comes to striping the debug info and retaining it for released builds (just in case it's ever needed).

Move -ldflags="-s -w" from CI env vars into the Makefile, gated by the
existing MM_DEBUG convention. Stripping is now applied to every caller
of make server / make dist, including the centralized release pipeline,
not just the dev binaries built in this repo's CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JulienTant

Copy link
Copy Markdown
Member Author

Plugins are released from our internal centralized delivery repo that triggers the plugin's makefile.

Completely missed that! Thanks. Fixed with b2d0fc3

I also made a chance to make sure that when "MM_DEBUG" is set, we don't strip the debug symbols. Curious if it's something we might be interested for the main repo @pavelzeman?

@agarciamontoro Not sure what is used for Sentry specifically, but stacktraces are complete and unaffected. I ran a small test locally to made sure of it. If Sentry reuse the panic stacktrace, it should work fine/

@agarciamontoro agarciamontoro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @JulienTant! I also verified the stacktraces are intact, so this looks safe to me :)

@JulienTant

Copy link
Copy Markdown
Member Author

Ping @esarafianou

@pavelzeman

pavelzeman commented May 6, 2026

Copy link
Copy Markdown

Please don't merge quite yet - we need to decide if we are shipping two sets of bits (with and without debug symbols) or if we strip the symbols and ship a separate .debug info package (that could be used with a debugger).

this applies here, in monorepo and anywhere else where we'd want to revisit the size of shipping binaries

@JulienTant JulienTant added the Do Not Merge Should not be merged until this label is removed label May 6, 2026
@JulienTant

Copy link
Copy Markdown
Member Author

Please don't merge quite yet - we need to decide if we are shipping two sets of bits (with and without debug symbols) or if we strip the symbols and ship a separate .debug info package (that could be used with a debugger).

this applies here, in monorepo and anywhere else where we'd want to revisit the size of shipping binaries

Copy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2: Dev Review Requires review by a core committer 3: Security Review Review requested from Security Team Do Not Merge Should not be merged until this label is removed QA Deferred

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants