Skip to content

zephyr: sw_isr_table: Fix compilation error #92336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thughes
Copy link
Contributor

@thughes thughes commented Jun 27, 2025

The IRQ_DIRECT_CONNECT macro eventually uses _Z_ISR_DIRECT_TABLE_ENTRY,
which defines a function. IRQ_DIRECT_CONNECT is meant to be used
inside functions. While nested functions are supported as an extension
in GNU C, the nested function cannot have static storage.

https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html:

A nested function always has no linkage. Declaring one with extern or
static is erroneous.

./scripts/twister -c -s arch.interrupt.gen_isr_table_local.riscv --all

tests/kernel/gen_isr_table/src/main.c: In function
'gen_isr_table_test_build_time_direct_interrupt':
include/zephyr/sw_isr_table.h:197:41: error: invalid storage class for
function '__isr_table_entry_isr1_irq_2'
#define __MK_ISR_ELEMENT_NAME(func, id) __isr_table_entry_ ## func ## _irq_ ## id
                                        ^~~~~~~~~~~~~~~~~~

Issue #92194

@thughes thughes force-pushed the push-tkksrrryqvwy branch 2 times, most recently from 520d877 to cbd2158 Compare June 30, 2025 20:57
The IRQ_DIRECT_CONNECT macro eventually uses _Z_ISR_DIRECT_TABLE_ENTRY,
which defines a function. IRQ_DIRECT_CONNECT is meant to be used
inside functions. While nested functions are supported as an extension
in GNU C, the nested function cannot have static storage.

https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html:

> A nested function always has no linkage. Declaring one with extern or
> static is erroneous.

./scripts/twister -c -s arch.interrupt.gen_isr_table_local.riscv --all

tests/kernel/gen_isr_table/src/main.c: In function
'gen_isr_table_test_build_time_direct_interrupt':
include/zephyr/sw_isr_table.h:197:41: error: invalid storage class for
function '__isr_table_entry_isr1_irq_2'
#define __MK_ISR_ELEMENT_NAME(func, id) __isr_table_entry_ ## func ## _irq_ ## id
                                        ^~~~~~~~~~~~~~~~~~

Issue zephyrproject-rtos#92194

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
@thughes thughes force-pushed the push-tkksrrryqvwy branch from cbd2158 to cd0f613 Compare June 30, 2025 21:04
static void __attribute__((section(sect))) __attribute__((naked)) \
__used _MK_IRQ_ELEMENT_NAME(func, __COUNTER__)(void) { \
void __attribute__((section(sect))) __attribute__((naked)) \
/* clang-format off */ \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to turn off clang-format here because it wanted to make line 248 and 249 a single line, which breaks the other check that lines are shorter than 100 characters.

Copy link
Collaborator

Choose a reason for hiding this comment

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

good thing, that clang-format isn't mandatory

Copy link

@thughes thughes marked this pull request as ready for review June 30, 2025 22:15
@github-actions github-actions bot requested review from dcpleung, nashif and ycsin June 30, 2025 22:16
@maass-hamburg maass-hamburg added bug The issue is a bug, or the PR is fixing a bug Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc. labels Jul 3, 2025
@maass-hamburg
Copy link
Collaborator

@dcpleung @nashif @ycsin please take a look, this is needed as a fix as the bug lets the ci fail in f.e. #91726

@ycsin ycsin requested a review from rakons July 7, 2025 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Interrupt Controller bug The issue is a bug, or the PR is fixing a bug Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants