From bd9c629c4c306c9159a5e6ad16fe5637d2bc6dbf Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 3 May 2019 14:39:54 -0400 Subject: 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. --- src/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 9eeee1dee1..7dfdf71725 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -6639,7 +6639,7 @@ static void validate_inline_fns(CodeGen *g) { } static void set_global_tls(CodeGen *g, ZigVar *var, LLVMValueRef global_value) { - if (var->is_thread_local && !g->is_single_threaded) { + if (var->is_thread_local && (!g->is_single_threaded || var->linkage != VarLinkageInternal)) { LLVMSetThreadLocalMode(global_value, LLVMGeneralDynamicTLSModel); } } -- cgit v1.2.3