When chasing down an issue which reliably appeared only in release builds done with platformio (STM32) but not in debug builds, I tried to find out how to align optimization settings as it turned out the problem appeared with -Os (default in release builds) but not with -Og (forcefully set during debug).
Finally I changed .platformio\penv\Lib\site-packages\platformio\builder\tools\piomisc.py’s ProcessDebug function where all -O? settings are removed and -Og is added.
Is there a better way than changing the source code of platformio to achieve this?
Thank you!