OCPBUGS-83863: Strip debug symbols from Go binaries#1525
Conversation
Add -s -w to ldflags to strip DWARF debug info and symbol tables. This typically reduces binary size by 20-30%, which reduces container image pull time during node scale-up. Also fix build-gather-sysinfo and build-performance-profile-creator targets which intended to strip but had a make-vs-shell variable expansion bug: they set a shell variable LDFLAGS then referenced $(LDFLAGS) which make expands (to empty) before the shell runs. rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED
|
@sdodson: This pull request references Jira Issue OCPBUGS-83863, which is valid. 3 validation(s) were run on this bug
The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sdodson The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
WalkthroughThe Makefile adds Go linker stripping flags ( ChangesBinary size optimization via Go linker flags
🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 10 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (10 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@sdodson: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
Thank you for the PR, Scott. Do we want to do the same thing for |
Summary
-s -wto ldflags inGO_BUILD_RECIPEto strip DWARF debug info and symbol tables from the main operator binarybuild-gather-sysinfoandbuild-performance-profile-creatortargets which intended to strip but had a make-vs-shell variable expansion bug ($(LDFLAGS)is expanded by make before the shell runs, so the shell variable set on the previous line was never used)Impact
The cluster-node-tuning-operator image (617 MB) contains three unstripped Go binaries totaling 195 MB:
cluster-node-tuning-operator(96.8 MB)gather-sysinfo(63.8 MB)performance-profile-creator(34.6 MB)Stripping typically reduces Go binary size by 20-30%, reducing container image pull time during node scale-up.
Test plan
file /usr/bin/cluster-node-tuning-operatorshould show "stripped")Summary by CodeRabbit