fanquake
commented at 11:12 am on April 3, 2024:
member
A depends build with DEBUG=1 and using cmake -B build -DCMAKE_BUILD_TYPE=Debug do not align, which is inconsistent/confusing. The depends build will use -O1, while CMAKE_BUILD_TYPE=Debug will set -O0.
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.
DrahtBot
commented at 11:12 am on April 3, 2024:
contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
theuni
commented at 5:09 pm on April 3, 2024:
member
Concept ACK.
I think msan is a good proxy for what we want enabled. From its docs:
To get a reasonable performance add -O1 or higher. To get meaningful stack traces in error messages add -fno-omit-frame-pointer. To get perfect stack traces you may need to disable inlining (just use -O1) and tail call elimination (-fno-optimize-sibling-calls).
-Og should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience. It is a better choice than -O0 for producing debuggable code because some compiler passes that collect debug information are disabled at -O0. Like -O0, -Og completely disables a number of optimization passes so that individual options controlling them have no effect. Otherwise -Og enables all -O1 optimization flags except for those that may interfere with debugging
From what I can tell, -O1 (and thus -Og) will disable the frame pointer. So we may also want to add -fno-omit-frame-pointer as recommended by llvm, but IMO we can wait and see if it turns out to be necessary for anyone first.
achow101
commented at 6:33 pm on April 3, 2024:
member
While this does resolve the compile issue I was having, it does seem to change how gdb is able to debug things, possibly in a meaningful way? This is just an example of a difference that I noticed while stepping through CWallet::Create with and without this PR:
One thing that jumps out to me as possibly being problematic, depending on what’s being debugged, is that the line bool rescan_required = false; is optimized away and no longer appears when going step by step. This is not necessarily a problem as it’s still fairly easy to follow what’s going on and the variable’s value can be checked even though the debugger doesn’t indicate that it was initialized.
Another thing that is kind of annoying is the appearance of the __new_allocator() and get() calls. We don’t see these in the actual code and their appearance means stepping through some more lines that are probably irrelevant to debugging.
theuni
commented at 7:39 pm on April 3, 2024:
member
@achow101 Yeah, I see the same. Sadly that’s the trade-off. Basically -O0 is a poor approximation of what real optimized code will look like. But anything above is bound to optimize some things out.
So we have to make a choice: pure debug-ability (including things like inlines which don’t actually exist), or more realistic binaries while sacrificing some source code in the debugger. Personally I prefer the latter, but you probably live in gdb more than me :)
theuni
commented at 7:46 pm on April 3, 2024:
member
Note that for local hacking (with clang), you can use:
fanquake
commented at 3:40 pm on April 4, 2024:
member
One thing to investigate is if -ggdb(n) is useful here at all.
fanquake force-pushed
on Apr 7, 2024
DrahtBot removed the label
CI failed
on Apr 7, 2024
fanquake force-pushed
on Jun 26, 2024
fanquake force-pushed
on Aug 9, 2024
fanquake
commented at 3:28 pm on August 9, 2024:
member
@theuni reminder that you might want to followup here at some point, re recent discussion/debugging.
hebasto added the label
Needs CMake port
on Aug 16, 2024
fanquake force-pushed
on Aug 28, 2024
fanquake removed the label
Needs CMake port
on Aug 28, 2024
fanquake force-pushed
on Sep 10, 2024
ryanofsky approved
ryanofsky
commented at 2:47 pm on September 10, 2024:
contributor
Code review ACKa4350695d9b5551a7720766a8af99c4ad5667e23. I don’t know all of the tradeoffs between flags, but this change makes sense and seems to do what is described.
I did notice this is changing darwin, linux, and windows flags from O1 to Og but not freebsd/netbsd/openbsd flags so was curious if that was intentional.
DrahtBot requested review from hebasto
on Sep 10, 2024
DrahtBot requested review from theuni
on Sep 10, 2024
fanquake force-pushed
on Sep 10, 2024
fanquake
commented at 2:50 pm on September 10, 2024:
member
I did notice this is changing darwin, linux, and windows flags from O1 to Og but not freebsd/netbsd/openbsd flags so was curious if that was intentional.
It was not. Have fixed that now. Will take this out of draft.
fanquake marked this as ready for review
on Sep 10, 2024
ryanofsky approved
ryanofsky
commented at 3:17 pm on September 10, 2024:
contributor
However, reading more about this it seems like there are real examples of where -Og hurts debuggability #16435 (comment) (“Yes. Please! On macOS, without that fix, debugging with lldb/gdb is impossible.”) and earlier in this thread.
Also if the goal is to make depends build and main build more consistent, I’m not sure why they couldn’t both use -O0 or if the other problems mentioned with -O0 prevent that.
But overall it seems like an improvement to use -Og not -O1 in debug depends builds, and to experiment -Og it in the main build to be more consistent. However, If it turns out -Og does negatively impact debugging in the main build, I think we should consider breaking consistency and using -O0 again in the main build by default. We could also recommend manually switching to -O0 in developer notes when using GDB.
DrahtBot added the label
CI failed
on Sep 11, 2024
DrahtBot removed the label
CI failed
on Sep 15, 2024
TheCharlatan approved
TheCharlatan
commented at 9:20 am on September 16, 2024:
contributor
ACK296def1f6fd936d72d49ce98f9473b4a5d2f9c4b
hebasto approved
hebasto
commented at 4:33 pm on September 16, 2024:
member
ACK296def1f6fd936d72d49ce98f9473b4a5d2f9c4b, I have reviewed the code and it looks OK.
This PR effectively aligns flags between the depends build subsystem and the main build system. This change makes the current undocumented behaviour–where flags from depends override flags form the main build system–more flexible, and it can be considered in the ongoing discussion.
Users will still be able to adjust their debugging experience by manually providing additional flags.
achow101
commented at 6:59 pm on September 16, 2024:
member
NACK using -Og for the main build.
Since I spend a considerable amount of time in gdb, I find this to be detrimental to debugability. One big issue that I’m seeing is that when stepping through line by line, some lines get skipped entirely, including lines that call other functions so it is no longer possible to step into those functions from that caller. Instead a breakpoint needs to be set on that function directly, but this is not always desirable. This can actually be seen in my earlier comment where the LoadWallet() line entirely disappears when stepping through the -Og build.
ryanofsky
commented at 12:58 pm on September 30, 2024:
contributor
If there disadvantages to setting -Og everywhere, as achow is suggesting, maybe it makes sense for depends build to be able to pass flags to the bitcoin build, but let the bitcoin build be free to override them, and keep using -O0 for itself on linux but switch to -Og if needed to avoid problems on other platforms.
I think this would be compatible with approach I suggested in #30813, where depends build provides flags that the main build can use to choose default flag values, and users can freely edit and override the saved values with cmake or ccmake.
fanquake force-pushed
on Dec 10, 2024
fanquake renamed this:
[RFC] Switch and/or align debugging flags (back) to `-Og`
[RFC] Switch and/or align debugging flags to `-O0`
on Dec 10, 2024
fanquake marked this as a draft
on Dec 10, 2024
DrahtBot
commented at 6:16 pm on December 10, 2024:
contributor
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
DrahtBot added the label
CI failed
on Dec 10, 2024
fanquake referenced this in commit
ea9e64ff3c
on Dec 12, 2024
fanquake force-pushed
on Dec 12, 2024
fanquake renamed this:
[RFC] Switch and/or align debugging flags to `-O0`
[RFC] Align debugging flags to `-O0`
on Dec 12, 2024
fanquake referenced this in commit
1251a23642
on Dec 17, 2024
fanquake force-pushed
on Dec 17, 2024
fanquake marked this as ready for review
on Dec 17, 2024
maflcko
commented at 9:33 pm on December 19, 2024:
member
The CI failure:
0[08:34:27.775] ********* Start testing of WalletTests ********* 1[08:34:27.775] Config: Using QtTest library 5.15.14, Qt 5.15.14 (i386-little_endian-ilp32 static debug build; by GCC 13.2.0), ubuntu 24.04 2[08:34:27.775] PASS : WalletTests::initTestCase()
3[08:34:27.775] QDEBUG : WalletTests::walletTests() NotifyUnload
4[08:34:27.775] QWARN : WalletTests::walletTests() This plugin does not support propagateSizeHints()
5[08:34:27.775] QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: 23d0e149f4c487be26bfd20c5a7735fa78757fa84c3368a720ee755f07b6e1d5 status= 0" 6[08:34:27.775] QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: 20bb379fd28f090730ac2d207b92c6e95c69dfa48a8118577edb20e068c9a65d status= 1" 7[08:34:27.775] QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: ec76e4ab5ae7066ba51a42c5e09a79adaf9708a4a3cdbd02a28d378179f3024e status= 1" 8[08:34:27.775] QDEBUG : WalletTests::walletTests() "NotifyAddressBookChanged: mfWxJ45yp2SFn7UciZyNpvDKrzbhyfKrY8 isMine=0 purpose=1 status=0" 9[08:34:27.775] QWARN : WalletTests::walletTests() This plugin does not support propagateSizeHints()
10[08:34:27.775] QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: 23d0e149f4c487be26bfd20c5a7735fa78757fa84c3368a720ee755f07b6e1d5 0"11[08:34:27.775] QDEBUG : WalletTests::walletTests() " inModel=0 Index=96-96 showTransaction=1 derivedStatus=0"12[08:34:27.775] QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: 20bb379fd28f090730ac2d207b92c6e95c69dfa48a8118577edb20e068c9a65d 1"13[08:34:27.775] QDEBUG : WalletTests::walletTests() " inModel=1 Index=33-34 showTransaction=1 derivedStatus=1"14[08:34:27.775] QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: ec76e4ab5ae7066ba51a42c5e09a79adaf9708a4a3cdbd02a28d378179f3024e 1"15[08:34:27.775] QDEBUG : WalletTests::walletTests() " inModel=1 Index=26-27 showTransaction=1 derivedStatus=1"16[08:34:27.775] QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: f51a5fd85b12b19bf82e2ed01583b06de4d91ca145afe516e1371cf8a0845f9b status= 0"17[08:34:27.775] QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: 1d5b20ad1872c813e6fd16b0715d68fa59f782c5912a94b5d5f64e39b50e1865 status= 1"18[08:34:27.775] QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: f51a5fd85b12b19bf82e2ed01583b06de4d91ca145afe516e1371cf8a0845f9b 0"19[08:34:27.775] QDEBUG : WalletTests::walletTests() " inModel=0 Index=67-67 showTransaction=1 derivedStatus=0"20[08:34:27.775] QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: 1d5b20ad1872c813e6fd16b0715d68fa59f782c5912a94b5d5f64e39b50e1865 1"21[08:34:27.775] QDEBUG : WalletTests::walletTests() " inModel=1 Index=36-37 showTransaction=1 derivedStatus=1"22[08:34:27.775] QWARN : WalletTests::walletTests() This plugin does not support propagateSizeHints()
23[08:34:27.775] QWARN : WalletTests::walletTests() This plugin does not support propagateSizeHints()
24[08:34:27.775] QWARN : WalletTests::walletTests() This plugin does not support propagateSizeHints()
25[08:34:27.775] QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: fe93875e30d86470a0861a46df809993cb589a49a9fd9941ad601fc35a140e50 status= 0"26[08:34:27.775] QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: 1d5b20ad1872c813e6fd16b0715d68fa59f782c5912a94b5d5f64e39b50e1865 status= 1"27[08:34:27.775] QDEBUG : WalletTests::walletTests() "NotifyTransactionChanged: f51a5fd85b12b19bf82e2ed01583b06de4d91ca145afe516e1371cf8a0845f9b status= 1"28[08:34:27.775] QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: f51a5fd85b12b19bf82e2ed01583b06de4d91ca145afe516e1371cf8a0845f9b 1"29[08:34:27.775] QDEBUG : WalletTests::walletTests() " inModel=1 Index=67-68 showTransaction=1 derivedStatus=1"30[08:34:27.775] QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: fe93875e30d86470a0861a46df809993cb589a49a9fd9941ad601fc35a140e50 0"31[08:34:27.775] QDEBUG : WalletTests::walletTests() " inModel=0 Index=29-29 showTransaction=1 derivedStatus=0"32[08:34:27.775] QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: 1d5b20ad1872c813e6fd16b0715d68fa59f782c5912a94b5d5f64e39b50e1865 1"33[08:34:27.775] QDEBUG : WalletTests::walletTests() " inModel=1 Index=37-38 showTransaction=1 derivedStatus=1"34[08:34:27.775] QDEBUG : WalletTests::walletTests() "TransactionTablePriv::updateWallet: f51a5fd85b12b19bf82e2ed01583b06de4d91ca145afe516e1371cf8a0845f9b 1"35[08:34:27.775] QDEBUG : WalletTests::walletTests() " inModel=1 Index=68-69 showTransaction=1 derivedStatus=1"36[08:34:27.775]
37[08:34:27.775] === Received signal at function time: 8293ms, total time: 8294ms, dumping stack ===38[08:34:27.775] === End of stack trace ===39[08:34:27.775] QFATAL : WalletTests::walletTests() Received signal440[08:34:27.775] Function time: 8293ms Total time: 8293ms
41[08:34:27.775] FAIL! : WalletTests::walletTests() Received a fatal error.42[08:34:27.775] Loc: [Unknown file(0)]
43[08:34:27.775] Totals: 1 passed, 1 failed, 0 skipped, 0 blacklisted, 8306ms
44[08:34:27.775] ********* Finished testing of WalletTests *********45[08:34:27.775]
46[08:34:27.948] 16/139 Test [#10](/bitcoin-bitcoin/10/): addrman_tests ........................ Passed 10.89 sec47[08:34:29.354] 17/139 Test [#24](/bitcoin-bitcoin/24/): blockfilter_index_tests .............. Passed 2.37 sec48[08:34:32.408] 18/139 Test [#21](/bitcoin-bitcoin/21/): bip324_tests ......................... Passed 11.24 sec49[08:34:40.010] 19/139 Test [#13](/bitcoin-bitcoin/13/): argsman_tests ........................ Passed 22.84 sec50[08:35:19.511] 20/139 Test [#7](/bitcoin-bitcoin/7/): secp256k1_exhaustive_tests ........... Passed 62.48 sec51[08:35:27.660] 21/139 Test [#17](/bitcoin-bitcoin/17/): base58_tests ......................... Passed 69.47 sec52[08:37:38.670] 22/139 Test [#5](/bitcoin-bitcoin/5/): secp256k1_noverify_tests ............. Passed 201.65 sec53[08:39:43.315] 23/139 Test [#9](/bitcoin-bitcoin/9/): bench_sanity_check_high_priority ..... Passed 326.26 sec54[08:40:22.068] 24/139 Test [#6](/bitcoin-bitcoin/6/): secp256k1_tests ...................... Passed 365.03 sec55[08:40:22.069]
56[08:40:22.069] 96% tests passed, 1 tests failed out of 2457[08:40:22.069]
58[08:40:22.069] Total Test time (real) =365.08 sec
59[08:40:22.070]
60[08:40:22.070] The following tests FAILED:
61[08:40:22.070] 8- test_bitcoin-qt (Subprocess aborted)
62[08:40:22.070] Errors while running CTest
63[08:40:22.805]
64[08:40:22.805] Exit status: 8
maflcko
commented at 8:37 am on January 22, 2025:
member
Could turn into draft while the CI is failing?
fanquake marked this as a draft
on Jan 22, 2025
theuni
commented at 4:10 pm on January 22, 2025:
member
Signal 4 is SIGILL. Presumably it’s hitting some unguarded x86_64 or SIMD code. Without a stacktrace (ironic given the switch to -O0) it’s not possible to see whether this is on our side or Qt’s. Going to have to reproduce it locally I’m afraid :(
fanquake force-pushed
on Jan 31, 2025
fanquake
commented at 3:13 pm on January 31, 2025:
member
I’ve pushed up a patch that should work around the broken qt code (although it’s unclear that 32-bit Clang builds are something we need to support for the gui).
Note that this branch is likely going to fail a different way now, in the ipc_tests, see #31772.
fanquake renamed this:
[RFC] Align debugging flags to `-O0`
build: align debugging flags to `-O0`
on Jan 31, 2025
fanquake force-pushed
on Feb 7, 2025
fanquake force-pushed
on Feb 7, 2025
DrahtBot removed the label
CI failed
on Feb 7, 2025
DrahtBot added the label
Build system
on Feb 7, 2025
fanquake force-pushed
on Feb 10, 2025
fanquake force-pushed
on Feb 18, 2025
fanquake marked this as ready for review
on Feb 18, 2025
depends: patch qt rounding bugs
When compiled under -O0, this code was causing runtime failures in the
32-bit Clang gui wallet tests. Work around that by importing a commit from upstream:
https://github.com/qt/qtbase/commit/8c8b9a4173f4add522ec13de85107deba7c82da0.
123d57620d
depends: patch around PlacementNew issue in capnp
See #31772 and https://github.com/capnproto/capnproto/pull/2235.
2e2192a4c7
depends: use -O0 in depends DEBUG=1 flags07907e7ef8
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2025-02-22 15:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me