OCPBUGS-83863: Strip debug symbols from Go binaries#92
Conversation
Set LDFLAGS to -s -w after including release-tools/build.make 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. 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. |
|
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)
WalkthroughThis PR adds linker flags to the Makefile that instruct the compiler to strip symbol and debug information from the final binary, reducing the output file size during the build process. ChangesBuild Configuration
🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 12✅ Passed checks (12 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[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 |
|
@sdodson: The following test 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. |
| all: build | ||
|
|
||
| include release-tools/build.make | ||
| LDFLAGS = -s -w |
There was a problem hiding this comment.
(Starting a few separate threads)
Why is it necessary in the livenessprobe and not other OCP images? IIRC, we don't stripe any CSI sidecar and most probably no OCP image.
Is there any document that says that OCP binaries need to be stripped?
There was a problem hiding this comment.
Working on that now openshift/enhancements#2021
| all: build | ||
|
|
||
| include release-tools/build.make | ||
| LDFLAGS = -s -w |
There was a problem hiding this comment.
This is upstream Makefile. If we really need to strip the binary, it would be better to export this env, var in Dockerfile.openshift.rhel7, which we already <carry>, and it won't conflict with any upstream changes to the Makefile.
There was a problem hiding this comment.
ACK I can refactor toward that
| all: build | ||
|
|
||
| include release-tools/build.make | ||
| LDFLAGS = -s -w |
There was a problem hiding this comment.
And please use UPSTREAM: <carry>: in the commit message.
Summary
LDFLAGS = -s -winMakefileafter includingrelease-tools/build.maketo strip DWARF debug info and symbol tablesImpact
The csi-livenessprobe image (310 MB) contains one unstripped Go binary:
livenessprobe(26.9 MB)Stripping typically reduces Go binary size by 20-30%, reducing container image pull time during node scale-up.
Test plan
Summary by CodeRabbit