-
Notifications
You must be signed in to change notification settings - Fork 19
Displaying the IAR Linker summary
Felipe Torrezan edited this page Jan 28, 2024
·
6 revisions
Starting from CMake 3.27.0 onwards, the linker's --silent flag is not hardcoded. Sometimes it is convenient to get the linker's resource consumption summary when building with CMake. A CMake option can be used for such purpose.
By default, CMake will suppress the output provided by the underlying tools. For example, when building with "Unix Makefiles":
$ cmake --build build
-- The C compiler identification is IAR ARM 9.40.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/iarsystems/bxarm/arm/bin/iccarm - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (1.6s)
-- Generating done (0.1s)
-- Build files have been written to: /.../cmake-tutorial/examples/arm/hello-world/build
[ 50%] Building C object CMakeFiles/hello-world.dir/main.o
[100%] Linking C executable hello-world.elf
[100%] Built target hello-world
To display the summary by default, append the following snippet to the toolchain file:
option(ISPLAY_LINKER_SUMMARY "Display linker resource usage" ON)
if(ISPLAY_LINKER_SUMMARY)
string(REGEX REPLACE "(^| )(--silent|-S)($| )" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endif()When building a project using the the option snippet.
$ cmake --build build
-- The C compiler identification is IAR ARM 9.40.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/iarsystems/bxarm/arm/bin/iccarm - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (1.6s)
-- Generating done (0.1s)
-- Build files have been written to: /.../cmake-tutorial/examples/arm/hello-world/build
[ 50%] Building C object CMakeFiles/hello-world.dir/main.o
[100%] Linking C executable hello-world.elf
IAR ELF Linker V9.32.2.340/LNX for ARM BX
Copyright 2007-2023 IAR Systems AB.
1'006 bytes of readonly code memory
46 bytes of readonly data memory
8'200 bytes of readwrite data memory
Errors: none
Warnings: none
Link time: 0.01 (CPU) 0.03 (elapsed)
[100%] Built target hello-world
CMake options are cached durign the configuration stage. One method to temporarily disable the ISPLAY_LINKER_SUMMARY option:
- Remove
build/CMakeCache.txt. - Re-configure the toolchain with the option turned off:
$ cmake -Bbuild -DISPLAY_LINKER_SUMMARY=OFF --toolchain ../../iar-toolchain.cmake
-- The C compiler identification is IAR ARM 9.40.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/iarsystems/bxarm/arm/bin/iccarm - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (1.5s)
-- Generating done (0.1s)
-- Build files have been written to: /.../cmake-tutorial/examples/arm/hello-world/build
- Rebuild the project:
$ cmake --build build --clean-first
[ 50%] Building C object CMakeFiles/hello-world.dir/main.o
[100%] Linking C executable hello-world.elf
[100%] Built target hello-world
This is the cmake-tutorial wiki. Back to Wiki Home
- IAR Compiler options in a CMake project
- IAR ILINK options in a CMake project
- Language-specific target options
- Selecting build types
- Using Ninja Multi-Config
- Filing a build log
- Multi-file compilation
- Invoking IAR binary utilities
- Use the IAR ELF Tool to convert executable targets to their binary formats
- Using IAR Build Tools with CMake Presets