From 2785bc38239a5bec644758ffa6af5523eb0fea6f Mon Sep 17 00:00:00 2001 From: agave Date: Fri, 7 Aug 2026 12:52:12 -0400 Subject: [PATCH] llvm: workaround to export associated .kd symbol for kernels on amdgcn --- src/codegen/llvm.zig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 255b2f6bb38d215ce826b67ca2d6b71d38c45de5..8f3e3917fc0bf0a15dbaa5261dd9dcac9fd4f972 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1507,7 +1507,7 @@ pub const Object = struct { } const arch = comp.root_mod.resolved_target.result.cpu.arch; - const is_nvptx = arch == .nvptx or arch == .nvptx64; + const workaround_alias_bugs = arch == .amdgcn or arch == .nvptx or arch == .nvptx64; const llvm_global_ty = llvm_global.typeOf(&o.builder); @@ -1528,10 +1528,11 @@ pub const Object = struct { // alias will be set below. const alias_global: Builder.Global.Index = global: { - // WORKAROUND (see https://github.com/llvm/llvm-project/issues/213504) - // LLVM throws "NVPTX aliasee must be a non-kernel function definition" - // if we try to alias a kernel, so we just rename the global directly. - if (is_nvptx and export_i == 0) { + // WORKAROUND (see https://github.com/llvm/llvm-project/issues/213504, https://github.com/llvm/llvm-project/issues/214835) + // For NVPTX, LLVM throws "NVPTX aliasee must be a non-kernel function definition" if we try to alias a kernel + // On AMDGCN, LLVM does not generate an alias for the kernel descriptor symbol on associated functions + // To solve these, we rename the global + if (workaround_alias_bugs and export_i == 0) { try llvm_global.rename(exp_name, &o.builder); break :global llvm_global; } -- 2.54.0