Why D program executable is big almost to 9+ MiB?

1k Views Asked by At

I found a simple Hello World program D executable is big size, about 9.2 MiB. I'm using gdc-4.8 compiler. Is this a feature or some kind of bug?

Thanks for all responses!

1

There are 1 best solutions below

5
On BEST ANSWER

I guess you are statically linking against the debug versions of the standard libraries.

First, the size of the executable depends on the use of dynamic vs. static linking of the standard libraries. If you statically link your executable then debug information is another contributor to size.

In numbers (I don't have gdc at hand):

  • compiled with ldc2, statically linked: 315KiB
  • compiled with ldc2 with debug info, statically linked: 2.9MiB
  • compiled with dmd, dynamically linked: 51KiB
  • compiled with dmd with debug info, statically linked: 77KiB

As far as I know gdc does not use/support -gc-section which also contributes to executable size.