Thread overview
[Issue 23756] Add thread local constructor/destructor pragma
Jun 16, 2023
Richard Cattermole
Jun 20, 2023
Walter Bright
Jun 20, 2023
Richard Cattermole
June 16, 2023
https://issues.dlang.org/show_bug.cgi?id=23756

--- Comment #1 from Richard Cattermole <alphaglosined@gmail.com> ---
This is also handled at the object file level apparently.

https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#tls-callback-functions

There is no reason for SimpleDllMain to exist.

--
June 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23756

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
> It is necessary to have a libc-based constructor/destructor at the thread level.

https://github.com/dlang/dmd/pull/14669

--
June 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23756

--- Comment #3 from Richard Cattermole <alphaglosined@gmail.com> ---
I had a look at that PR.

Nothing in it looks to be adding a per-thread constructor/destructor.

It only adjusts the existing crt_constructor/destructor behavior. Without changing what list of hooks it gets added to. From what I can tell it is unrelated to this ticket.

--
May 02
https://issues.dlang.org/show_bug.cgi?id=23756

Richard Cattermole <alphaglosined@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|Windows                     |All

--- Comment #4 from Richard Cattermole <alphaglosined@gmail.com> ---
Glibc offers support for C++ thread local destruction as part of its implementation of pthread.

https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables

Via ``__cxa_thread_atexit ``.

I don't know how we could hook into this, but it seems like we could do it if we wanted to.

--