Skip to main content
Louis Cloete work
Associate III
October 28, 2021
Solved

STM32L476 -flto causes WWDT interrupt to trigger even though WWDT is disabled.

Hi! I have a project in which I tried to enable LTO for release builds. Issue is that the code hangs before entering the main loop. Upon investigation, I found that an interrupt is triggered: the code gets stuck in the default implementation for the WWDT_IRQHandler function:

Default_Handler:
Infinite_Loop:
 b Infinite_Loop

I do not enable WWDT in CubeMX, and it is indeed disabled in my hal conf header file. Now I'm suspecting that I might be enabling LTO incorrectly. I pass -flto to both the C compiler and the linker as arguments. Am I missing something?

This topic has been closed for replies.
TDK
TDKBest answer
October 28, 2021

> WWDT_IRQHandler

You mean WWDG_IRQHandler?

Default_Handler is the default handler for all IRQs you haven't defined. How do you know it's in WWDG_IRQHandler? Examine the VECTACTIVE bits to determine which interrupt it's in.

It's unlikely that the problem is -flto. It's more likely that optimizations are exposing a bug in your program that previously went undetected.

Edit: maybe it is a linker bug, in which case there's nothing we can do about it here. You can remove the weak ISR function definitions.

https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966

"If you feel a post has answered your question, please click ""Accept as Solution""."

2 replies

Louis Cloete work
Associate III
October 28, 2021

Forgot to add link I found which might be relevant: https://github.com/ObKo/stm32-cmake/issues/78

TDK
TDKBest answer
October 28, 2021

> WWDT_IRQHandler

You mean WWDG_IRQHandler?

Default_Handler is the default handler for all IRQs you haven't defined. How do you know it's in WWDG_IRQHandler? Examine the VECTACTIVE bits to determine which interrupt it's in.

It's unlikely that the problem is -flto. It's more likely that optimizations are exposing a bug in your program that previously went undetected.

Edit: maybe it is a linker bug, in which case there's nothing we can do about it here. You can remove the weak ISR function definitions.

https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966

"If you feel a post has answered your question, please click ""Accept as Solution""."