-
Notifications
You must be signed in to change notification settings - Fork 7.9k
toolchain: iar: Experimental IAR support #84800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
786c3f3
toolchain: move some hardcoded flags to properties
RobinKastberg f7dce51
toolchain: stop C flags from leaking to the assembler
RobinKastberg 842ac0a
toolchain: iar: tls: no tls pointer offset in IAR
RobinKastberg cf690f5
checkpatch: Allow __BYTE_ORDER__ and __aligned__ in toolchain files
RobinKastberg 43807a0
toolchain: iar: Add experimental IAR support
RobinKastberg cce28a9
MAINTAINERS: add the `Toolchain IAR` area
RobinKastberg f1bf5d3
toolchain: doc: Add toolchain information about IAR
RobinKastberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright (c) 2025 IAR Systems AB | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Configures binary tools as GNU binutils | ||
include(extensions) | ||
|
||
# Specifically choose arm-zephyr-eabi from the zephyr sdk for objcopy and friends | ||
|
||
if("${IAR_TOOLCHAIN_VARIANT}" STREQUAL "iccarm") | ||
set(IAR_ZEPHYR_HOME ${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin) | ||
set(IAR_GNU_PREFIX arm-zephyr-eabi-) | ||
else() | ||
message(ERROR "IAR_TOOLCHAIN_VARIANT not set") | ||
endif() | ||
find_program(CMAKE_OBJCOPY ${IAR_GNU_PREFIX}objcopy PATHS ${IAR_ZEPHYR_HOME} NO_DEFAULT_PATH) | ||
find_program(CMAKE_OBJDUMP ${IAR_GNU_PREFIX}objdump PATHS ${IAR_ZEPHYR_HOME} NO_DEFAULT_PATH) | ||
find_program(CMAKE_AS ${IAR_GNU_PREFIX}as PATHS ${IAR_ZEPHYR_HOME} NO_DEFAULT_PATH) | ||
find_program(CMAKE_AR ${IAR_GNU_PREFIX}ar PATHS ${IAR_ZEPHYR_HOME} NO_DEFAULT_PATH) | ||
find_program(CMAKE_RANLIB ${IAR_GNU_PREFIX}ranlib PATHS ${IAR_ZEPHYR_HOME} NO_DEFAULT_PATH) | ||
find_program(CMAKE_READELF ${IAR_GNU_PREFIX}readelf PATHS ${IAR_ZEPHYR_HOME} NO_DEFAULT_PATH) | ||
find_program(CMAKE_NM ${IAR_GNU_PREFIX}nm PATHS ${IAR_ZEPHYR_HOME} NO_DEFAULT_PATH) | ||
find_program(CMAKE_STRIP ${IAR_GNU_PREFIX}strip PATHS ${IAR_ZEPHYR_HOME} NO_DEFAULT_PATH) | ||
find_program(CMAKE_GDB ${IAR_GNU_PREFIX}gdb-py PATHS ${IAR_ZEPHYR_HOME} NO_DEFAULT_PATH) | ||
|
||
if(CMAKE_GDB) | ||
execute_process( | ||
COMMAND ${CMAKE_GDB} --configuration | ||
RESULTS_VARIABLE GDB_CFG_ERR | ||
OUTPUT_QUIET | ||
ERROR_QUIET | ||
) | ||
endif() | ||
|
||
if(NOT CMAKE_GDB OR GDB_CFG_ERR) | ||
find_program(CMAKE_GDB_NO_PY ${CROSS_COMPILE}gdb PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) | ||
|
||
if(CMAKE_GDB_NO_PY) | ||
set(CMAKE_GDB ${CMAKE_GDB_NO_PY} CACHE FILEPATH "Path to a program." FORCE) | ||
endif() | ||
endif() | ||
|
||
# Include bin tool properties | ||
include(${ZEPHYR_BASE}/cmake/bintools/iar/target_bintools.cmake) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
# Copyright (c) 2025 IAR Systems AB | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# - elfconvert : Name of command for elf file conversion. | ||
# In this implementation `objcopy` is used | ||
# elfconvert_formats : Formats supported: ihex, srec, binary | ||
# elfconvert_flag : empty | ||
# elfconvert_flag_final : empty | ||
# elfconvert_flag_strip_all : -S | ||
# elfconvert_flag_strip_debug : -g | ||
# elfconvert_flag_intarget : --input-target= | ||
# elfconvert_flag_outtarget : --output-target= | ||
# elfconvert_flag_section_remove: --remove-section= | ||
# elfconvert_flag_section_only : --only-section= | ||
# elfconvert_flag_section_rename: --rename-section; | ||
# elfconvert_flag_gapfill : --gap-fill; | ||
# Note: The ';' will be transformed into an | ||
# empty space when executed | ||
# elfconvert_flag_srec_len : --srec-len= | ||
# elfconvert_flag_infile : empty, objcopy doesn't take arguments for filenames | ||
# elfconvert_flag_outfile : empty, objcopy doesn't take arguments for filenames | ||
# | ||
|
||
# elfconvert to use for transforming an elf file into another format, | ||
# such as intel hex, s-rec, binary, etc. | ||
set_property(TARGET bintools PROPERTY elfconvert_command ${CMAKE_OBJCOPY}) | ||
|
||
# List of format the tool supports for converting, for example, | ||
# GNU tools uses objectcopy, which supports the following: ihex, srec, binary | ||
set_property(TARGET bintools PROPERTY elfconvert_formats ihex srec binary) | ||
|
||
set_property(TARGET bintools PROPERTY elfconvert_flag "") | ||
set_property(TARGET bintools PROPERTY elfconvert_flag_final "") | ||
|
||
set_property(TARGET bintools PROPERTY elfconvert_flag_strip_all "-S") | ||
set_property(TARGET bintools PROPERTY elfconvert_flag_strip_debug "-g") | ||
|
||
set_property(TARGET bintools PROPERTY elfconvert_flag_intarget "--input-target=") | ||
set_property(TARGET bintools PROPERTY elfconvert_flag_outtarget "--output-target=") | ||
|
||
set_property(TARGET bintools PROPERTY elfconvert_flag_section_remove "--remove-section=") | ||
set_property(TARGET bintools PROPERTY elfconvert_flag_section_only "--only-section=") | ||
set_property(TARGET bintools PROPERTY elfconvert_flag_section_rename "--rename-section;") | ||
|
||
set_property(TARGET bintools PROPERTY elfconvert_flag_lma_adjust "--change-section-lma;") | ||
|
||
# Note, placing a ';' at the end results in the following param to be a list, | ||
# and hence space separated. | ||
# Thus the command line argument becomes: | ||
# `--gap-file <value>` instead of `--gap-fill<value>` (The latter would result in an error) | ||
set_property(TARGET bintools PROPERTY elfconvert_flag_gapfill "--gap-fill;") | ||
set_property(TARGET bintools PROPERTY elfconvert_flag_srec_len "--srec-len=") | ||
|
||
set_property(TARGET bintools PROPERTY elfconvert_flag_infile "") | ||
set_property(TARGET bintools PROPERTY elfconvert_flag_outfile "") | ||
|
||
# | ||
# - disassembly : Name of command for disassembly of files | ||
# In this implementation `objdump` is used | ||
# disassembly_flag : -d | ||
# disassembly_flag_final : empty | ||
# disassembly_flag_inline_source : -S | ||
# disassembly_flag_all : -SDz | ||
# disassembly_flag_infile : empty, objdump doesn't take arguments for filenames | ||
# disassembly_flag_outfile : '>', objdump doesn't take arguments for output file, but result is printed to standard out, and is redirected. | ||
|
||
set_property(TARGET bintools PROPERTY disassembly_command ${CMAKE_OBJDUMP}) | ||
set_property(TARGET bintools PROPERTY disassembly_flag -d) | ||
set_property(TARGET bintools PROPERTY disassembly_flag_final "") | ||
set_property(TARGET bintools PROPERTY disassembly_flag_inline_source -S) | ||
set_property(TARGET bintools PROPERTY disassembly_flag_all -SDz) | ||
|
||
set_property(TARGET bintools PROPERTY disassembly_flag_infile "") | ||
set_property(TARGET bintools PROPERTY disassembly_flag_outfile ">;" ) | ||
|
||
# | ||
# - strip: Name of command for stripping symbols | ||
# In this implementation `strip` is used | ||
# strip_flag : empty | ||
# strip_flag_final : empty | ||
# strip_flag_all : --strip-all | ||
# strip_flag_debug : --strip-debug | ||
# strip_flag_dwo : --strip-dwo | ||
# strip_flag_infile : empty, strip doesn't take arguments for input file | ||
# strip_flag_outfile : -o | ||
|
||
# This is using strip from bintools. | ||
set_property(TARGET bintools PROPERTY strip_command ${CMAKE_STRIP}) | ||
|
||
# Any flag the strip command requires for processing | ||
set_property(TARGET bintools PROPERTY strip_flag "") | ||
set_property(TARGET bintools PROPERTY strip_flag_final "") | ||
|
||
set_property(TARGET bintools PROPERTY strip_flag_all --strip-all) | ||
set_property(TARGET bintools PROPERTY strip_flag_debug --strip-debug) | ||
set_property(TARGET bintools PROPERTY strip_flag_dwo --strip-dwo) | ||
set_property(TARGET bintools PROPERTY strip_flag_remove_section -R ) | ||
|
||
set_property(TARGET bintools PROPERTY strip_flag_infile "") | ||
set_property(TARGET bintools PROPERTY strip_flag_outfile -o ) | ||
|
||
# | ||
# - readelf : Name of command for reading elf files. | ||
# In this implementation `readelf` is used | ||
# readelf_flag : empty | ||
# readelf_flag_final : empty | ||
# readelf_flag_headers : -e | ||
# readelf_flag_infile : empty, readelf doesn't take arguments for filenames | ||
# readelf_flag_outfile : '>', readelf doesn't take arguments for output | ||
# file, but result is printed to standard out, and | ||
# is redirected. | ||
|
||
# This is using readelf from bintools. | ||
set_property(TARGET bintools PROPERTY readelf_command ${CMAKE_READELF}) | ||
|
||
set_property(TARGET bintools PROPERTY readelf_flag "") | ||
set_property(TARGET bintools PROPERTY readelf_flag_final "") | ||
set_property(TARGET bintools PROPERTY readelf_flag_headers -e) | ||
|
||
set_property(TARGET bintools PROPERTY readelf_flag_infile "") | ||
set_property(TARGET bintools PROPERTY readelf_flag_outfile ">;" ) | ||
|
||
# Example on how to support dwarfdump instead of readelf | ||
#set_property(TARGET bintools PROPERTY readelf_command dwarfdump) | ||
#set_property(TARGET bintools PROPERTY readelf_flag "") | ||
#set_property(TARGET bintools PROPERTY readelf_flag_headers -E) | ||
#set_property(TARGET bintools PROPERTY readelf_flag_infile "") | ||
#set_property(TARGET bintools PROPERTY readelf_flag_outfile "-O file=" ) | ||
|
||
set_property(TARGET bintools PROPERTY symbols_command ${CMAKE_NM}) | ||
set_property(TARGET bintools PROPERTY symbols_flag "") | ||
set_property(TARGET bintools PROPERTY symbols_final "") | ||
set_property(TARGET bintools PROPERTY symbols_infile "") | ||
set_property(TARGET bintools PROPERTY symbols_outfile ">;" ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accepted.
Making a comment to be able to back reference in future that this is a (temporary) exception because we generally want to avoid toolchain specific adjustments within the build system code itself and instead keep this in toolchain specific parts.