authorgravatar for root@agave.cxagave <root@agave.cx> 2026-08-07 12:52:12-04:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-08 13:48:58+02:00
log2785bc38239a5bec644758ffa6af5523eb0fea6f
treefab2d52ed06802504a9c0826d831abc480b4d61a
parentcc6f42302a1cf768710d4888ce41004ef470d130

llvm: workaround to export associated .kd symbol for kernels on amdgcn


1 files changed, 6 insertions(+), 5 deletions(-)

src/codegen/llvm.zig+6-5
......@@ -1507,7 +1507,7 @@ pub const Object = struct {
15071507 }
15081508
15091509 const arch = comp.root_mod.resolved_target.result.cpu.arch;
1510 const is_nvptx = arch == .nvptx or arch == .nvptx64;
1510 const workaround_alias_bugs = arch == .amdgcn or arch == .nvptx or arch == .nvptx64;
15111511
15121512 const llvm_global_ty = llvm_global.typeOf(&o.builder);
15131513
......@@ -1528,10 +1528,11 @@ pub const Object = struct {
15281528 // alias will be set below.
15291529 const alias_global: Builder.Global.Index = global: {
15301530
1531 // WORKAROUND (see https://github.com/llvm/llvm-project/issues/213504)
1532 // LLVM throws "NVPTX aliasee must be a non-kernel function definition"
1533 // if we try to alias a kernel, so we just rename the global directly.
1534 if (is_nvptx and export_i == 0) {
1531 // WORKAROUND (see https://github.com/llvm/llvm-project/issues/213504, https://github.com/llvm/llvm-project/issues/214835)
1532 // For NVPTX, LLVM throws "NVPTX aliasee must be a non-kernel function definition" if we try to alias a kernel
1533 // On AMDGCN, LLVM does not generate an alias for the kernel descriptor symbol on associated functions
1534 // To solve these, we rename the global
1535 if (workaround_alias_bugs and export_i == 0) {
15351536 try llvm_global.rename(exp_name, &o.builder);
15361537 break :global llvm_global;
15371538 }