Small program producing binary with large filesize
Seb
seb at wilzba.ch
Tue Jul 31 21:11:32 UTC 2018
On Tuesday, 31 July 2018 at 15:19:19 UTC, Dan Barbarito wrote:
> Hi all,
>
> I am starting to write a command line tool. So far it is a
> small (feature-wise) program but the file size is scaring me.
> It's already 13 megabytes, but I would expect it to be much
> smaller. Is it because I'm using 3 libraries so far? The
> libraries are: mir, vibe.d, and d2sqlite3. Would using these
> libraries be causing this file size?
>
> The code can be found here
> (http://fossil.barbarito.me/finbot/zip/finbot.zip), if anyone
> wants to take a look. I am simply running "dub build" to build
> the binary. I tried running "dub build --build=release" but
> that didn't effect the file size too much.
>
> Thanks!
If you use LDC, release build and their full LTO (-flto=full),
the resulting binary should get smaller.
DFLAGS="-flto=full" dub build --compiler=ldc -b release
As an example, dlang-tour is 53M in debug build with DMD, but
with LTO + release + ldc it gets down to 6.2M.
You also get a smaller build, if instead of using all of Vibe.d,
you only use the subset of components you actually use, e.g.
dependency "vibe-d:web" version="~>0.8"
More information about the Digitalmars-d-learn
mailing list