[libc-commits] [libc] [libc] Fix OS when using `-llvm` OS in the triple (PR #181908)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Tue Feb 17 13:05:17 PST 2026


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/181908

Summary:
We spoof the OS name for the GPU targets and used to get it form the
'end' of the triple list. Adding `-llvm` makes that now point to `-llvm`
which is not recognized so it fails. Just use the direct index, we
already guard that the triple is the correct size


>From 6f2983e857003e46b7b722b8c6291c9aac2d3bcd Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Tue, 17 Feb 2026 14:59:30 -0600
Subject: [PATCH] [libc] Fix OS when using `-llvm` OS in the triple

Summary:
We spoof the OS name for the GPU targets and used to get it form the
'end' of the triple list. Adding `-llvm` makes that now point to `-llvm`
which is not recognized so it fails. Just use the direct index, we
already guard that the triple is the correct size
---
 libc/cmake/modules/LLVMLibCArchitectures.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index 94c978a458a6d..bb96c07b1e7a7 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -70,7 +70,7 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
   endif()
 
   # Setting OS name for GPU architectures.
-  list(GET triple_comps -1 gpu_target_sys)
+  list(GET triple_comps 2 gpu_target_sys)
   if(gpu_target_sys MATCHES "^amdhsa" OR gpu_target_sys MATCHES "^cuda" OR target_arch MATCHES "^spirv")
     set(target_sys "gpu")
   endif()



More information about the libc-commits mailing list