Thursday, October 18, 2012

goupx can shrink Go language binaries

By Vasudev Ram

I have been using the Go language lately, and noticed that the binaries it creates when you compile your source code can be large, since they statically link everything needed to run your Go program. (A simple Hello World program binary can be on the order of magnitude of 1 MB in size.)

(Some of the posts I checked say that Go supports dynamic linking via gccgo, a front-end to the gcc compiler. Not sure right now what the difference is between dynamic linking and dynamic loading (of libraries, as is done with C. Need to check.)

goupx is a possible solution to this issue. It seems to be based on UPX (Ultimate Packer for eXecutables), a utility for compressing executable files.

I had come across UPX some years ago, and tried it out a bit then. Today I again checked the UPX web site and was interested to see that it supports compressing executables for several platforms, including Linux, Mac OS X and others, not just Windows.

From the goupx site:

[ Resulting filesizes are typically 25% of the original go executable. Your mileage my vary. ]

goupx seen via this comment on proggit (part of a thread about learning Go).

- Vasudev Ram - Dancing Bison Enterprises

No comments: