[compiler-rt] 8e11bed - [compiler-rt] Produce the right arch suffix for arm libraries

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 18 05:59:58 PDT 2021


Author: Martin Storsjö
Date: 2021-03-18T14:58:58+02:00
New Revision: 8e11bede3a6ac11ebcc05c82fac39899feaf9534

URL: https://github.com/llvm/llvm-project/commit/8e11bede3a6ac11ebcc05c82fac39899feaf9534
DIFF: https://github.com/llvm/llvm-project/commit/8e11bede3a6ac11ebcc05c82fac39899feaf9534.diff

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

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, that had to be reverted
in 7b153b43d3a14d76975039408c4b922beb576735 due to affecting how
the builtins themselves are compiled, not only affecting the output
file name.

Differential Revision: https://reviews.llvm.org/D98452

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index fe4c61abd403..ca2f34e618ab 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -124,6 +124,21 @@ macro(set_output_name output name arch)
   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()


        


More information about the llvm-commits mailing list