-
Notifications
You must be signed in to change notification settings - Fork 230
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
__thread / _Thread_local #268
Comments
I think this can be done and the changes would mostly affect the frontend as well as the code emitter, adding the enhancement label. |
Thank you. I currently work around this by testing syntactically for the name of some known thread local global variable defined in libc in the function emitting the assembly code for "load symbol" in the backend backend, and emitting a special instruction sequence in this case. |
|
Currently implemented for KVX in Verimag's versions. |
C11 defines the
_Thread_local
keyword, and GCC has long had the__thread
modifier.They define data to reside in the thread-local storage. Basically, if
x
is thread-local, then it behaves as a separate variable depending on the thread where its address is taken (either explicitly with&
or implicitly when used as an lvalue or expr).CompCert does not support multi-threading. However, on some platforms, the system libraries put essential data (including
stdin
,stdout
,stderr
) in thread-local storage, meaning that code compiled with vanilla CompCert cannot dofprintf(stderr, ...)
(one gets a linkage error for referring to a thread-local object using a normal relocation).As far as I understand CompCert internals, only the symbol name is transmitted to the back-end when a “load symbol” opcode is generated. Maybe it would be interesting to be able to convey some attributes, such as whether the symbol is marked as thread-local, to the back-end, along with the symbol name, so that it is possible to implement such references.
(I realize that this is probably a lot of work for a little problem.)
The text was updated successfully, but these errors were encountered: