[libc-commits] [libc] [libc] Handle the `unknown` default target in CMake (PR #115122)

via libc-commits libc-commits at lists.llvm.org
Wed Nov 6 07:37:45 PST 2024


================
@@ -126,12 +115,40 @@ endif()
 # architecture.
 if(explicit_target_triple)
   get_arch_and_system_from_triple(${explicit_target_triple} libc_arch libc_sys)
-  if(NOT libc_arch)
+  if(NOT libc_arch OR NOT libc_sys)
     message(FATAL_ERROR
             "libc build: Invalid or unknown triple: ${explicit_target_triple}")
   endif()
   set(LIBC_TARGET_ARCHITECTURE ${libc_arch})
   set(LIBC_TARGET_OS ${libc_sys})
+  # If the compiler target triple is not the same as the triple specified by
+  # LIBC_TARGET_TRIPLE or LLVM_RUNTIMES_TARGET, we will add a --target option
+  # if the compiler is clang. If the compiler is GCC we just error out as there
+  # is no equivalent of an option like --target.
+  if(NOT libc_compiler_triple STREQUAL explicit_target_triple)
----------------
lntue wrote:

`libc_compiler_triple` is not obtained before this anymore, so it means that it is always crossbuild whenever target triple is specified?

https://github.com/llvm/llvm-project/pull/115122


More information about the libc-commits mailing list