From 60c0f522d96ed455545552b567af6a6c345595a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 30 Oct 2024 06:11:06 +0100 Subject: [PATCH] llvm: Set vendor type in LLVM target triple for more OSs. Annoyingly, LLVM and Clang have various checks throughout that depend on these vendor types being set. --- src/codegen/llvm.zig | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index cec888fba9..682b96d31a 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -164,14 +164,34 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 { }; if (llvm_sub_arch) |sub| try llvm_triple.appendSlice(sub); + try llvm_triple.append('-'); - // Unlike CPU backends, GPU backends actually care about the vendor tag. - try llvm_triple.appendSlice(switch (target.cpu.arch) { - .amdgcn => if (target.os.tag == .mesa3d) "-mesa-" else "-amd-", - .nvptx, .nvptx64 => "-nvidia-", - .spirv64 => if (target.os.tag == .amdhsa) "-amd-" else "-unknown-", - else => "-unknown-", + try llvm_triple.appendSlice(switch (target.os.tag) { + .aix, + .zos, + => "ibm", + .bridgeos, + .driverkit, + .ios, + .macos, + .tvos, + .visionos, + .watchos, + => "apple", + .ps4, + .ps5, + => "scei", + .amdhsa, + .amdpal, + => "amd", + .cuda, + .nvcl, + => "nvidia", + .mesa3d, + => "mesa", + else => "unknown", }); + try llvm_triple.append('-'); const llvm_os = switch (target.os.tag) { .freestanding => "unknown",