Bug 23756 – Add thread local constructor/destructor pragma

Status
NEW
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-03-03T02:18:31Z
Last change time
2024-12-13T19:27:33Z
Assigned to
No Owner
Creator
Richard (Rikki) Andrew Cattermole
Moved to GitHub: dmd#18154 →

Comments

Comment #0 by alphaglosined — 2023-03-03T02:18:31Z
It is necessary to have a libc-based constructor/destructor at the thread level. This would replace DllMain for thread initialization and allow us to do TLS initialization in -betterC (although we may want to switch to it outright, for threads not registered with runtime). Some MSVC specific details: https://lallouslab.net/2017/05/30/using-cc-tls-callbacks-in-visual-studio-with-your-32-or-64bits-programs/
Comment #1 by alphaglosined — 2023-06-16T01:26:56Z
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.
Comment #2 by bugzilla — 2023-06-20T06:44:04Z
> It is necessary to have a libc-based constructor/destructor at the thread level. https://github.com/dlang/dmd/pull/14669
Comment #3 by alphaglosined — 2023-06-20T06:53:21Z
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.
Comment #4 by alphaglosined — 2024-05-02T22:49:44Z
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.
Comment #5 by robert.schadek — 2024-12-13T19:27:33Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18154 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB