Thread overview | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
September 20, 2013 compiled code file size | ||||
---|---|---|---|---|
| ||||
I'm re-visiting the D language. I've compared the file sizes of 2 executables - 1 is compiled C code using gcc; the other is D code using dmd. helloWorld.d => helloWorld.exe = 146,972 bytes ex1hello.c => ex1-hello.exe = 5,661 bytes Why such a huge difference??? Duke |
September 20, 2013 Re: compiled code file size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Duke Normandin | DMD likes the size. When compiling, compiler may use GBs of RAM. In resulting executable there is no dead/unused code elimination. |
September 20, 2013 Re: compiled code file size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | On Friday, 20 September 2013 at 16:35:40 UTC, Temtaime wrote:
> In resulting executable there is no dead/unused code elimination.
Not true.
|
September 20, 2013 Re: compiled code file size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | On Fri, 20 Sep 2013 18:35:39 +0200, Temtaime wrote: > DMD likes the size. > When compiling, compiler may use GBs of RAM. > In resulting executable there is no dead/unused code elimination. http://imgur.com/W5AMy0P |
September 20, 2013 Re: compiled code file size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | Why? I have a large project. If i replace main with "void main() {}" the size is still 26 MB in debug. |
September 20, 2013 Re: compiled code file size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Duke Normandin | On Friday, 20 September 2013 at 16:20:34 UTC, Duke Normandin wrote:
> Why such a huge difference???
The D program carries its additional D runtime library code with it, whereas the C program only depends on libraries provided by the operating system, and thus it doesn't have to include it in the exe.
|
September 20, 2013 Re: compiled code file size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Duke Normandin | On Friday, 20 September 2013 at 16:20:34 UTC, Duke Normandin wrote:
> I'm re-visiting the D language. I've compared the file sizes of 2 executables - 1 is compiled C code using gcc; the other is D code using dmd.
>
> helloWorld.d => helloWorld.exe = 146,972 bytes
> ex1hello.c => ex1-hello.exe = 5,661 bytes
>
> Why such a huge difference???
>
> Duke
You are doing it wrong.
```
$ gcc hello.c; ls -lah a.out
-rwxr-xr-x 1 dicebot users 4.9K Sep 20 18:47 a.out
```
vs
```
$ gcc -static hello.c; ls -lah a.out
-rwxr-xr-x 1 dicebot users 717K Sep 20 18:48 a.out
```
(C standard library is dynamically linked by default)
So actual relative difference is about 2x - quite big but not as huge. It mostly comes from additional D runtime stuff.
|
September 20, 2013 Re: compiled code file size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | C/C++ applications also carries on its runtime(mingwm10, msvc's redist, for example). If compiled with static runtime, msvc's hello world application uses about 40 KB. |
September 20, 2013 Re: compiled code file size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | On Friday, 20 September 2013 at 16:44:30 UTC, Temtaime wrote:
> Why? I have a large project.
> If i replace main with "void main() {}" the size is still 26 MB in debug.
Could be due to things like static module constructors or typeinfos. There *are* problems with things getting intertwined and not being considered dead by the linker, but it does try.
The proof of it is hello world being 150 KB instead of the 6 MB or so it would be if it carried all of the dead code from phobos too.
|
September 20, 2013 Re: compiled code file size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Friday, 20 September 2013 at 16:37:19 UTC, Adam D. Ruppe wrote:
> On Friday, 20 September 2013 at 16:35:40 UTC, Temtaime wrote:
>> In resulting executable there is no dead/unused code elimination.
>
> Not true.
Well, it is _mostly_ true. There is an elimination of unused code inside the function bodies during the code gen, but no unused data/code symbol elimination - and it actually can't be done safely right now by language design.
|
Copyright © 1999-2021 by the D Language Foundation