[PATCH] D98452: [compiler-rt] Produce the right arch suffix for arm libraries

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 11 13:57:37 PST 2021


mstorsjo created this revision.
mstorsjo added reviewers: MaskRay, phosek, rprichard.
Herald added subscribers: kristof.beyls, mgorny, dberris.
mstorsjo requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

If producing libraries with an arch suffix (i.e. if
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR isn't set), we append the
architecture name. However, for arm, clang doesn't look for libraries
with the full architecture name, but only looks for "arm" and "armhf".

Try to deduce what the full target triple might have been, and use
that for deciding between "arm" and "armhf".

This tries to reapply this bit from D98173 <https://reviews.llvm.org/D98173>, that had to be reverted
in 7b153b43d3a14d76975039408c4b922beb576735 <https://reviews.llvm.org/rG7b153b43d3a14d76975039408c4b922beb576735> due to affecting how
the builtins themselves are compiled, not only affecting the output
file name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98452

Files:
  compiler-rt/cmake/Modules/AddCompilerRT.cmake


Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===================================================================
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -124,6 +124,21 @@
   else()
     if(ANDROID AND ${arch} STREQUAL "i386")
       set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}")
+    elseif("${arch}" MATCHES "^arm")
+      if(COMPILER_RT_DEFAULT_TARGET_ONLY)
+        set(triple "${COMPILER_RT_DEFAULT_TARGET_TRIPLE}")
+      else()
+        set(triple "${TARGET_TRIPLE}")
+      endif()
+      # When using arch-suffixed runtime library names, clang only looks for
+      # libraries named "arm" or "armhf", see getArchNameForCompilerRTLib in
+      # clang. Therefore, try to inspect both the arch name and the triple
+      # if it seems like we're building an armhf target.
+      if ("${arch}" MATCHES "hf$" OR "${triple}" MATCHES "hf$")
+        set(${output} "${name}-armhf${COMPILER_RT_OS_SUFFIX}")
+      else()
+        set(${output} "${name}-arm${COMPILER_RT_OS_SUFFIX}")
+      endif()
     else()
       set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}")
     endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98452.330065.patch
Type: text/x-patch
Size: 1167 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210311/8be0f4c7/attachment.bin>


More information about the llvm-commits mailing list