Skip to content

Commit

Permalink
[compiler-rt] Produce the right arch suffix for arm libraries
Browse files Browse the repository at this point in the history
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 7b153b4 due to affecting how
the builtins themselves are compiled, not only affecting the output
file name.

Differential Revision: https://reviews.llvm.org/D98452
  • Loading branch information
mstorsjo committed Mar 18, 2021
1 parent 26ec76a commit 8e11bed
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions compiler-rt/cmake/Modules/AddCompilerRT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 8e11bed

Please sign in to comment.