[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)
YunQiang Su via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 5 00:36:20 PDT 2024
================
@@ -183,6 +183,24 @@ message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
+if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ set(option_prefix "")
+ if (CMAKE_C_SIMULATE_ID MATCHES "MSVC")
+ set(option_prefix "/clang:")
+ endif()
+ set(print_target_triple ${CMAKE_C_COMPILER} ${option_prefix}--target=${LLVM_DEFAULT_TARGET_TRIPLE} ${option_prefix}-print-target-triple)
+ execute_process(COMMAND ${print_target_triple}
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE output
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(result EQUAL 0)
+ set(LLVM_DEFAULT_TARGET_TRIPLE ${output})
+ else()
+ string(REPLACE ";" " " print_target_triple "${print_target_triple}")
----------------
wzssyqa wrote:
Since most of the CIs monitor the commit only. I have no idea how to trigger them before commit.
https://github.com/llvm/llvm-project/pull/89425
More information about the cfe-commits
mailing list