bitcoin icon indicating copy to clipboard operation
bitcoin copied to clipboard

[RFC] Align debugging flags to `-O0`

Open fanquake opened this issue 10 months ago • 14 comments

We currently have two issues in relation to debugging optimisation flags:

  • A depends build with DEBUG=1 and using cmake -B build -DCMAKE_BUILD_TYPE=Debug do not align, which is inconsistent/confusing. A depends build will -O1, while CMAKE_BUILD_TYPE=Debug will set -O0.
  • -O0 is unusable in various ways:
    • Compiling certain assembly under -O0 doesn't currently work: https://github.com/bitcoin/bitcoin/pull/29407#issuecomment-2027843446 (probably an upstream issue?).
    • Windows cross-compilation at -O0 is broken without additional flags: https://github.com/bitcoin/bitcoin/issues/28109.

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 https://github.com/bitcoin/bitcoin/pull/3833 Switched to -Og in https://github.com/bitcoin/bitcoin/pull/13005. Switched back to -O0 https://github.com/bitcoin/bitcoin/pull/16435

Depends DEBUG=1 mode has used -O1 since inception.

fanquake avatar Apr 03 '24 11:04 fanquake