Skip to content

Commit

Permalink
[libc][cmake] Fix LIBC_TARGET_OS query from compiler triple for `darw…
Browse files Browse the repository at this point in the history
…in`.

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
  • Loading branch information
lntue committed Jan 27, 2023
1 parent 57b491b commit a369bb8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libc/cmake/modules/LLVMLibCArchitectures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)

Expand Down

0 comments on commit a369bb8

Please sign in to comment.