-Os and debugging: looking for how to customize gcc options for debug builds

I’m using gdb a lot these days and notice debug builds are done with -Os. Is there any way to override this so my variables are less likely to be optimized away? Having to build standalone builds scripts and keep them up to date is a pain.
Thanks.
PS Some tags related to gdb, debugger, or other likely labels might be useful

you can add the following to the top of you main file:

#pragma GCC optimize ("O0")

see docs here

AWESOME! That’s perfect. Thanks very much.

1 Like