how to make D program footprint smaller ?

russhy russhy at gmail.com
Thu Jul 8 11:18:26 UTC 2021


On Thursday, 8 July 2021 at 10:01:33 UTC, dangbinghoo wrote:
> I have tried to add
>
> ```
>   "dflags": ["--link-defaultlib-shared"],
>   "lflags": ["--as-needed"],
> ```
>
> to dub.json, and my compiler is ldc2, with 800 loc program used 
> `hibernated` and `asdf` package. it compiled to 27MB binary not 
> stripped and even 4MB size after stripped. (When compiled to 
> ARM, the binary is 3.6MB which is a little bit smaller, but 
> link flags won't opt. this either!)
>
> I tried the link flags above, but it seems that the stripped 
> binary is in some size.
>
> any suggestions for optimizing this?
>
>
> thanks!
> ---
> dbh

try:

```
"dflags-ldc": [
     "-linkonce-templates",
     "--Oz"
],
```

but yeah
Are you using lot of templates in your code? buffer as global?

my 20k LOC game's exe is only just 1.46mb (on windows), but 
that's because i don't use std at all


More information about the Digitalmars-d-learn mailing list