Skip to content

Commit bd9c629

Browse files
committed
always respect threadlocal for variables with external linkage
Previously if you had, for example: extern "c" threadlocal var errno: c_int; This would turn errno into a normal variable for --single-threaded builds. However for variables with external linkage, there is an ABI to uphold. This is needed to make errno work for DragonFly BSD. See #2381.
1 parent 8cda4fd commit bd9c629

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/codegen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6639,7 +6639,7 @@ static void validate_inline_fns(CodeGen *g) {
66396639
}
66406640

66416641
static void set_global_tls(CodeGen *g, ZigVar *var, LLVMValueRef global_value) {
6642-
if (var->is_thread_local && !g->is_single_threaded) {
6642+
if (var->is_thread_local && (!g->is_single_threaded || var->linkage != VarLinkageInternal)) {
66436643
LLVMSetThreadLocalMode(global_value, LLVMGeneralDynamicTLSModel);
66446644
}
66456645
}

0 commit comments

Comments
 (0)