We currently have two issues in relation to debugging optimisation flags:
- A depends build with
DEBUG=1
and usingcmake -B build -DCMAKE_BUILD_TYPE=Debug
do not align, which is inconsistent/confusing. A depends build will-O1
, whileCMAKE_BUILD_TYPE=Debug
will set-O0
. -O0
is unusable in various ways:- Compiling certain assembly under
-O0
doesn’t currently work: #29407 (comment) (probably an upstream issue?). - Windows cross-compilation at
-O0
is broken without additional flags: #28109.
- Compiling certain assembly under
I’m not completely sure yet what the right choice is (previously it seems that -Og
was unusable with Clang? (note that for Clang it looks like -Og
and -O1
are basically equivalent), but we should at least align the two systems to be using the same thing for debugging.
Configure history:
-O0
added in #3833
Switched to -Og
in #13005.
Switched back to -O0
#16435
Depends DEBUG=1
mode has used -O1
since inception.