Bug 23969 – Windows cannot export/import TLS from DLLs

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2023-06-05T07:22:15Z
Last change time
2024-12-13T19:29:31Z
Keywords
dll, pull
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=9816
Moved to GitHub: dmd#18173 →

Comments

Comment #0 by bugzilla — 2023-06-05T07:22:15Z
The following C code: __declspec(dllexport) __declspec(thread) int xxx = 3; fails to compile with VC with: test.c(2): error C2492: 'xxx': data with thread storage duration may not have dll interface So it looks like we can't reasonably make that work for D on Windows. The `export` will have to be ignored, because making it an error will make it clumsy to use `export:` attributes.
Comment #1 by dlang-bot — 2023-06-05T07:56:52Z
@WalterBright created dlang/dmd pull request #15296 "fix Issue 23969 - Windows cannot export/import TLS from DLLs" fixing this issue: - fix Issue 23969 - Windows cannot export/import TLS from DLLs https://github.com/dlang/dmd/pull/15296
Comment #2 by bugzilla — 2023-06-05T08:00:07Z
What Microsoft has to say about it: https://learn.microsoft.com/en-us/cpp/parallel/thread-local-storage-tls?view=msvc-170 TL/DR: exporting TLS from DLLs causes a system crash.
Comment #3 by alphaglosined — 2023-06-05T11:25:41Z
(In reply to Walter Bright from comment #2) > TL/DR: exporting TLS from DLLs causes a system crash. But only on operating systems below Vista, which we don't support. However in saying that, we should probably disallow exporting of TLS variables anyway as it'll be platform/libc dependent and that could get old very fast trying to figure out why your application doesn't work when ported. Only then to have to rewrite everything.
Comment #4 by bugzilla — 2023-06-05T23:37:55Z
Microsoft VC will not compile: __declspec(dllexport) __declspec(thread) int x = 3;
Comment #5 by robert.schadek — 2024-12-13T19:29:31Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18173 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB