Big problem with Small programs
Sean Kelly
sean at f4.ca
Tue Jan 23 12:03:38 PST 2007
Walter Bright wrote:
> kris wrote:
>> I have a helloworld.d program. I compile it on both Win32 and on
>> linux. On linux, the executable is 72KB whereas on Win32 it is 141KB.
>> Why is this?
>>
>> Turns out that D programs importing comprehensive Win32 D headers will
>> wind up with executable space occupied for *all* constants and *all*
>> struct initializers for the darned Win32 decls; where none of them are
>> actually used.
>>
>> That amounts to ~70KB of junk in the executable -- almost a full 100%
>> increase in size beyond what it should be.
>>
>> Does OptLink remove this? I've had no success with it. Walter? Can you
>> help with this?
>
> Try using enums instead of const variables, they don't take up any space
> in the object file.
For reference, the "hello world" app test was compiled with Bud, which
basically just recursively compiled all .d files and links the objects
together. However, I just tried creating a library out of the Win32
modules and renamed them to .di files to keep Bud from building them,
and the resulting app was 90k instead of 144k. I don't suppose you can
explain how linking a lib and linking individual object files can have
such glaringly different effects? I'm going to try a manual build
without Bud and see if the app is 144k now too.
Sean
More information about the Digitalmars-d
mailing list