[Issue 2254] Size of executable almost triples

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 22 13:28:53 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2254



--- Comment #10 from torhu at yahoo.com 2009-11-22 13:28:52 PST ---
Since I assume this is a long-term bug now that wrapping up D 2 has the main
focus, I'll post some tips and tricks.

If you are using D 1, you'll probably have better luck with Tango.  A hello
world program built with Tango is about half the size.  If you really want to
use phobos you can custom build it, see comment #1 and onwards.

I wonder what platform you're on if saving a few hundred kB of disk space is
important, though.

When that's said, if you use other libraries written in D, make sure you build
in one of two ways:

A) Build everything in one go, don't use .lib files.  Except for tango/phobos
and C libs.  This means using a build tool or script that hands all files to
dmd at once.  Very fast and simple build process.  Supported by
xfbuild/bud/dsss build tools.

B) Build .lib files of your library dependencies first, by handing one file at
a time to dmd, then running lib.exe to create a .lib file.  Supported by DSSS,
and possibly xfbuild.  Or you could use a makefile or whatever you prefer.

The *WRONG* way to build is as follows:

C) Build .lib files by handing all files to dmd at once.  Then build your app
(any way you like) and link to those .lib files.  Unless your exe uses
absolutely everyting defined in those libs, this causes a bloated executable. 
You end up getting more then a wanted, because this way of building causes fake
dependencies between modules.


If you want try A, I suggest having a look at xfbuild, it's very fast and
flexible.  Ask in the newsgroup D.learn if you need help with setting it all
up.
http://bitbucket.org/h3r3tic/xfbuild/wiki/Home

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list