Skip to content

Commit 8e11bed

Browse files
committed
[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 7b153b4 due to affecting how the builtins themselves are compiled, not only affecting the output file name. Differential Revision: https://reviews.llvm.org/D98452
1 parent 26ec76a commit 8e11bed

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,21 @@ macro(set_output_name output name arch)
124124
else()
125125
if(ANDROID AND ${arch} STREQUAL "i386")
126126
set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}")
127+
elseif("${arch}" MATCHES "^arm")
128+
if(COMPILER_RT_DEFAULT_TARGET_ONLY)
129+
set(triple "${COMPILER_RT_DEFAULT_TARGET_TRIPLE}")
130+
else()
131+
set(triple "${TARGET_TRIPLE}")
132+
endif()
133+
# When using arch-suffixed runtime library names, clang only looks for
134+
# libraries named "arm" or "armhf", see getArchNameForCompilerRTLib in
135+
# clang. Therefore, try to inspect both the arch name and the triple
136+
# if it seems like we're building an armhf target.
137+
if ("${arch}" MATCHES "hf$" OR "${triple}" MATCHES "hf$")
138+
set(${output} "${name}-armhf${COMPILER_RT_OS_SUFFIX}")
139+
else()
140+
set(${output} "${name}-arm${COMPILER_RT_OS_SUFFIX}")
141+
endif()
127142
else()
128143
set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}")
129144
endif()

0 commit comments

Comments
 (0)