BinUtils: Restore llvm-ar fallback on Apple platforms

Since commit 29ea94e17c (BinUtils: Avoid llvm-ar on Apple platforms,
2022-03-03, v3.21.6~1^2) we do not consider `llvm-ar` at all on Apple
platforms.  However, there are existing cross-compiling use cases in
which the toolchain has `llvm-ar` but not `ar`.  Prior to the
re-ordering in commit cf82300a63 (BinUtils: Clarify search logic and
make it more consistent, 2021-05-27, v3.21.0-rc1~119^2~2), we preferred
`ar` and then `llvm-ar`.  Restore the original order for Apple.

Fixes: #23320
This commit is contained in:
Brad King
2022-03-15 16:58:45 -04:00
parent bb99538a45
commit fee36b7a78

View File

@@ -173,8 +173,13 @@ else()
else()
list(PREPEND _CMAKE_LINKER_NAMES "ld.lld")
endif()
if(NOT APPLE)
if(APPLE)
# llvm-ar does not generate a symbol table that the Apple ld64 linker accepts.
# FIXME(#23333): We still need to consider 'llvm-ar' as a fallback because
# the 'APPLE' definition may be based on the host in this context, and a
# cross-compiling toolchain may not have 'ar'.
list(APPEND _CMAKE_AR_NAMES "llvm-ar")
else()
list(PREPEND _CMAKE_AR_NAMES "llvm-ar")
endif()
list(PREPEND _CMAKE_RANLIB_NAMES "llvm-ranlib")