January 16, 2022 [Issue 22681] New: rt_moduleTlsCtor/Dtor() don't work with phobos dynamically linked | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22681 Issue ID: 22681 Summary: rt_moduleTlsCtor/Dtor() don't work with phobos dynamically linked Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: druntime Assignee: nobody@puremagic.com Reporter: duser@airmail.cc ``` __gshared int ctors, dtors; static this() { ctors++; } static ~this() { dtors++; } import core.thread; import core.stdc.stdio; void main() { ctors = 0; dtors = 0; createLowLevelThread({ scope(failure) assert(0); // satisfy nothrow thread_attachThis(); rt_moduleTlsCtor(); rt_moduleTlsDtor(); thread_detachThis(); }).joinLowLevelThread; printf("ctors %d dtors %d\n", ctors, dtors); assert(ctors == 1 && dtors == 1); } ``` with these commands, it works: % dmd -run tlstest.d % ldc2 -run tlstest.d with these commands, the constructor and destructor don't run: % dmd -defaultlib=phobos2 -run tlstest.d % dmd -L-lphobos2 -run tlstest.d % ldc2 --link-defaultlib-shared -run tlstest.d other things that do TLS initialization like `new Thread()` and `rt_init()` work normally -- |
Copyright © 1999-2021 by the D Language Foundation