From cd9dd4cf8e97797e61dcd374812de9d29c27887d Mon Sep 17 00:00:00 2001 From: Felipe Torrezan Date: Mon, 20 Jan 2025 09:07:57 +0100 Subject: [PATCH] IAR: decouple linker location from toolkit's bin dir The implementation in commit 564d527c04 (IAR: Improve error message for missing license, 2024-08-12, v3.31.0-rc1~234^2) failed for corner cases in which symlinks were used from a location different from the one in which the toolkit is shipped with (`/bin`). In this new implementation, the `` architecture is taken solely from the compiler NAME itself for all the supported languages and forwarded to its respective BinUtils executable names (e.g., `icc`, `iasm`, `a`). This decouples the location from the subdirectory in which they should be found. Fixes: #26610 --- Modules/CMakeFindBinUtils.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index dc28f128d5..4efcd555ea 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -111,10 +111,11 @@ elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^x(Open)?W list(APPEND _CMAKE_TOOL_VARS LINKER AR) elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIAR$") - # Get the architecture from the IAR compiler parent directory - get_filename_component(__iar_bin_dir "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY) - get_filename_component(__iar_toolkit_dir "${__iar_bin_dir}" DIRECTORY) - get_filename_component(__iar_arch_id "${__iar_toolkit_dir}" NAME) + # Detect the `` compiler name + get_filename_component(__iar_selected_compiler "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" NAME) + # Strip out the `icc`,`iasm`,`a` prefixes and other `_suffixes leaving only the `` + string(TOLOWER "${__iar_selected_compiler}" __iar_arch_id) + string(REGEX REPLACE "^x(icc|iasm|a)|(_.*)$" "" __iar_arch_id "x${__iar_arch_id}") # IAR Archive Tool set(_CMAKE_AR_NAMES "iarchive" "iarchive.exe" @@ -147,8 +148,7 @@ elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIAR$") "isymexport" "isymexport.exe" ) list(APPEND _CMAKE_TOOL_VARS AR LINKER IAR_ELFDUMP IAR_ELFTOOL IAR_EXE2OBJ IAR_OBJMANIP IAR_SYMEXPORT) - unset(__iar_bin_dir) - unset(__iar_toolkit_dir) + unset(__iar_selected_compiler) unset(__iar_arch_id) # in all other cases search for ar, ranlib, etc.