[compiler-rt] CompilerRT: Normalize COMPILER_RT_DEFAULT_TARGET_TRIPLE (PR #88407)
YunQiang Su via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 09:45:03 PDT 2024
https://github.com/wzssyqa updated https://github.com/llvm/llvm-project/pull/88407
>From a1b4b8a5544422e075f218038761dbb5bc49af45 Mon Sep 17 00:00:00 2001
From: YunQiang Su <syq at gcc.gnu.org>
Date: Fri, 12 Apr 2024 00:08:26 +0800
Subject: [PATCH 1/2] CompilerRT: Normalize COMPILER_RT_DEFAULT_TARGET_TRIPLE
If LLVM is configured with -DLLVM_DEFAULT_TARGET_TRIPLE, and the
argument is not normalized, such as Debian-style vendor-less triple,
clang will try to find libclang_rt in lib/<normalized_triple>,
while libclang_rt is placed into lib/<triple_arg>.
Let's also place libclang_rt into lib/<normalized_triple>.
---
.../cmake/Modules/CompilerRTUtils.cmake | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index e8e5f612d5b03c..e1d25dac9c24b7 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -362,10 +362,22 @@ macro(construct_compiler_rt_default_triple)
message(FATAL_ERROR "CMAKE_C_COMPILER_TARGET must also be set when COMPILER_RT_DEFAULT_TARGET_ONLY is ON")
endif()
message(STATUS "cmake c compiler target: ${CMAKE_C_COMPILER_TARGET}")
- set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${CMAKE_C_COMPILER_TARGET})
+ if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -target ${CMAKE_C_COMPILER_TARGET} -print-effective-triple
+ OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ else()
+ set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${CMAKE_C_COMPILER_TARGET})
+ endif()
else()
- set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${LLVM_TARGET_TRIPLE} CACHE STRING
- "Default triple for which compiler-rt runtimes will be built.")
+ if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -target ${LLVM_TARGET_TRIPLE} -print-effective-triple
+ OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ else()
+ set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${LLVM_TARGET_TRIPLE} CACHE STRING
+ "Default triple for which compiler-rt runtimes will be built.")
+ endif()
endif()
string(REPLACE "-" ";" LLVM_TARGET_TRIPLE_LIST ${COMPILER_RT_DEFAULT_TARGET_TRIPLE})
>From 05d44b0667aab83abf7decc398d916e8bab49cc3 Mon Sep 17 00:00:00 2001
From: YunQiang Su <syq at gcc.gnu.org>
Date: Fri, 12 Apr 2024 00:44:43 +0800
Subject: [PATCH 2/2] use --target=
---
compiler-rt/cmake/Modules/CompilerRTUtils.cmake | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index e1d25dac9c24b7..75f111efeb102f 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -363,7 +363,7 @@ macro(construct_compiler_rt_default_triple)
endif()
message(STATUS "cmake c compiler target: ${CMAKE_C_COMPILER_TARGET}")
if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
- execute_process(COMMAND ${CMAKE_C_COMPILER} -target ${CMAKE_C_COMPILER_TARGET} -print-effective-triple
+ execute_process(COMMAND ${CMAKE_C_COMPILER} --target=${CMAKE_C_COMPILER_TARGET} -print-effective-triple
OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
@@ -371,7 +371,7 @@ macro(construct_compiler_rt_default_triple)
endif()
else()
if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
- execute_process(COMMAND ${CMAKE_C_COMPILER} -target ${LLVM_TARGET_TRIPLE} -print-effective-triple
+ execute_process(COMMAND ${CMAKE_C_COMPILER} --target=${LLVM_TARGET_TRIPLE} -print-effective-triple
OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
More information about the llvm-commits
mailing list