Commit 60c0f522d9

Alex Rønne Petersen <alex@alexrp.com>
2024-10-30 06:11:06
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.
1 parent f89982b
Changed files (1)
src
codegen
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",