From b3747dd707eeaf06e0bacbde259bf71ef525a961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Tue, 26 May 2026 00:56:38 +0200 Subject: [PATCH] llvm: work around upstream aarch64-windows bug for private thread_local symbols https://codeberg.org/ziglang/zig/issues/31865 --- src/codegen/llvm.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index afc5c9d38236e8c7330de21bcee18e8c1cc6d63c..7bc534a168c853225b55f46ae9b96416bbebaa5f 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1550,6 +1550,11 @@ pub const Object = struct { try o.flushTypePool(pt); } + fn workaroundPrivateSymbolBugs(target: *const std.Target, resolved: *const InternPool.Nav.Resolved) bool { + // https://codeberg.org/ziglang/zig/issues/31865 + return target.cpu.arch.isAARCH64() and target.ofmt == .coff and resolved.@"threadlocal"; + } + pub fn updateNav(o: *Object, pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) !void { const zcu = o.zcu; const ip = &zcu.intern_pool; @@ -1622,14 +1627,14 @@ pub const Object = struct { false => .default, }; llvm_global.ptr(&o.builder).linkage = switch (@"extern".linkage) { - .internal => if (o.builder.strip) .private else .internal, + .internal => if (o.builder.strip and !workaroundPrivateSymbolBugs(zcu.getTarget(), &resolved)) .private else .internal, .strong => .external, .weak => .extern_weak, .link_once => unreachable, }; llvm_global.ptr(&o.builder).visibility = .fromSymbolVisibility(@"extern".visibility); } else { - llvm_global.ptr(&o.builder).linkage = if (o.builder.strip) .private else .internal; + llvm_global.ptr(&o.builder).linkage = if (o.builder.strip and !workaroundPrivateSymbolBugs(zcu.getTarget(), &resolved)) .private else .internal; llvm_global.ptr(&o.builder).visibility = .default; llvm_global.ptr(&o.builder).dll_storage_class = .default; llvm_global.ptr(&o.builder).unnamed_addr = .unnamed_addr; -- 2.54.0