Thread overview
[Issue 23969] Windows cannot export/import TLS from DLLs
[Issue 23969] TLS in Windows cannot export/import TLS from DLLs
Jun 05, 2023
Walter Bright
Jun 05, 2023
Walter Bright
Jun 05, 2023
Dlang Bot
Jun 05, 2023
Walter Bright
Jun 05, 2023
Walter Bright
Jun 05, 2023
Richard Cattermole
Jun 05, 2023
Walter Bright
June 05, 2023
https://issues.dlang.org/show_bug.cgi?id=23969

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |dll

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

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|TLS in Windows cannot       |Windows cannot
                   |export/import TLS from DLLs |export/import TLS from DLLs

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

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #1 from Dlang Bot <dlang-bot@dlang.rocks> ---
@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

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

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=9816

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

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
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.

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

Richard Cattermole <alphaglosined@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alphaglosined@gmail.com

--- Comment #3 from Richard Cattermole <alphaglosined@gmail.com> ---
(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.

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

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
Microsoft VC will not compile:

    __declspec(dllexport) __declspec(thread) int x = 3;

--