Mark external thread local globals

This commit is contained in:
gingerBill
2021-05-05 11:47:47 +01:00
parent 08360e2337
commit 579b317be8
2 changed files with 22 additions and 0 deletions

View File

@@ -5773,6 +5773,25 @@ lbValue lb_find_value_from_entity(lbModule *m, Entity *e) {
g.type = alloc_type_pointer(e->type);
LLVMSetLinkage(g.value, LLVMExternalLinkage);
if (e->Variable.thread_local_model != "") {
LLVMSetThreadLocal(g.value, true);
String m = e->Variable.thread_local_model;
LLVMThreadLocalMode mode = LLVMGeneralDynamicTLSModel;
if (m == "default") {
mode = LLVMGeneralDynamicTLSModel;
} else if (m == "localdynamic") {
mode = LLVMLocalDynamicTLSModel;
} else if (m == "initialexec") {
mode = LLVMInitialExecTLSModel;
} else if (m == "localexec") {
mode = LLVMLocalExecTLSModel;
} else {
GB_PANIC("Unhandled thread local mode %.*s", LIT(m));
}
LLVMSetThreadLocalMode(g.value, mode);
}
lb_add_entity(m, e, g);
lb_add_member(m, name, g);
return g;

View File

@@ -2176,6 +2176,9 @@ int main(int arg_count, char const **arg_ptr) {
case BuildMode_DynamicLibrary:
i32 result = linker_stage(&gen);
if (result != 0) {
if (build_context.show_timings) {
show_timings(&checker, timings);
}
return 1;
}
break;