Skip to content

audio: stft_process: switch assert include to rtos/panic.h - #11097

Open
singalsu wants to merge 1 commit into
thesofproject:mainfrom
singalsu:fix_stft_process_assert
Open

audio: stft_process: switch assert include to rtos/panic.h#11097
singalsu wants to merge 1 commit into
thesofproject:mainfrom
singalsu:fix_stft_process_assert

Conversation

@singalsu

Copy link
Copy Markdown
Collaborator

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.

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>
@singalsu
singalsu marked this pull request as ready for review August 14, 2026 08:25
Copilot AI lite review requested due to automatic review settings August 14, 2026 08:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

singalsu added a commit to singalsu/sof that referenced this pull request Aug 14, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants