You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 do fprintf(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.)
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.
Activity
bschommer commentedon Feb 4, 2019
I think this can be done and the changes would mostly affect the frontend as well as the code emitter, adding the enhancement label.
monniaux commentedon Feb 4, 2019
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.
monniaux commentedon Feb 24, 2020
monniaux commentedon Mar 16, 2020
Currently implemented for KVX in Verimag's versions.