-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: runtime: support general dynamic thread local storage model #71953
Comments
CC @cherrymui @golang/compiler |
Related Issues Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
For golang/go#71953 For golang/go#54805 Change-Id: Ie6f3641dbea4a4e0993289f8db25bbe6c228724c GitHub-Last-Rev: fd5b052 GitHub-Pull-Request: golang#56
For golang/go#71953 For golang/go#54805 Change-Id: Ie6f3641dbea4a4e0993289f8db25bbe6c228724c GitHub-Last-Rev: fd5b052 GitHub-Pull-Request: golang#56
Change https://go.dev/cl/644615 mentions this issue: |
For golang/go#71953 Change-Id: Ie6f3641dbea4a4e0993289f8db25bbe6c228724c GitHub-Last-Rev: ec997ee GitHub-Pull-Request: #56 Reviewed-on: https://go-review.googlesource.com/c/proposal/+/644615 Commit-Queue: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
Hello! Is there a plan to support this for x86_64? I hit this problem recently on Alpine Linux and was wondering if there's a fix in sight in the near future? Thank you! |
Hello, |
Proposal Details
Proposal: Support General Dynamic TLS Model
Summary
This proposal aims to add support for the general dynamic (GD) Thread Local Storage (TLS) model to the Go runtime, to resolve issue 54805. The current implementation only supports the initial exec (IE) and local exec (LE) TLS models, which restricts interoperability with certain C libraries (particularly Musl) and prevents loading Go shared libraries without
LD_PRELOAD
.A more detailed design document is available at: Proposal: Go general dynamic TLS
There is a prototype implementation for Arm64 Linux in review 644975.
Problem
The Go runtime uses Thread Local Storage to preserve goroutine state (
g
) when interacting with C code, but lacks support for the general dynamic TLS model. This limitation:LD_PRELOAD
Proposed Changes
Assembler and Linker Changes
-tls=[IE,LE,GD]
to the assembler to explicitly select the TLS model-tls=IE
forshared
mode, whilecmd/go
specifies-tls=GD
explicitly when neededRuntime Changes
Command Changes
cmd/go
to automatically enable the general dynamic TLS model when required, based on the combination ofGOOS
/GOARCH
andbuildmode
-D=TLS_GD
and-tls=GD
option to assembler to enable the GD modelInitial Implementation Focus
buildmode=c-shared
andbuildmode=c-archive
Please refer to the full design document for more detailed information on the implementation approach and technical considerations.
The text was updated successfully, but these errors were encountered: