-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hack/build: Strip compiled binaries #1158
Conversation
4490fb7
to
0ee413d
Compare
Docs for these settings in [1]. With this change, our compiled Linux binary (without libvirt) drops from ~240 MB to ~130 MB. Alex was concerned about panic support, but with: $ git diff -U1 diff --git a/cmd/openshift-install/main.go b/cmd/openshift-install/main.go index 37f7f96..fbd9889 100644 --- a/cmd/openshift-install/main.go +++ b/cmd/openshift-install/main.go @@ -69,2 +69,4 @@ func newRootCmd() *cobra.Command { func runRootCmd(cmd *cobra.Command, args []string) { + panic("testing, testing") + logrus.SetOutput(ioutil.Discard) panics still produce useful tracebacks: $ openshift-install create install-config panic: testing, testing goroutine 1 [running]: main.runRootCmd(0x8575360, 0x85d4390, 0x0, 0x0) /.../go/src/github.com/openshift/installer/cmd/openshift-install/main.go:70 +0x39 github.com/openshift/installer/vendor/github.com/spf13/cobra.(*Command).execute(0x8575360, 0x85d4390, 0x0, 0x0, 0x8575360, 0x85d4390) /.../go/src/github.com/openshift/installer/vendor/github.com/spf13/cobra/command.go:746 +0x237 github.com/openshift/installer/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc42044f180, 0x0, 0xc4209cc500, 0xc42044f2d0) /.../go/src/github.com/openshift/installer/vendor/github.com/spf13/cobra/command.go:852 +0x30a github.com/openshift/installer/vendor/github.com/spf13/cobra.(*Command).Execute(0xc42044f180, 0xc420983ec0, 0x1) /.../go/src/github.com/openshift/installer/vendor/github.com/spf13/cobra/command.go:800 +0x2b main.installerMain() /.../go/src/github.com/openshift/installer/cmd/openshift-install/main.go:50 +0x132 main.main() /.../go/src/github.com/openshift/installer/cmd/openshift-install/main.go:34 +0x39 which looks fine. I've left dev builds unstripped, because [2]: Generally speaking we do not recommend stripping debug info (it's useful, after all)... There's also some stripping discussion in [3]. [1]: https://golang.org/cmd/link/ [2]: golang/go#6853 (comment) [3]: golang/go#19226 Suggested-by: Pedro Jose Amoedo Martinez
Update, this is probably using Go's built-in linker, so I've updated my commit message and started setting |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: crawford, wking The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I'm not sure how portable this is, but for the GNU linker this is:
With this change, our compiled Linux binary (without libvirt) drops from ~240 MB to ~130 MB. Alex was concerned about panic support, but with:
panics still produce useful tracebacks:
which looks fine.
Suggested-by: @pamoedom