Build: Default to add debug symbols with the flag -g/--debug
Currently the flag "-g" (--debug on IAR) to add debug symbols to the
elf file is opt-in, instead of opt-out.
This is quite annoying when developing as one often has to rebuild to
be able to debug.
This flag has no affect on the .hex or .bin file so there are no
security concerns with adding debug symbols to the .elf file.
As I see it, if you are concerned about leaking symbol information you
will not distribute the .elf file and only distribute the .bin and
.hex file.
If you are not concerned about leaking symbol information then it is
very useful and harmless to add debug symbols with -g.
NB: The -g flag does not affect the FLASH/RAM usage.
The reason we can not use RelWithDebInfo is that it does more than add
the -g flag so you don't get the same binary and risk not reproducing
the issue after changing the build type.
We add this flag by introducing the opt-out CMake variable
TFM_DEBUG_SYMBOLS. This variable has conflicting semantics with
TFM_CODE_COVERAGE so we change TFM_CODE_COVERAGE to no longer add the
-g flag and we require that if TFM_CODE_COVERAGE is enabled, then
TFM_DEBUG_SYMBOLS must also be enabled.
This is a breaking change to users of TFM_CODE_COVERAGE, but there is
no clean way of introducing TFM_DEBUG_SYMBOLS without breaking
TFM_CODE_COVERAGE.
Change-Id: I0a412426c40717e086c9bc4330cbb27a5cc810bd
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
diff --git a/toolchain_IARARM.cmake b/toolchain_IARARM.cmake
index ec532f1..0984c8e 100644
--- a/toolchain_IARARM.cmake
+++ b/toolchain_IARARM.cmake
@@ -48,6 +48,8 @@
$<$<COMPILE_LANGUAGE:C,CXX>:-DNO_TYPEOF>
$<$<COMPILE_LANGUAGE:C,CXX>:-D_NO_DEFINITIONS_IN_HEADER_FILES>
$<$<COMPILE_LANGUAGE:C,CXX>:--diag_suppress=Pe546,Pe940,Pa082,Pa084>
+ $<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<BOOL:${TFM_DEBUG_SYMBOLS}>>:--debug>
+ $<$<AND:$<COMPILE_LANGUAGE:ASM>,$<BOOL:${TFM_DEBUG_SYMBOLS}>>:-r>
)
endmacro()
@@ -189,4 +191,4 @@
macro(compiler_link_shared_code TARGET SHARED_CODE_PATH ORIG_TARGET LIB_LIST)
message(FATAL_ERROR "Code sharing support is not implemented by IAR.")
-endmacro()
\ No newline at end of file
+endmacro()