How to stop DMD from exploding the executable file size?

ryuukk_ ryuukk.dev at gmail.com
Sat Sep 3 00:49:36 UTC 2022


On Friday, 2 September 2022 at 17:53:51 UTC, max haughton wrote:
> On Tuesday, 30 August 2022 at 22:51:46 UTC, ryuukk_ wrote:
>> Having this simple code makes the executable gigantic!
>>
>> ```D
>> struct Big
>> {
>>     int[1024 * 1024] big = 0;
>> }
>>
>> Big big;
>> ```
>>
>> Only with DMD, LDC produces a tiny executable
>>
>> Is there a flag available to fix this behavior? it's not 
>> sustainable
>
> You really shouldn't have structs this big unless absolutely 
> necessary.
>
> The thing being elided is the initializer and pointer bitmap 
> for the runtime to use.

My use case should not makes us blind about the issue DMD is 
having

I tested with both C and Zig, and they both produce small 
executable

If DMD can do it on linux, there is no reason it can't do it on 
windows, if LDC can do it for both

I want to promote D, i can't promote D if i tell people "yeah but 
X, Y, Z, then you should go with X, when Z, and when stars are 
aligned, maybe"

It just feels bad; and the list of things that feels bad starts 
to stack up to a point it becomes sad


More information about the Digitalmars-d mailing list