Skip to content

Commit

Permalink
compiler: add CONFIG_COMPILER_TRACK_MACRO_EXPANSION
Browse files Browse the repository at this point in the history
Add a new compiler option to control tracking locations of tokens across
macro expansions. It may be useful to disable it when debugging long
macro expansion chains.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
  • Loading branch information
gmarull authored and carlescufi committed May 5, 2023
1 parent 8b616ab commit 99ebe39
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ if(CONFIG_COMPILER_SAVE_TEMPS)
zephyr_compile_options($<TARGET_PROPERTY:compiler,save_temps>)
endif()

if(NOT CONFIG_COMPILER_TRACK_MACRO_EXPANSION)
# @Intent: Set compiler specific flags to not track macro expansion
zephyr_compile_options($<TARGET_PROPERTY:compiler,no_track_macro_expansion>)
endif()

if(CONFIG_COMPILER_COLOR_DIAGNOSTICS)
# @Intent: Set compiler specific flag for diagnostic messages
zephyr_compile_options($<TARGET_PROPERTY:compiler,diagnostic>)
Expand Down
8 changes: 8 additions & 0 deletions Kconfig.zephyr
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ config COMPILER_SAVE_TEMPS
Instruct the compiler to save the temporary intermediate files
permanently. These can be useful for troubleshooting build issues.

config COMPILER_TRACK_MACRO_EXPANSION
bool "Track macro expansion"
default y
help
When enabled, locations of tokens across macro expansions will be
tracked. Disabling this option may be useful to debug long macro
expansion chains.

config COMPILER_COLOR_DIAGNOSTICS
bool "Colored diagnostics"
default y
Expand Down
3 changes: 3 additions & 0 deletions cmake/compiler/gcc/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ set_compiler_property(PROPERTY debug -g)
# Flags to save temporary object files
set_compiler_property(PROPERTY save_temps -save-temps=obj)

# Flags to not track macro expansion
set_compiler_property(PROPERTY no_track_macro_expansion -ftrack-macro-expansion=0)

# GCC 11 by default emits DWARF version 5 which cannot be parsed by
# pyelftools. Can be removed once pyelftools supports v5.
check_set_compiler_property(APPEND PROPERTY debug -gdwarf-4)
Expand Down

0 comments on commit 99ebe39

Please sign in to comment.