Inherent code performance advantages of D over C?

Marco Leise Marco.Leise at gmx.de
Sun Dec 8 00:24:19 PST 2013


Am Sun, 08 Dec 2013 05:19:53 +0100
schrieb "Jason den Dulk" <public2 at jasondendulk.com>:

> One think I have discovered is that Phobos introduces "junk code" 
> into executables. One time I did an experiment. I copied the bits 
> of Phobos that my program used into a separate file and imported 
> that instead of the Phobos modules. The resultant executable was 
> half the size (using -release, -inline, -O and "strip" in both 
> cases). For some reason, Phobos was adding over 250KB of junk 
> code that strip could not get rid of.
> 
> Regards
> Jason

Strip doesn't remove dead code, but sections in the executable
that aren't required for running the program, like symbol
names or debugging information. That said all code is merged
into a single .text section by the linker and cannot be tangled
by strip at all.

To remove unreferenced functions, use:
gdc -ffunction-sections -Wl,--gc-sections
That will create a single section for every function (instead
of one section per module as far as I understand it) and tell
the linker to remove any section that is not referenced.

-- 
Marco



More information about the Digitalmars-d mailing list