Skip to content

__attribute__((weak)) doesn't seem to work as intended #99

@sDessens

Description

@sDessens

Commit 0b7839f broke pwm control on my machine and B-G431B. The offending change appears to be:

before: src/drivers/hardware_specific/generic_mcu.cpp

#elif defined(_STM32_DEF_) // or stm32
/// do nothing
#else 
int _configure6PWM(...){ return -1; }
#endif

After: rc/drivers/hardware_specific/generic_mcu.cpp

__attribute__((weak)) int _configure6PWM(...) {return -1;}

Although this implementation is declared weak, the linker still selects this implementation for the final executable, instead of the correct one in src/drivers/hardware_specific/stm32_mcu.cpp. This problem occurs with all weakly defined implementations in this file. Simply emptying the file returns everything to working order.

I'm observing very strange behavior when debugging this issue. Sometimes, removing just one of the functions from generic_mcu.cpp fixes the issue. Sometimes, it doesn't. This suggests we're dealing with nondeterministic compiler behavior...

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions