rt_init, rt_term and _initCount

Rainer Schuetze via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 22 00:12:48 PDT 2016



On 22.10.2016 01:21, Benjamin Thaut wrote:
> On Friday, 21 October 2016 at 19:40:52 UTC, Rainer Schuetze wrote:
>>
>> The wrapper around main in the executable should work just as any
>> DLLs' DllMain, i.e. it should register/unregister its own data
>> segments with the GC and run its shared and TLS module
>> constructors/decoontructors. Everything else should be handled by the
>> druntime DLL.
>
> Yes, I also considered that option. The problem with that is, that
> druntime deinit joins alls threads before running the shared module
> dtors. If the main executable behaves exactly like the dlls do this
> joining of threads would be lost and different from the behavior of a
> fully statical linked executable.

The main executable wrapper could add this join-all if it is considered 
useful. I'm not really convinced: If there are actually threads still 
running on program termination, it's likely they need some signal to 
stop. In C++ that is usually fired in the shared destructor of some 
global. This is currently not possible in D as these are run after joinAll.

Please also consider that the main executable might not know about DLLs 
being written in D. In that case all termination must be triggered by 
the druntime DLL.


More information about the Digitalmars-d mailing list