Hello everyone,

First of all, I am not sure if this is a bug - or if I am holding it wrong.

I am trying to compile some interrupt handlers marked as such, on a platform with hard-float and neon.

The gcc command line for this project is
arm-none-eabi-gcc -std=gnu23 -O2 -Wall -Werror -Wextra -Wpedantic -Wshadow -pipe -mcpu=cortex-a5 -mfpu=vfpv4-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -flto

and the code that I am trying to compile, for its various variations (note that the "used" attribute is only here to suppress extra warnings about unused functions that are not related to the behavior in question, and are not there in the actual code):

Line 1:
static void __attribute__ ((used,interrupt("IRQ"))) irq_1 (void) { }
This line is supposed to fail since there is hard-float and NEON extensions - and it does: general-regs-only.c:1:1: error: FP registers might be clobbered despite 'interrupt' attribute: compile with '-mgeneral-regs-only' [-Werror=attributes]

So, in line 2, let's do as suggested (for this one function):
static void __attribute__ ((used,target("general-regs-only"),interrupt("IRQ"))) irq_2 (void) { } general-regs-only.c:2:1: error: FP registers might be clobbered despite 'interrupt' attribute: compile with '-mgeneral-regs-only' [-Werror=attributes]

It's not working. Let's switch order for line 3:
static void __attribute__ ((used,interrupt("IRQ"),target("general-regs-only"))) irq_3 (void) { } This compiles, but only as long as line 2 exists. If line 2 is commented out, it fails all the same.

static void __attribute__ ((used,general-regs-only,interrupt("IRQ"))) irq_4 (void) { }
general-regs-only.c:4:41: error: expected ')' before '-' token
general-regs-only.c:4:69: error: expected identifier or '(' before ')' token

This is more of a documentation error. The documentation at https://gcc.gnu.org/onlinedocs/gcc/ARM-Function-Attributes.html mentions this attribute first thing on the page, and it is invalid, and has to be shoved through target("general-regs-only") instead (maybe? but it still does not work as expected).

I can, in order to compile, successfully use a pragma:

#pragma GCC push_options
#pragma GCC target("general-regs-only")
static void __attribute__ ((used,interrupt("IRQ"))) irq_5 (void) { }
#pragma GCC pop_options

But I'd say attributes should work. The dependency in the example of failing in line 2, but then succeeding in line 3 - if, and only if, line 2 is active - seems to indicate to me that the attribute is attached to the wrong function, either for the purpose of checking, for assembly generation, or both.

The identical behavior is experienced with
arm-none-eabi-gcc-14 (Gentoo 14.2.1_p20240921 p1) 14.2.1 20240921
arm-none-eabi-gcc-15 (Gentoo 15.0.0_pre20241006 p15) 15.0.0 20241006 (experimental) Older version do not support sufficient parts of the C23 standard for my codebase.

I have attached the four lines of test source to be compiled with
arm-none-eabi-gcc -std=gnu23 -O2 -Wall -Werror -Wextra -Wpedantic -Wshadow -pipe -mcpu=cortex-a5 -mfpu=vfpv4-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -flto -c -o general-regs-only.o general-regs-only.c
for reproduction.

Am I just holding it wrong, or is this worth being posted to the bug tracker?

Best regards,
Chris
static void __attribute__ ((used,interrupt("IRQ"))) irq_1 (void) { }
static void __attribute__ ((used,target("general-regs-only"),interrupt("IRQ"))) irq_2 (void) { }
static void __attribute__ ((used,interrupt("IRQ"),target("general-regs-only"))) irq_3 (void) { }
static void __attribute__ ((used,general-regs-only,interrupt("IRQ"))) irq_4 (void) { }

Reply via email to