audio: stft_process: switch assert include to rtos/panic.h - #11097
audio: stft_process: switch assert include to rtos/panic.h#11097singalsu wants to merge 1 commit into
Conversation
The two stft_process source files use lassert.h from libc, which under a newlib-based Zephyr build (e.g. MTL with COMMON_LIBC_MALLOC_ARENA_SIZE set) expands assert() to a __assert_no_args() call whose implementation is not linked into the SOF firmware image. Enabling COMP_STFT_PROCESS on such a build therefore fails at link time with an "undefined reference to __assert_no_args" error. All other SOF audio modules includes <rtos/panic.h> instead, which maps assert() to Zephyr's __ASSERT_NO_MSG in firmware builds and to sof_panic() in the posix testbench. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes Zephyr/newlib link failures when COMP_STFT_PROCESS is enabled by replacing the libc <assert.h> include with SOF’s <rtos/panic.h>, aligning STFT code with the assert/panic mechanism used by other SOF audio modules across firmware and testbench builds.
Changes:
- Replace
<assert.h>with<rtos/panic.h>in the generic STFT implementation. - Replace
<assert.h>with<rtos/panic.h>in the HiFi3-optimized STFT implementation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/audio/stft_process/stft_process-hifi3.c | Switches assert provider to rtos/panic.h so asserts resolve correctly in Zephyr firmware builds. |
| src/audio/stft_process/stft_process-generic.c | Switches assert provider to rtos/panic.h to avoid newlib __assert_no_args() link dependency. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
kv2019i
left a comment
There was a problem hiding this comment.
So less than ideal, but given panic.h is used by other modules, I'm ok to proceed with merge.
| #include <sof/audio/format.h> | ||
| #include <sof/common.h> | ||
| #include <assert.h> | ||
| #include <rtos/panic.h> |
There was a problem hiding this comment.
So this kind of works by accident. Seems the root problem is that the __assert_no_args is not export to loadable modules and thus fails. So only one variant of assert is working in loadable modules and for that, you need to include rtos/panic.h.
FYI @lyakh , have you seen this before?
See thesofproject#11097 The two stft_process source files pulled in libc's <assert.h>, which under a newlib-based Zephyr build (e.g. MTL with COMMON_LIBC_MALLOC_ARENA_SIZE set) expands assert() to a __assert_no_args() call whose implementation is not linked into the SOF firmware image. Enabling COMP_STFT_PROCESS on such a build therefore fails at link time with an "undefined reference to __assert_no_args" error. Every other SOF audio component that uses assert() includes <rtos/panic.h> instead, which maps assert() to Zephyr's __ASSERT_NO_MSG in firmware builds and to sof_panic() in the posix testbench. Do the same in stft_process-generic.c and stft_process-hifi3.c. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The two stft_process source files use lassert.h from libc, which under a newlib-based Zephyr build (e.g. MTL with COMMON_LIBC_MALLOC_ARENA_SIZE set) expands assert() to a __assert_no_args() call whose implementation is not linked into the SOF firmware image. Enabling COMP_STFT_PROCESS on such a build therefore fails at link time with an "undefined reference to __assert_no_args" error.
All other SOF audio modules includes <rtos/panic.h> instead, which maps assert() to Zephyr's __ASSERT_NO_MSG in firmware builds and to sof_panic() in the posix testbench.