Bug 20737 – TLS variables unusable with -betterC for Windows MSVC targets

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2020-04-14T21:16:42Z
Last change time
2023-05-16T12:28:53Z
Keywords
betterC, pull
Assigned to
No Owner
Creator
kinke
See also
https://issues.dlang.org/show_bug.cgi?id=21910, https://issues.dlang.org/show_bug.cgi?id=23014

Comments

Comment #0 by kinke — 2020-04-14T21:16:42Z
This, compiled & linked with -betterC, segfaults with DMD 2.091 on Windows, with -m64 and -m32mscoff (-m32 works; working fine with LDC too): int tlsVar; extern(C) int main() { tlsVar = 123; return 0; }
Comment #1 by r.sagitario — 2020-04-14T21:45:27Z
The TLS directory is not generated into the executable. It's not linked in because there is no reference to _tls_index in the object file as dmd assumes _tls_index==0 when directly building an executable. If you compile with -c and link separately, the TLS directory exists and the program runs without problems.
Comment #2 by bugzilla — 2023-01-15T07:46:23Z
*** Issue 21910 has been marked as a duplicate of this issue. ***
Comment #3 by alphaglosined — 2023-03-03T01:59:12Z
This is still occurring as of 2.102. Also, TLS when it is linked in working under this situation is missing initialization.
Comment #4 by ryuukk.dev — 2023-03-26T05:02:31Z
Any update on this?
Comment #5 by bugzilla — 2023-04-04T06:48:10Z
Comment #6 by ryuukk.dev — 2023-04-30T23:31:47Z
your link is for importc the issue is for betterc today 1st march 2023, using master branch, it is still broken what is the conclusion so i can move on?
Comment #7 by dlang-bot — 2023-05-02T22:09:21Z
@rainers created dlang/dmd pull request #15170 "fix issues 20737 and 23024 - TLS variables unusable with -betterC/imp…" fixing this issue: - fix issues 20737 and 23024 - TLS variables unusable with -betterC/importC for Windows MSVC targets always generate access via __tls_index https://github.com/dlang/dmd/pull/15170
Comment #8 by dlang-bot — 2023-05-04T12:17:18Z
dlang/dmd pull request #15170 "fix issues 20737 and 23014 - TLS variables unusable with -betterC/imp…" was merged into stable: - b4fe7b84643c9638ff22f06f614b907a67551a62 by Rainer Schuetze: fix issues 20737 and 23014 - TLS variables unusable with -betterC/importC for Windows MSVC targets always generate access via __tls_index https://github.com/dlang/dmd/pull/15170
Comment #9 by dlang-bot — 2023-05-16T12:28:53Z
dlang/dmd pull request #15238 "merge stable" was merged into master: - 3072e43d2b60a85b219c7572557c0e367e8d4a88 by Rainer Schuetze: fix issues 20737 and 23014 - TLS variables unusable with -betterC/importC for Windows MSVC targets (#15170) always generate access via __tls_index https://github.com/dlang/dmd/pull/15238