Debug Mode Adds Unsupported -g2
Flag to Assembler, Causing Fatal Error
#5005
Labels
-g2
Flag to Assembler, Causing Fatal Error
#5005
Description:
When attempting to debug a project created with STM32Cube in PlatformIO, the assembler (
arm-none-eabi-as
) receives the-g2
flag, which it does not recognize, resulting in a fatal error. This issue prevents successful debugging even though the project compiles without errors in normal build mode.Environment:
arm-none-eabi-gcc
(version 12.3.1)Build Configuration (
platformio.ini
):Problem:
When initiating a debug session using
pio debug -v
, PlatformIO automatically adds the-g2
and-ggdb2
flags to both the GCC compiler and the assembler. While the compiler accepts these flags, the assembler (arm-none-eabi-as) does not recognize -g2, leading to the following fatal error:Even though I forced the -g option in build_flags, it did not take effect.I added the following content to the configuration file, and the debug debugging can be used normally.
debug_build_flags = -g
Steps to Reproduce:
Create a new STM32Cube project using PlatformIO with the genericSTM32F103ZE board.
In platformio.ini, set -g as the debug flag.
Include an assembly startup file (e.g., startup_stm32f103zetx.s) in the project.
Build the project to confirm that it compiles without issues.
Start a debug session using
pio debug -v
.Observe the assembler error related to the
-g2
flag.Log Output:
Expected Behavior:
PlatformIO should respect the build_flags specified in the platformio.ini file and avoid adding unsupported flags like
-g2
to the assembler. The debugger should initiate successfully without modifying the assembler flags in an incompatible way.Actual Behavior:
During the debug build process, PlatformIO adds
-g2
and-ggdb2
flags to both the GCC compiler and the assembler. While GCC handles these flags gracefully, the assembler does not recognize-g2
, resulting in a fatal error and preventing the debug session from starting.The text was updated successfully, but these errors were encountered: