rhx/SwiftHelloGtk

Generated executable file size is too big

Opened this issue · 2 comments

When I build the example running ./build.sh, the generated executable .build/debug/HelloGtk is about 230MB in file size, which seems excessive for a simple application that only shows a window containing a text label.

If I strip the executable with $ strip HelloGtk, the file size gets reduced to 161MB, which is still too big.

Why are the binary executables so big? Is there any way to prevent this?

rhx commented

The executable gets a bit smaller if you build an optimised release version, i.e., using

./distclean.sh
./build.sh -c release

This reduces the size to about 59MB for me. At the moment, the build scripts link all of the Swift wrappers for GLib, GTK, etc. into the executable. This is mainly because gtk, gir2swift, SwiftGtk, and the Swift compiler itself get updated very frequently. If you don't want a self-contained app, it should be possible to build and install shared binaries of the Swift Gtk modules and then link against those (I haven't investigated this yet, though).

This reduces the size to about 59MB for me

I think 59MB is good enough. At least it´s a much more convenient file size than 230MB.

it should be possible to build and install shared binaries of the Swift Gtk modules

Maybe a shared library could be logical next step once more applications get developed using SwiftGtk.

At the moment, the build scripts link all of the Swift wrappers for GLib, GTK, etc. into the executable.

Would it be possible to somehow strip/exclude all the unused Swift wrappers from the executable, in such a way that only functions/wrappers directly called from the swift application gets included into the binary??