How to stop DMD from exploding the executable file size?

Bastiaan Veelo Bastiaan at Veelo.net
Fri Sep 2 12:53:04 UTC 2022


On Thursday, 1 September 2022 at 22:31:50 UTC, H. S. Teoh wrote:
> On Thu, Sep 01, 2022 at 10:15:03PM +0000, solidstate1991 via 
> Digitalmars-d wrote:
>> On Tuesday, 30 August 2022 at 22:58:44 UTC, ryuukk_ wrote:
>> > ```
>> > $ ldc2 -m64 app.d
>> > $ ll
>> > total 4545
>> > -rw-r--r-- 1 ryuukk 197121      69 Aug 31 00:57 app.d
>> > -rwxr-xr-x 1 ryuukk 197121  453120 Aug 31 00:57 app.exe*
>> > -rw-r--r-- 1 ryuukk 197121 4195865 Aug 31 00:57 app.obj
>> > ```
>> > 
>> > ```
>> > $ dmd -m64 app.d
>> > $ ll
>> > total 8617
>> > -rw-r--r-- 1 ryuukk 197121      69 Aug 31 00:57 app.d
>> > -rwxr-xr-x 1 ryuukk 197121 4623872 Aug 31 00:57 app.exe*
>> > -rw-r--r-- 1 ryuukk 197121 4196322 Aug 31 00:57 app.obj
>> > ```
>> 
>> LDC has way better optimization features, so it's kinda 
>> expected.
>
> Yep.  LDC is my go-to compiler for release builds.  I use dmd 
> for development because the turnaround time is faster, but I 
> also don't care about performance/executable size when using 
> dmd.  For release builds when I *do* care about those things, I 
> use LDC; dmd isn't even on my radar for that.
>
>
> T

LDC is great, but note that the object files are equally large 
for both compilers. Apparently it is the linker that should be 
attributed the size reduction. Which leads me to wonder what the 
main function looks like, because it might have removed the 
entire initialisation as dead code…

It would have been better if OP would have posted complete code.

— Bastiaan.


More information about the Digitalmars-d mailing list