www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - [dub] Size of executable

reply "Chris" <wendlec tcd.ie> writes:
[Maybe this has been asked before.]

I usually use dub to create and build projects. I built one of 
the projects with dub and then by hand with dmd[1] passing all 
the files etc. Turned out that the executable built with dub was 
1.4 MB whereas the one built by hand was only 807 kB. Why is that?

Another thing, I've spotted a typo in dub's[2] command line help:

clean [<package>]     Removes intermetiate build files and cached 
build
                         results

It should read "intermediate" (with "d"), else it sounds like the 
Goths in Asterix :-)



[1] dmd 2.066.0
[2] DUB version 0.9.22, built on Sep 16 2014
Nov 27 2014
next sibling parent reply "Gary Willoughby" <dev nomad.so> writes:
On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote:
 I usually use dub to create and build projects. I built one of 
 the projects with dub and then by hand with dmd[1] passing all 
 the files etc. Turned out that the executable built with dub 
 was 1.4 MB whereas the one built by hand was only 807 kB. Why 
 is that?
dub compiles and links every file in the source folder whether it's used or not. Whereas with dmd or rdmd you only compile and link the files you actually use.
Nov 27 2014
parent reply "Chris" <wendlec tcd.ie> writes:
On Thursday, 27 November 2014 at 12:29:03 UTC, Gary Willoughby 
wrote:
 On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote:
 I usually use dub to create and build projects. I built one of 
 the projects with dub and then by hand with dmd[1] passing all 
 the files etc. Turned out that the executable built with dub 
 was 1.4 MB whereas the one built by hand was only 807 kB. Why 
 is that?
dub compiles and links every file in the source folder whether it's used or not. Whereas with dmd or rdmd you only compile and link the files you actually use.
I compiled the exact same files. I excluded those I didn't need in the dub configuration like so: "excludedSourceFiles": [...] But dub's executable is bigger.
Nov 27 2014
parent reply "CraigDillabaugh" <craig.dillabaugh gmail.com> writes:
On Thursday, 27 November 2014 at 13:56:19 UTC, Chris wrote:
 On Thursday, 27 November 2014 at 12:29:03 UTC, Gary Willoughby 
 wrote:
 On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote:
 I usually use dub to create and build projects. I built one 
 of the projects with dub and then by hand with dmd[1] passing 
 all the files etc. Turned out that the executable built with 
 dub was 1.4 MB whereas the one built by hand was only 807 kB. 
 Why is that?
dub compiles and links every file in the source folder whether it's used or not. Whereas with dmd or rdmd you only compile and link the files you actually use.
I compiled the exact same files. I excluded those I didn't need in the dub configuration like so: "excludedSourceFiles": [...] But dub's executable is bigger.
When you build with dub it should print out (if I remember correctly, its been a little while) the command it uses to build your code. Is there any difference between that command and your 'by hand' version?
Nov 27 2014
parent reply "Chris" <wendlec tcd.ie> writes:
On Thursday, 27 November 2014 at 13:59:23 UTC, CraigDillabaugh 
wrote:
 On Thursday, 27 November 2014 at 13:56:19 UTC, Chris wrote:
 On Thursday, 27 November 2014 at 12:29:03 UTC, Gary Willoughby 
 wrote:
 On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote:
 I usually use dub to create and build projects. I built one 
 of the projects with dub and then by hand with dmd[1] 
 passing all the files etc. Turned out that the executable 
 built with dub was 1.4 MB whereas the one built by hand was 
 only 807 kB. Why is that?
dub compiles and links every file in the source folder whether it's used or not. Whereas with dmd or rdmd you only compile and link the files you actually use.
I compiled the exact same files. I excluded those I didn't need in the dub configuration like so: "excludedSourceFiles": [...] But dub's executable is bigger.
When you build with dub it should print out (if I remember correctly, its been a little while) the command it uses to build your code. Is there any difference between that command and your 'by hand' version?
dub says: Compiling using dmd... Linking... I have the exact same setting, I think. I don't build for release with either method. dmd file1.d file2.d file3.d ... (dub compiles the same files, no release build)
Nov 27 2014
next sibling parent reply "CraigDillabaugh" <craig.dillabaugh gmail.com> writes:
On Thursday, 27 November 2014 at 14:14:50 UTC, Chris wrote:
 On Thursday, 27 November 2014 at 13:59:23 UTC, CraigDillabaugh 
 wrote:
 On Thursday, 27 November 2014 at 13:56:19 UTC, Chris wrote:
 On Thursday, 27 November 2014 at 12:29:03 UTC, Gary 
 Willoughby wrote:
 On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote:
 I usually use dub to create and build projects. I built one 
 of the projects with dub and then by hand with dmd[1] 
 passing all the files etc. Turned out that the executable 
 built with dub was 1.4 MB whereas the one built by hand was 
 only 807 kB. Why is that?
dub compiles and links every file in the source folder whether it's used or not. Whereas with dmd or rdmd you only compile and link the files you actually use.
I compiled the exact same files. I excluded those I didn't need in the dub configuration like so: "excludedSourceFiles": [...] But dub's executable is bigger.
When you build with dub it should print out (if I remember correctly, its been a little while) the command it uses to build your code. Is there any difference between that command and your 'by hand' version?
dub says: Compiling using dmd... Linking... I have the exact same setting, I think. I don't build for release with either method. dmd file1.d file2.d file3.d ... (dub compiles the same files, no release build)
I am sure there is some way to get it to print out exactly what it is doing. I've done it before when trying to figure out some compilation issues ... unfortunately it was a while ago and the machine I am at now doesn't have dub (or D for that matter) installed. Maybe you need to give the the dub -v (--verbose) option. Type 'dub help' to check - again I can't do that right here.
Nov 27 2014
parent "Chris" <wendlec tcd.ie> writes:
On Thursday, 27 November 2014 at 17:08:00 UTC, CraigDillabaugh
wrote:
 On Thursday, 27 November 2014 at 14:14:50 UTC, Chris wrote:
 On Thursday, 27 November 2014 at 13:59:23 UTC, CraigDillabaugh 
 wrote:
 On Thursday, 27 November 2014 at 13:56:19 UTC, Chris wrote:
 On Thursday, 27 November 2014 at 12:29:03 UTC, Gary 
 Willoughby wrote:
 On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote:
 I usually use dub to create and build projects. I built 
 one of the projects with dub and then by hand with dmd[1] 
 passing all the files etc. Turned out that the executable 
 built with dub was 1.4 MB whereas the one built by hand 
 was only 807 kB. Why is that?
dub compiles and links every file in the source folder whether it's used or not. Whereas with dmd or rdmd you only compile and link the files you actually use.
I compiled the exact same files. I excluded those I didn't need in the dub configuration like so: "excludedSourceFiles": [...] But dub's executable is bigger.
When you build with dub it should print out (if I remember correctly, its been a little while) the command it uses to build your code. Is there any difference between that command and your 'by hand' version?
dub says: Compiling using dmd... Linking... I have the exact same setting, I think. I don't build for release with either method. dmd file1.d file2.d file3.d ... (dub compiles the same files, no release build)
I am sure there is some way to get it to print out exactly what it is doing. I've done it before when trying to figure out some compilation issues ... unfortunately it was a while ago and the machine I am at now doesn't have dub (or D for that matter) installed. Maybe you need to give the the dub -v (--verbose) option. Type 'dub help' to check - again I can't do that right here.
Nope, --verbose doesn't tell me anything useful in this regard. Only stuff like Refreshing local packages (refresh existing: true)... Looking for local package map at /var/lib/dub/packages/local-packages.json ... I added a lot to the project yesterday, and still, the "pure" dmd-compiled version is 1.9 MB whereas the dub-compiled version is 3.5 MB. There is absolutely nothing in dub.json that links to anything else. Now, I've just created an empty test project with $ dub init size The executable is 940.5 kB Then $ dmd source/app.d -ofother The executable is 548.0 kB Try it yourself.
Nov 28 2014
prev sibling parent Mike Wey <mike-wey example.com> writes:
On 11/27/2014 03:14 PM, Chris wrote:
  dub says:

 Compiling using dmd...
 Linking...

 I have the exact same setting, I think. I don't build for release with
 either method.

 dmd file1.d file2.d file3.d ...

 (dub compiles the same files, no release build)
dub builds with --debug by default. -- Mike Wey
Nov 27 2014
prev sibling parent "Kapps" <opantm2+spam gmail.com> writes:
On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote:
 [Maybe this has been asked before.]

 I usually use dub to create and build projects. I built one of 
 the projects with dub and then by hand with dmd[1] passing all 
 the files etc. Turned out that the executable built with dub 
 was 1.4 MB whereas the one built by hand was only 807 kB. Why 
 is that?

 Another thing, I've spotted a typo in dub's[2] command line 
 help:

 clean [<package>]     Removes intermetiate build files and 
 cached build
                         results

 It should read "intermediate" (with "d"), else it sounds like 
 the Goths in Asterix :-)



 [1] dmd 2.066.0
 [2] DUB version 0.9.22, built on Sep 16 2014
Dub builds with debug symbols by default. Using dub build -v will tell you how it invokes DMD.
Nov 28 2014