How to stop DMD from exploding the executable file size?

ryuukk_ ryuukk.dev at gmail.com
Tue Aug 30 23:09:55 UTC 2022


On Tuesday, 30 August 2022 at 23:05:16 UTC, H. S. Teoh wrote:
> On Tue, Aug 30, 2022 at 10:51:46PM +0000, ryuukk_ via 
> Digitalmars-d 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
>
> Which version of dmd are you using? I tried to compile the 
> above code with 2.098 (old git master) and the total executable 
> size is only 900KB.
>
> I remember about a year or two ago there was a bug where dmd 
> would generate 1024 * 1024 store instructions to initialize the 
> array, but I just checked the disassembly, it's now a rep stos, 
> which is very small.
>
>
> T

dmd --version prints: `DMD32 D Compiler v2.100.1`

It's on Windows, maybe that problem is windows specific?


More information about the Digitalmars-d mailing list