STM32g030k6p6 simple sketch overflows the flash memory?

Yes but that’s already the default setting in PlatformIO (-Os compiler optimization level). You would have to explicitly add build_type = debug to override this.

You can fake / modify the linkerscript to force it to compile then look into what’s taking up all that space, similiarly to how I did it in here, just that your linkerscript would be here.

Let me try this quickly.