Program size, linking matter, and static this()

Vladimir Panteleev vladimir at thecybershadow.net
Tue Dec 20 14:27:41 PST 2011


On Tuesday, 20 December 2011 at 14:01:04 UTC, Denis Shelomovskij 
wrote:
> Detailed description:
> GtkD is built using singe (gtk-one-obj.lib) or separate (one 
> per source file) object files (gtk-sep-obj.lib).
>
> Than main.d that imports gtk.Main is built using those 
> libraries.
>
> Than zeroCount utils is built and launched over resulting files:
> --------------------------------------------------
> Now let's calculate zero bytes counts:
> --------------------------------------------------
>  Zero bytes|     %|    Non-zero| Total bytes|        File
>     3628311| 21.56|    13202153|    16830464|gtk-one-obj.lib
>     1953124| 15.98|    10272924|    12226048|gtk-sep-obj.lib
>   127968798| 99.00|     1298430|   129267228|main-one-obj.exe
>      743821| 37.51|     1239183|     1983004|main-sep-obj.exe
> Done.
>
> So we have to use very slow per-file build to produce a good 
> (not 100 MiB) executable.
> No matter what *.exe is launched, its process allocates ~20MiB 
> of RAM (loaded Gtk dll-s).

I believe this is bug 2254:

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

The cause is the way DMD builds libraries. The old way of 
building libraries (using a librarian) does not create libraries 
that exhibit this problem when linked with an executable.


More information about the Digitalmars-d mailing list