[libc-commits] [libc] a369bb8 - [libc][cmake] Fix LIBC_TARGET_OS query from compiler triple for `darwin`.

Tue Ly via libc-commits libc-commits at lists.llvm.org
Fri Jan 27 07:15:09 PST 2023


Author: Tue Ly
Date: 2023-01-27T10:14:48-05:00
New Revision: a369bb8a3b18804898cefe70938fb63a41a2a5db

URL: https://github.com/llvm/llvm-project/commit/a369bb8a3b18804898cefe70938fb63a41a2a5db
DIFF: https://github.com/llvm/llvm-project/commit/a369bb8a3b18804898cefe70938fb63a41a2a5db.diff

LOG: [libc][cmake] Fix LIBC_TARGET_OS query from compiler triple for `darwin`.

Currently LIBC_TARGET_OS query from compiler triple returns `apple` for
macOS.  This change will fix it back to `darwin` as before.

Differential Revision: https://reviews.llvm.org/D141282

Added: 
    

Modified: 
    libc/cmake/modules/LLVMLibCArchitectures.cmake

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index f925355bcf8c2..6ace3b55ee37d 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -46,6 +46,8 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
   if(target_arch MATCHES "^mips")
     set(target_arch "mips")
   elseif(target_arch MATCHES "^arm")
+    # TODO(lntue): Shall we separate `arm64`?  It is currently recognized as
+    # `arm` here.
     set(target_arch "arm")
   elseif(target_arch MATCHES "^aarch64")
     set(target_arch "aarch64")
@@ -59,6 +61,16 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
 
   set(${arch_var} ${target_arch} PARENT_SCOPE)
   list(GET triple_comps ${system_index} target_sys)
+
+  # Correcting OS name for Apple's systems.
+  if(target_sys STREQUAL "apple")
+    list(GET triple_comps 2 target_sys)
+  endif()
+  # Strip version from `darwin###`
+  if(target_sys MATCHES "^darwin")
+    set(target_sys "darwin")
+  endif()
+
   set(${sys_var} ${target_sys} PARENT_SCOPE)
 endfunction(get_arch_and_system_from_triple)
 


        


More information about the libc-commits mailing list