[compiler-rt] CompilerRT: Normalize COMPILER_RT_DEFAULT_TARGET_TRIPLE (PR #88835)
YunQiang Su via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 15 20:27:56 PDT 2024
https://github.com/wzssyqa updated https://github.com/llvm/llvm-project/pull/88835
>From c5d45f8544148f4e368f5b6d5172ffe54fb669a8 Mon Sep 17 00:00:00 2001
From: YunQiang Su <syq at debian.org>
Date: Sun, 14 Apr 2024 23:16:52 +0800
Subject: [PATCH 1/2] CompilerRT: Normalize COMPILER_RT_DEFAULT_TARGET_TRIPLE
If LLVM is configured with -DLLVM_DEFAULT_TARGET_TRIPLE, or
compiler_rt is configured with -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE,
while 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>.
---
compiler-rt/cmake/Modules/CompilerRTUtils.cmake | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index e8e5f612d5b03c..bd656049fd7208 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -363,9 +363,19 @@ macro(construct_compiler_rt_default_triple)
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=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} -print-effective-triple
+ OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ 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=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} -print-effective-triple
+ OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
endif()
string(REPLACE "-" ";" LLVM_TARGET_TRIPLE_LIST ${COMPILER_RT_DEFAULT_TARGET_TRIPLE})
>From 78a35fd0fd536abeccde87e0efec381104d97e1a Mon Sep 17 00:00:00 2001
From: YunQiang Su <syq at gcc.gnu.org>
Date: Tue, 16 Apr 2024 11:27:35 +0800
Subject: [PATCH 2/2] only one is needed
---
compiler-rt/cmake/Modules/CompilerRTUtils.cmake | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index bd656049fd7208..6d413f6753bc0c 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -363,19 +363,15 @@ macro(construct_compiler_rt_default_triple)
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=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} -print-effective-triple
- OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- 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=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} -print-effective-triple
- OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- endif()
+ endif()
+
+ if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+ execute_process(COMMAND ${CMAKE_C_COMPILER} --target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} -print-effective-triple
+ OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
string(REPLACE "-" ";" LLVM_TARGET_TRIPLE_LIST ${COMPILER_RT_DEFAULT_TARGET_TRIPLE})
More information about the llvm-commits
mailing list