From 6896e50967c65ec648c07ba61c796d6660929a91 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 18 Aug 2020 10:41:22 -0400 Subject: CMakeFindBinUtils: Always consider plain binutils when not cross-compiling Since commit c5dd2ca538 (DetermineCompiler: Relax _CMAKE_TOOLCHAIN_PREFIX detection, 2020-03-25, v3.18.0-rc1~430^2), `_CMAKE_TOOLCHAIN_PREFIX` may be set even when not cross-compiling. In this case we may still need to use binutils without any prefix. Fixes: #21103 --- Modules/CMakeFindBinUtils.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index de9ef9a..b2004f1 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -102,6 +102,19 @@ else() set(_CMAKE_ADDITIONAL_ADDR2LINE_NAMES "llvm-addr2line") endif() + if(NOT CMAKE_CROSSCOMPILING AND NOT "${_CMAKE_TOOLCHAIN_PREFIX}" STREQUAL "") + list(APPEND _CMAKE_ADDITIONAL_AR_NAMES "ar") + list(APPEND _CMAKE_ADDITIONAL_RANLIB_NAMES "ranlib") + list(APPEND _CMAKE_ADDITIONAL_STRIP_NAMES "strip") + list(APPEND _CMAKE_ADDITIONAL_LINKER_NAMES "ld") + list(APPEND _CMAKE_ADDITIONAL_NM_NAMES "nm") + list(APPEND _CMAKE_ADDITIONAL_OBJDUMP_NAMES "objdump") + list(APPEND _CMAKE_ADDITIONAL_OBJCOPY_NAMES "objcopy") + list(APPEND _CMAKE_ADDITIONAL_READELF_NAMES "readelf") + list(APPEND _CMAKE_ADDITIONAL_DLLTOOL_NAMES "dlltool") + list(APPEND _CMAKE_ADDITIONAL_ADDR2LINE_NAMES "addr2line") + endif() + find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_AR_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_ADDITIONAL_RANLIB_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) -- cgit v0.12