On Friday, 9 July 2021 at 01:51:55 UTC, dangbinghoo wrote:
On Thursday, 8 July 2021 at 11:18:26 UTC, russhy wrote:
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
thanks for your suggestion. I just tried that flags but it
seems not working for me.
and I just use the `nm` tool with `x86_64-pc-linux-gnu-gcc-nm
--size-sort myprg` to get all symbols in the binary, it showed
up that. the executable linked with tons of vibe.d symbols.
the situation is that: my program relies on another source
library which depends on vibe.d, the problem is that the source
library is just a set of various tools, my program is using a
little sub of that library, which has nothing imported with
vibe.d.
BUT: the final program compiled with dub seems simply linked
all symbols of the sourcelibrary to the executable.
So, it there any flags that opt. this like gcc? just to link
only needed symbols?
thanks!
dbh.
I tried to delete the dependency of `vibe.d` and `hibernated`
package(just an experiment, I finally need them in other
process-executables). it shows up that deleting `vibe.d`
decreases the size to 1.8MB (stripped) and deleting `vibe.d` and
`hibernated` result-in a size of only 530KB(stripped), this is
the size it should be.
I don't know this is related to dub or LDC itself, but obviously,
THIS IS A REAL PROBLEM about D compiling.
as questioned in the previous thread, I need to find out
something like `--as-needed` options available for D.
thanks!