I've updated the GCC compiler from 10.3 to 11.1. I'm using it to compile for target CPU cortex-m4 with FPU.

In my code there is a lot of functions marked as interrupt with the __attribute__((interrupt)) for example:

__attribute__((interrupt)) void systick_isr_vector() {
}

Unfortunately, after update, the compiler has started to generate warnings for interrupt attribute

../unittests_entry.cpp:138:52: warning: FP registers might be clobbered despite 'interrupt' attribute: compile with '-mgeneral-regs-only' [-Wattributes]
  138 | __attribute__((interrupt)) void systick_isr_vector() {
      |          

The question that appeared here was how to turn this warning off. I don't want to disable -Wattributes I want to disable warning only for this particular case instead.

What is more why GCC tries to prohibit using FPU context on the interrupt service routine? It is allowed in the interrupt context on the ARMv7m architecture and supported in the hardware.

I suppose it is a bug in the GCC?

2

There are 2 answers

0
Tom V On

Probably the single biggest defining feature of the Cortex M architectures (ARMv6M, v7M, v8M) is that you don't need any special treatment of interrupt functions. Any ABI compliant function can be used as an interrupt handler and the all the funny business that used to be done with attribute(interrupt) etc is now done by hardware. So just remove the attribute.

0
Lundin On

I don't know why you get the warning, but in case you know it is harmless, you should be able to suppress it locally like this:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
__attribute__((interrupt)) void systick_isr_vector() {
}
#pragma GCC diagnostic pop

See the GCC documentation for details.