What can be done to reduce executable size?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Dec 16 09:45:42 PST 2011


On 12/16/11 3:49 AM, Jonathan M Davis wrote:
> On Friday, December 16, 2011 02:38:09 Andrei Alexandrescu wrote:
>> On 12/16/11 1:12 AM, Jonathan M Davis wrote:
>>> Simply making it so that std.file is only imported in std.stdio with
>>> version(unittest) cut off _that_ much?
>>
>> Yah, but the matter is more complex. The issue is that std.file pulls
>> std.datetime, which (a) has static this() code, and (b) pulls core.time,
>> which in turn has static this() code.
>>
>> The issue with that is as follows. Any file that transitively imports a
>> module with constructors will have its own module info generated. When
>> that happens, all vtables in that module will be instantiated, so all
>> methods will be linked in. That in turn causes all functions they call
>> to also be linked in.
>>
>> That's why many programs using std are large.
>>
>> We can attack this in two ways:
>>
>> 1. Revise and reduce all static this() uses in phobos and druntime;
>>
>> 2. Improve the compiler to do minimal linking when static this() does
>> come about.
>
> Well, both std.datetime and core.time need static this() and can't not have
> it.

I am pretty sure they don't need static this(). Only last night I 
removed static this() from core.time.

Andrei




More information about the Digitalmars-d mailing list