From fee36b7a784543c3d89e2ef7c531e6892116f237 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Mar 2022 16:58:45 -0400 Subject: 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 --- Modules/CMakeFindBinUtils.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 01cb161b3f..84fde49ce9 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -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") -- cgit v1.2.1