IAR ILINK linker options in a CMake Project - iarsystems/cmake-tutorial GitHub Wiki

The IAR ILINK Linker comes with a vast amount of options that are described in detail in its accompanying Development Guide. Below you will find a non-exhaustive compendium of frequently used options, alongside their respective meanings, where and how you can use them in your CMake projects.

Architecture-agnostic options

Some linker options are available regardless of the chosen target architecture. Below you will find relevant information. In CMake, all linker options can be specified in target_link_options().

  • --config <file>.icf reads the linker configuration from <file>.icf.
target_link_options(tgt PRIVATE
  --config /opt/iar/bxarm/arm/config/linker/ST/stm32f407xG.icf
  # other linker options... )
  • --map <file|dir> produces a linker map file in the chosen location. Example:
target_link_options(tgt PRIVATE
  --map . # will generate a map file inside ${CMAKE_CURRENT_BUILD_DIR}
  # other linker options... )
  • --no_wrap_diagnostics prevents line breaks for linker-related diagnostic messages. In CMake, it is a recommended option for environments where these messages will be logged.

  • --redirect=<foo>=<alt_foo> redirects all symbolic reference pointing to <foo> towards <alt_foo>. This option can be specified multiple times although CMake requires the SHELL: prefix for repeated parameters. Example:

target_link_options(tgt PRIVATE
  SHELL:--redirect=__write=__write_buffered
  SHELL:--redirect=_Printf=_PrintfFullNoMb
  # other options... )
  • --search <path> or -L <path> specifies a path in which the linker should search for objects and libraries. This option can be specified multiple times although CMake requires the SHELL: prefix for repeated parameters. Example:
target_link_options(tgt PRIVATE
  SHELL:--search=/path/to/libs
  SHELL:--search=/path/to/more-libs
  # other options... )

Architecture-specific options

Below you will find details about ILINK's options available for specific architectures.

Semihosting

The semihosting interface is available for both Arm and RISC-V targets.

  • --semihosting[=iarbreakpoint] links the target with semihosting debugging interface. Example:
target_link_options(tgt PRIVATE 
  --semihosting
  # other options... )

Related resources

⚠️ **GitHub.com Fallback** ⚠️