Getting rid of global cdtors

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Jun 18 03:47:47 UTC 2020


On 6/17/20 11:00 PM, Timon Gehr wrote:
> On 18.06.20 04:02, Andrei Alexandrescu wrote:
>> On 6/14/20 2:53 PM, Andrei Alexandrescu wrote:
>>> Getting rid of static cdtors is a good goal for druntime and standard 
>>> library. Modules that need initialization should do so lazily upon 
>>> first use.
>>>
>>> I picked a low-hanging fruit in 
>>> https://github.com/dlang/phobos/pull/7529 - there is no need at all 
>>> to initialize and test pointers to function in Posix.
>>>
>>> Could a Windows engineer help with the Windows part? It's a bit more 
>>> involved - the pointers to functions should be initialized upon first 
>>> use in a Singleton manner, and atexit(WSACleanup) needs to be 
>>> inserted right after the call to WSAStartup.
>>
>> I needed to close that PR and it would be great if someone could pick 
>> it up. I don't have the time to set up a Windows platform. Would be 
>> glad to take a look over the PR if someone would like to adopt it.
>>
>> As I noted in the PR, eliminating static cdtors is key to lean and 
>> mean executables on a pay-as-you-go basis.
>>
> 
> What about this? https://dlang.org/library/object/object.factory.html
> ProtoObject?

Yah, that'd need to be looked at too.


More information about the Digitalmars-d mailing list