www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - whats happening to my binary file size?

reply "Israel" <tl12000 live.com> writes:
I wasnt paying any attention to the file size of my binaries when
i started using D.

My first program is simple and compiles at 486kb, which honestly,
is kind of absurd but anyways, after i start adding other imports
it ran all the way up to 4.5mb.

what i want to ask is, what exactly is happening to my binary
when all i do is import various modules?
Aug 26 2014
next sibling parent reply "Messenger" <dont shoot.me> writes:
On Tuesday, 26 August 2014 at 23:36:44 UTC, Israel wrote:
 I wasnt paying any attention to the file size of my binaries 
 when
 i started using D.

 My first program is simple and compiles at 486kb, which 
 honestly,
 is kind of absurd but anyways, after i start adding other 
 imports
 it ran all the way up to 4.5mb.

 what i want to ask is, what exactly is happening to my binary
 when all i do is import various modules?
Conjecture: your binary has its imports statically linked in, and your linker doesn't remove unused code (--gc-sections). https://issues.dlang.org/show_bug.cgi?id=879
Aug 26 2014
parent reply "Israel" <tl12000 live.com> writes:
On Wednesday, 27 August 2014 at 01:41:51 UTC, Messenger wrote:
 On Tuesday, 26 August 2014 at 23:36:44 UTC, Israel wrote:
 I wasnt paying any attention to the file size of my binaries 
 when
 i started using D.

 My first program is simple and compiles at 486kb, which 
 honestly,
 is kind of absurd but anyways, after i start adding other 
 imports
 it ran all the way up to 4.5mb.

 what i want to ask is, what exactly is happening to my binary
 when all i do is import various modules?
Conjecture: your binary has its imports statically linked in, and your linker doesn't remove unused code (--gc-sections). https://issues.dlang.org/show_bug.cgi?id=879
I see, thanks man. From what i understand is that this is a "unintended" "feature" rather than a direct bug in order to make my life easier? I know that object files are stored in .a libraries but all this seems too advanced for me to understand...
Aug 26 2014
parent reply "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> writes:
On Wednesday, 27 August 2014 at 02:16:37 UTC, Israel wrote:
 On Wednesday, 27 August 2014 at 01:41:51 UTC, Messenger wrote:
 Conjecture: your binary has its imports statically linked in, 
 and your linker doesn't remove unused code (--gc-sections).

 https://issues.dlang.org/show_bug.cgi?id=879
I see, thanks man. From what i understand is that this is a "unintended" "feature" rather than a direct bug in order to make my life easier? I know that object files are stored in .a libraries but all this seems too advanced for me to understand...
You could try using LDC. The latest version 0.14.0 already uses --gc-sections automatically. (But it is based on DMD 2.065, so you cannot (yet) use all of the newest features like nogc that are in DMD 2.066.)
Aug 27 2014
parent reply "Israel" <tl12000 live.com> writes:
On Wednesday, 27 August 2014 at 09:23:57 UTC, Marc Schütz wrote:
 On Wednesday, 27 August 2014 at 02:16:37 UTC, Israel wrote:
 On Wednesday, 27 August 2014 at 01:41:51 UTC, Messenger wrote:
 Conjecture: your binary has its imports statically linked in, 
 and your linker doesn't remove unused code (--gc-sections).

 https://issues.dlang.org/show_bug.cgi?id=879
I see, thanks man. From what i understand is that this is a "unintended" "feature" rather than a direct bug in order to make my life easier? I know that object files are stored in .a libraries but all this seems too advanced for me to understand...
You could try using LDC. The latest version 0.14.0 already uses --gc-sections automatically. (But it is based on DMD 2.065, so you cannot (yet) use all of the newest features like nogc that are in DMD 2.066.)
Yea i saw that thread in the LDC section and thats actually pretty cool that he produced an 88kb file. Im not too worried about the GC since ive been working with it my entire time from beginner till now. But, how would i configure dub and my dub.json to automatically use those LDC switches if it isnt automatically built into dub?
Aug 27 2014
next sibling parent "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> writes:
On Wednesday, 27 August 2014 at 16:24:23 UTC, Israel wrote:
 On Wednesday, 27 August 2014 at 09:23:57 UTC, Marc Schütz wrote:
 You could try using LDC. The latest version 0.14.0 already 
 uses --gc-sections automatically. (But it is based on DMD 
 2.065, so you cannot (yet) use all of the newest features like 
  nogc that are in DMD 2.066.)
Yea i saw that thread in the LDC section and thats actually pretty cool that he produced an 88kb file. Im not too worried about the GC since ive been working with it my entire time from beginner till now. But, how would i configure dub and my dub.json to automatically use those LDC switches if it isnt automatically built into dub?
I'm not too familiar with DUB, so I'll pass on this one, but a clarification: --gc-sections isn't referring to D's builtin GC, but tells the linker to remove "garbage sections" in the executable, i.e. those that aren't referenced from anywhere. Apart from the name (and that the underlying ideas are similar), those two have nothing to do with each other.
Aug 27 2014
prev sibling parent Mike Parker <aldacron gmail.com> writes:
On 8/28/2014 1:24 AM, Israel wrote:
 On Wednesday, 27 August 2014 at 09:23:57 UTC, Marc Schütz wrote:
 But, how would i configure dub and my dub.json to automatically
 use those LDC switches if it isnt automatically built into dub?
You can pass compiler-specific flags by adding a "dflags" entry to your dub.json. Likewise, "lflags" is for the linker. See [1]. [1] http://code.dlang.org/package-format#build-settings --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
Aug 27 2014
prev sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 26 August 2014 at 23:36:44 UTC, Israel wrote:
 I wasnt paying any attention to the file size of my binaries 
 when
 i started using D.

 My first program is simple and compiles at 486kb, which 
 honestly,
 is kind of absurd but anyways, after i start adding other 
 imports
 it ran all the way up to 4.5mb.

 what i want to ask is, what exactly is happening to my binary
 when all i do is import various modules?
You can see what's taking up space by upload a .map file here: http://thecybershadow.net/d/mapview/
Aug 26 2014