zephyr: SystemView tracing with STM32L0x fails to compile

Describe the bug I’m trying to enable tracing using systemview on a STM32L071 board. I can compile the same code for an nrf9160dk board and it works fine. It fails with the console log shown below.

To Reproduce have this in your project config

CONFIG_THREAD_NAME=y
CONFIG_SEGGER_SYSTEMVIEW=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_TRACING=y
CONFIG_SEGGER_SYSVIEW_POST_MORTEM_MODE=n
CONFIG_SEGGER_SYSTEMVIEW_BOOT_ENABLE=y

Expected behavior It should compile without errors.

Logs and console output

❯ west build .
-- west flash: rebuilding
[0/1] Re-running CMake...
Including boilerplate (Zephyr base (cached)): <redacted>/zephyrproject/zephyr/cmake/app/boilerplate.cmake
-- Application: <redacted>
-- Zephyr version: 3.0.0 (<redacted>/zephyrproject/zephyr)
-- Found west (found suitable version "0.11.0", minimum required is "0.7.1")
-- Board: <redacted>_<redacted>
-- Cache files will be written to: <redacted>/Library/Caches/zephyr
-- Found dtc: /opt/homebrew/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (/Applications/ARM)
-- Found BOARD.dts: <redacted>/boards/arm/<redacted>_<redacted>/<redacted>_<redacted>.dts
node '/board' compatible '<redacted>,<redacted>' has unknown vendor prefix '<redacted>'
-- Generated zephyr.dts: <redacted>/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: <redacted>/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: <redacted>/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: <redacted>/build/zephyr/dts.cmake
<redacted>/build/zephyr/zephyr.dts:677.5-26: Warning (i2c_bus_reg): /soc/i2c@40005400/st25dv@53:reg: I2C address must be less than 7-bits, got "0x200". Set I2C_TEN_BIT_ADDRESS for 10 bit addresses or fix the property
<redacted>/build/zephyr/zephyr.dts:73.39-78.5: Warning (interrupt_provider): /soc/interrupt-controller@40010400: Missing #address-cells in interrupt provider
Parsing <redacted>/zephyrproject/zephyr/Kconfig
Loaded configuration '<redacted>/boards/arm/<redacted>_<redacted>/<redacted>_<redacted>_defconfig'
Merged configuration '<redacted>/prj.conf'
Configuration saved to '<redacted>/build/zephyr/.config'
Kconfig header saved to '<redacted>/build/zephyr/include/generated/autoconf.h'
-- Configuring done
-- Generating done
-- Build files have been written to: <redacted>/build
[30/154] Building C object modules/segger/CMake...odules/debug/segger/SEGGER/SEGGER_SYSVIEW.c.obj
In file included from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/kernel_includes.h:21,
                 from <redacted>/zephyrproject/zephyr/include/kernel.h:17,
                 from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_Int.h:64,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.c:146:
<redacted>/zephyrproject/zephyr/include/sys/atomic.h: In function 'atomic_test_and_clear_bit':
<redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:14:2: warning: implicit declaration of function 'SEGGER_SYSVIEW_RecordU32' [-Wimplicit-function-declaration]
   14 |  SEGGER_SYSVIEW_RecordU32(TID_SYSCALL, (uint32_t)id)
      |  ^~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:234:61: note: in expansion of macro 'sys_port_trace_syscall_enter'
  234 | #define atomic_and(target, value) ({  atomic_val_t retval;  sys_port_trace_syscall_enter(K_SYSCALL_ATOMIC_AND, atomic_and, target, value);  retval = atomic_and(target, value);  sys_port_trace_syscall_exit(K_SYSCALL_ATOMIC_AND, atomic_and, target, value, retval);  retval; })
      |                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:151:8: note: in expansion of macro 'atomic_and'
  151 |  old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);
      |        ^~~~~~~~~~
<redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:17:2: warning: implicit declaration of function 'SEGGER_SYSVIEW_RecordEndCallU32' [-Wimplicit-function-declaration]
   17 |  SEGGER_SYSVIEW_RecordEndCallU32(TID_SYSCALL, (uint32_t)id)
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:234:178: note: in expansion of macro 'sys_port_trace_syscall_exit'
  234 | #define atomic_and(target, value) ({  atomic_val_t retval;  sys_port_trace_syscall_enter(K_SYSCALL_ATOMIC_AND, atomic_and, target, value);  retval = atomic_and(target, value);  sys_port_trace_syscall_exit(K_SYSCALL_ATOMIC_AND, atomic_and, target, value, retval);  retval; })
      |                                                                                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:151:8: note: in expansion of macro 'atomic_and'
  151 |  old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);
      |        ^~~~~~~~~~
In file included from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_Int.h:64,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.c:146:
<redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h: At top level:
<redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:263:6: warning: conflicting types for 'SEGGER_SYSVIEW_RecordU32'
  263 | void SEGGER_SYSVIEW_RecordU32                     (unsigned int EventId, U32 Para0);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/kernel_includes.h:21,
                 from <redacted>/zephyrproject/zephyr/include/kernel.h:17,
                 from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_Int.h:64,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.c:146:
<redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:14:2: note: previous implicit declaration of 'SEGGER_SYSVIEW_RecordU32' was here
   14 |  SEGGER_SYSVIEW_RecordU32(TID_SYSCALL, (uint32_t)id)
      |  ^~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:234:61: note: in expansion of macro 'sys_port_trace_syscall_enter'
  234 | #define atomic_and(target, value) ({  atomic_val_t retval;  sys_port_trace_syscall_enter(K_SYSCALL_ATOMIC_AND, atomic_and, target, value);  retval = atomic_and(target, value);  sys_port_trace_syscall_exit(K_SYSCALL_ATOMIC_AND, atomic_and, target, value, retval);  retval; })
      |                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:151:8: note: in expansion of macro 'atomic_and'
  151 |  old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);
      |        ^~~~~~~~~~
In file included from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_Int.h:64,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.c:146:
<redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:281:6: warning: conflicting types for 'SEGGER_SYSVIEW_RecordEndCallU32'
  281 | void SEGGER_SYSVIEW_RecordEndCallU32              (unsigned int EventID, U32 Para0);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/kernel_includes.h:21,
                 from <redacted>/zephyrproject/zephyr/include/kernel.h:17,
                 from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_Int.h:64,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.c:146:
<redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:17:2: note: previous implicit declaration of 'SEGGER_SYSVIEW_RecordEndCallU32' was here
   17 |  SEGGER_SYSVIEW_RecordEndCallU32(TID_SYSCALL, (uint32_t)id)
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:234:178: note: in expansion of macro 'sys_port_trace_syscall_exit'
  234 | #define atomic_and(target, value) ({  atomic_val_t retval;  sys_port_trace_syscall_enter(K_SYSCALL_ATOMIC_AND, atomic_and, target, value);  retval = atomic_and(target, value);  sys_port_trace_syscall_exit(K_SYSCALL_ATOMIC_AND, atomic_and, target, value, retval);  retval; })
      |                                                                                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:151:8: note: in expansion of macro 'atomic_and'
  151 |  old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);
      |        ^~~~~~~~~~
[87/154] Building C object zephyr/kernel/CMakeFiles/kernel.dir/atomic_c.c.obj
FAILED: zephyr/kernel/CMakeFiles/kernel.dir/atomic_c.c.obj 
ccache /Applications/ARM/bin/arm-none-eabi-gcc -DHSE_VALUE=8000000 -DKERNEL -DSTM32L071xx -DUSE_FULL_LL_DRIVER -DUSE_HAL_DRIVER -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -I<redacted>/zephyrproject/zephyr/kernel/include -I<redacted>/zephyrproject/zephyr/arch/arm/include -I<redacted>/zephyrproject/zephyr/include -I<redacted>/build/zephyr/include/generated -I<redacted>/zephyrproject/zephyr/soc/arm/st_stm32/stm32l0 -I<redacted>/zephyrproject/zephyr/drivers -I<redacted>/zephyrproject/zephyr/soc/arm/st_stm32/common -I<redacted>/zephyrproject/zephyr/subsys/tracing/include -I<redacted>/zephyrproject/zephyr/subsys/tracing/sysview/. -I<redacted>/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -I<redacted>/zephyrproject/modules/hal/stm32/stm32cube/stm32l0xx/soc -I<redacted>/zephyrproject/modules/hal/stm32/stm32cube/stm32l0xx/drivers/include -I<redacted>/zephyrproject/modules/hal/stm32/stm32cube/stm32l0xx/drivers/include/Legacy -I<redacted>/zephyrproject/modules/hal/stm32/stm32cube/common_ll/include -I<redacted>/zephyrproject/modules/debug/segger/SEGGER -I<redacted>/zephyrproject/modules/debug/segger/Config -I<redacted>/zephyrproject/zephyr/modules/segger/. -I<redacted>/include -isystem <redacted>/zephyrproject/zephyr/lib/libc/minimal/include -isystem /Applications/ARM/bin/../lib/gcc/arm-none-eabi/10.3.1/include -isystem /Applications/ARM/bin/../lib/gcc/arm-none-eabi/10.3.1/include-fixed -Os -imacros <redacted>/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m0plus -mthumb -mabi=aapcs -mfp16-format=ieee -imacros <redacted>/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=<redacted>=CMAKE_SOURCE_DIR -fmacro-prefix-map=<redacted>/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=<redacted>/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT zephyr/kernel/CMakeFiles/kernel.dir/atomic_c.c.obj -MF zephyr/kernel/CMakeFiles/kernel.dir/atomic_c.c.obj.d -o zephyr/kernel/CMakeFiles/kernel.dir/atomic_c.c.obj -c <redacted>/zephyrproject/zephyr/kernel/atomic_c.c
In file included from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
                 from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/kernel.h:1634:20: error: field 'lock' has incomplete type
 1634 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:2005:20: error: field 'lock' has incomplete type
 2005 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:2479:20: error: field 'lock' has incomplete type
 2479 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h: In function 'k_work_user_is_pending':
<redacted>/zephyrproject/zephyr/include/kernel.h:4000:9: warning: implicit declaration of function 'atomic_test_bit' [-Wimplicit-function-declaration]
 4000 |  return atomic_test_bit(&work->flags, K_WORK_USER_STATE_PENDING);
      |         ^~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/kernel.h: In function 'k_work_user_submit_to_queue':
<redacted>/zephyrproject/zephyr/include/kernel.h:4026:7: warning: implicit declaration of function 'atomic_test_and_set_bit'; did you mean 'sys_test_and_set_bit'? [-Wimplicit-function-declaration]
 4026 |  if (!atomic_test_and_set_bit(&work->flags,
      |       ^~~~~~~~~~~~~~~~~~~~~~~
      |       sys_test_and_set_bit
<redacted>/zephyrproject/zephyr/include/kernel.h:4034:4: warning: implicit declaration of function 'atomic_clear_bit'; did you mean 'atomic_clear'? [-Wimplicit-function-declaration]
 4034 |    atomic_clear_bit(&work->flags,
      |    ^~~~~~~~~~~~~~~~
      |    atomic_clear
<redacted>/zephyrproject/zephyr/include/kernel.h: At top level:
<redacted>/zephyrproject/zephyr/include/kernel.h:4239:20: error: field 'lock' has incomplete type
 4239 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:4542:20: error: field 'lock' has incomplete type
 4542 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:4670:20: error: field 'lock' has incomplete type
 4670 |  struct k_spinlock lock;  /**< Synchronization lock */
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:4870:20: error: field 'lock' has incomplete type
 4870 |  struct k_spinlock lock;
      |                    ^~~~
<redacted>/zephyrproject/zephyr/include/kernel.h:5081:20: error: field 'lock' has incomplete type
 5081 |  struct k_spinlock lock;
      |                    ^~~~
In file included from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:128:20: error: conflicting types for 'atomic_test_bit'
  128 | static inline bool atomic_test_bit(const atomic_t *target, int bit)
      |                    ^~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
                 from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/kernel.h:4000:9: note: previous implicit declaration of 'atomic_test_bit' was here
 4000 |  return atomic_test_bit(&work->flags, K_WORK_USER_STATE_PENDING);
      |         ^~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:167:20: error: conflicting types for 'atomic_test_and_set_bit'
  167 | static inline bool atomic_test_and_set_bit(atomic_t *target, int bit)
      |                    ^~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
                 from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/kernel.h:4026:7: note: previous implicit declaration of 'atomic_test_and_set_bit' was here
 4026 |  if (!atomic_test_and_set_bit(&work->flags,
      |       ^~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:186:20: warning: conflicting types for 'atomic_clear_bit'
  186 | static inline void atomic_clear_bit(atomic_t *target, int bit)
      |                    ^~~~~~~~~~~~~~~~
<redacted>/zephyrproject/zephyr/include/sys/atomic.h:186:20: error: static declaration of 'atomic_clear_bit' follows non-static declaration
In file included from <redacted>/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from <redacted>/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from <redacted>/zephyrproject/zephyr/subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
                 from <redacted>/zephyrproject/zephyr/include/tracing/tracing_syscall.h:11,
                 from <redacted>/build/zephyr/include/generated/syscalls/atomic_c.h:7,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic_c.h:75,
                 from <redacted>/zephyrproject/zephyr/include/sys/atomic.h:31,
                 from <redacted>/zephyrproject/zephyr/include/spinlock.h:15,
                 from <redacted>/zephyrproject/zephyr/kernel/atomic_c.c:23:
<redacted>/zephyrproject/zephyr/include/kernel.h:4034:4: note: previous implicit declaration of 'atomic_clear_bit' was here
 4034 |    atomic_clear_bit(&work->flags,
      |    ^~~~~~~~~~~~~~~~
[96/154] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/tracing/sysview/sysview.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: re-build in <redacted>/build failed (no --build-dir given)

Environment (please complete the following information):

  • OS: Mac OS 12.1
  • Toolchain GNU Arm
  • Tag: zephyr-v3.0.0 (have also tried the main branch)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (11 by maintainers)

Commits related to this issue

Most upvoted comments

This is caused by circular header dependencies. IMHO the segger systemview header should never direclty include zephyr kernel headers but what happens is

In file included from ../include/zephyr/kernel_includes.h:37,
                 from ../include/zephyr/kernel.h:17,
                 from /home/user/workspace/zephyrproject/modules/debug/segger/Config/SEGGER_RTT_Conf.h:150,
                 from /home/user/workspace/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW_ConfDefaults.h:66,
                 from /home/user/workspace/zephyrproject/modules/debug/segger/SEGGER/SEGGER_SYSVIEW.h:65,
                 from ../subsys/tracing/sysview/./tracing_sysview_syscall.h:10,
                 from ../include/zephyr/tracing/tracing_syscall.h:11,
                 from zephyr/include/generated/syscalls/atomic_c.h:7,
                 from ../include/zephyr/sys/atomic_c.h:75,
                 from ../include/zephyr/sys/atomic.h:31,
                 from ../include/zephyr/kernel_structs.h:24,
                 from ../include/zephyr/arch/arm/aarch32/arch_inlines.h:10,
                 from ../include/zephyr/arch/arch_inlines.h:18,
                 from ../include/zephyr/sys/arch_interface.h:1265,
                 from ../include/zephyr/arch/cpu.h:12,
                 from /home/user/workspace/zephyrproject/zephyr/arch/common/isr_tables.c:10:
../include/zephyr/fatal.h:87:59: error: unknown type name 'z_arch_esf_t'
   87 | void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf);

So regular code includes zephyr kernel code, which includes the tracing with segger, which then in SEGGER_RTT_Conf.h includes the kernel again.

I prepared a fix which moves all the dependent code into the c files of the segger module. Unfortunately that needs changes in both zephyr and segger repositories:

zephyr - fix_segger_dependencies segger - fix_include_dependencies

Let me know if it works for you, then I will start a merge request.

Nice redacted log