IAR: ASM compiler architecture ID detected wrong on IAR functional safety variant
Background
IAR compilers exist both in a normal and a "functional safety" variant for a given architecture. The difference can be seen when doing a --version
for example:
Normal:
IAR Assembler V2.20.1.1739 for RL78
Functional Safety:
IAR Assembler V3.10.2.2086 for RL78 Functional Safety
Issue
When using CMake with a Functional Safety IAR variant the architecture ID for the ASM compiler is detected as "Safety" which fails the configuration:
[cmake] -- The C compiler identification is IAR RL78 3.10.2
[cmake] -- The ASM compiler identification is IAR Safety 3.10.2
[cmake] CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeFindBinUtils.cmake:142 (message):
[cmake] Failed to find linker and librarian for IAR on Safety.
[cmake] Call Stack (most recent call first):
[cmake] C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeDetermineASMCompiler.cmake:214 (include)
[cmake] CMakeLists.txt:5 (project)
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
For C this does not seem to be an issue.
Current workaround
Add "Safety" as a possible architecture ID to ASM compiler detection.
In CMakeFindBinUtils.cmake
change
set(_CMAKE_IAR_ITOOLS "ARM" "RX" "RH850" "RL78" "RISCV" "RISC-V" "STM8")
to:
set(_CMAKE_IAR_ITOOLS "ARM" "RX" "RH850" "RL78" "RISCV" "RISC-V" "STM8" "Safety")
And in Modules/Compiler/IAR-ASM.cmake
change:
set(_CMAKE_IAR_ITOOLS "ARM" "RH850" "RL78" "RX" "RISC-V" "STM8")
set(_CMAKE_IAR_XTOOLS "AVR" "MSP430" "V850" "8051")
set(_CMAKE_IAR_ASM_SILENT "RH850" "RL78" "RX" "RISC-V" "STM8")
to:
set(_CMAKE_IAR_ITOOLS "ARM" "RH850" "RL78" "RX" "RISC-V" "STM8" "Safety")
set(_CMAKE_IAR_XTOOLS "AVR" "MSP430" "V850" "8051")
set(_CMAKE_IAR_ASM_SILENT "RH850" "RL78" "RX" "RISC-V" "STM8" "Safety")
Possible fix
In CMakeDetermineASMCompiler.cmake
adjust the logic used to extract the architecture:
list(GET _all_compileid_matches "-1" CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID)
I think this simply takes the last entry from the compiler output which results in the architecture ID becoming "Safety" and not "RL78".