Skip to content

Conversation

fanquake
Copy link
Member

@fanquake fanquake commented Apr 3, 2024

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
Copy link
Contributor

DrahtBot commented Apr 3, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/29796.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept NACK achow101
Concept ACK emc99, theuni
Approach NACK maflcko
Stale ACK TheCharlatan, hebasto, ryanofsky

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@hebasto
Copy link
Member

hebasto commented Apr 3, 2024

  • A depends build with DEBUG=1 and using ./configure --enable-debug do not align, which is inconsistent/confusing.

Concept ACK on fixing that.

@emc99
Copy link

emc99 commented Apr 3, 2024

Concept ACK

@theuni
Copy link
Member

theuni commented Apr 3, 2024

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).

From gcc's docs on -Og

-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
Copy link
Member

achow101 commented Apr 3, 2024

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:

On master:

Thread 4 "b-httpworker.0" hit Breakpoint 1, wallet::CWallet::Create (context=..., name="funds", database=std::unique_ptr<wallet::WalletDatabase> = {...}, 
    wallet_creation_flags=0, error=..., warnings=std::vector of length 0, capacity 0) at wallet/wallet.cpp:2948
2948	{
(gdb) n
2949	   interfaces::Chain* chain = context.chain;
(gdb) 
2950	   ArgsManager& args = *Assert(context.args);
(gdb) 
2024-04-03T18:24:24.238066Z [addcon] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:2768 started
2024-04-03T18:24:24.238169Z [addcon] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:2768 completed (1μs)
2024-04-03T18:24:24.238246Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1860 started
2024-04-03T18:24:24.238343Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1860 completed (3μs)
2951	   const std::string& walletFile = database->Filename();
(gdb) 
2953	   const auto start{SteadyClock::now()};
(gdb) 
2024-04-03T18:24:25.288339Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1860 started
2024-04-03T18:24:25.288437Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1860 completed (3μs)
2956	   std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, std::move(database)), ReleaseWallet);
(gdb) 
2024-04-03T18:24:25.789076Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1932 started
2024-04-03T18:24:25.789145Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1932 completed (2μs)
2957	   walletInstance->m_keypool_size = std::max(args.GetIntArg("-keypool", DEFAULT_KEYPOOL_SIZE), int64_t{1});
(gdb) 
2958	   walletInstance->m_notify_tx_changed_script = args.GetArg("-walletnotify", "");
(gdb) 
2961	   bool rescan_required = false;
(gdb) 
2962	   DBErrors nLoadWalletRet = walletInstance->LoadWallet();
(gdb) 
2024-04-03T18:24:27.971293Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention connman.m_nodes_mutex, ./net.h:1622 started
2024-04-03T18:24:27.971368Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention connman.m_nodes_mutex, ./net.h:1622 completed (2μs)
2024-04-03T18:24:27.972260Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Wallet file version = 10500, last client version = 279900
2024-04-03T18:24:28.845346Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Descriptors: 8, Descriptor Keys: 1 plaintext, 0 encrypted, 1 total.
2024-04-03T18:24:29.556576Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 7bb07d3df110f36af92db5568fb8d4cc1381dd0a6d24b17182ed87cad6ab1d33, type = legacy, internal = false
2024-04-03T18:24:29.556711Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 5cb8f1604559d7b3612008ed3307ca1e21328301d1117b3acdd8b22d5b277219, type = p2sh-segwit, internal = false
2024-04-03T18:24:29.556751Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 68a4834fa805e997434b5c4f2f31625be6f3c5aebae0757293c4215675614a1b, type = bech32, internal = false
2024-04-03T18:24:29.556788Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 19d3e9f0d167b24e3c5330462a0c6cbc3d6e4e06e469967a395835102c0aea4a, type = bech32m, internal = false
2024-04-03T18:24:29.556851Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 09212e585c214fb06d197863920ed50181b984dc6bace73a865ff06a84ec3e61, type = legacy, internal = true
2024-04-03T18:24:29.556892Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 05db3056830116eafc425f192ee58033d44772bbf3bdd62ab50e8d014ecab772, type = p2sh-segwit, internal = true
2024-04-03T18:24:29.556927Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 2fe605d1acd8e46f55fbb47c8162545449df0ab59839219a7541b770a948fa3c, type = bech32, internal = true
2024-04-03T18:24:29.556961Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 115308b94096b7f96245e3ed280290ac5c627c5d666abf5249e4a16bcd5ac79e, type = bech32m, internal = true
2963	   if (nLoadWalletRet != DBErrors::LOAD_OK) {
(gdb) 
3006	   const bool fFirstRun = walletInstance->m_spk_managers.empty() &&
(gdb) 
2024-04-03T18:24:31.018609Z [msghand] [logging/timer.h:58] [Log] [lock] Enter: lock contention connman.m_nodes_mutex, ./net.h:1622 started
2024-04-03T18:24:31.018740Z [msghand] [logging/timer.h:58] [Log] [lock] Enter: lock contention connman.m_nodes_mutex, ./net.h:1622 completed (5μs)
3007	                    !walletInstance->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) &&

This PR:

Thread 4 "b-httpworker.0" hit Breakpoint 1, wallet::CWallet::Create (context=..., name="funds", database=std::unique_ptr<wallet::WalletDatabase> = {...}, 
    wallet_creation_flags=0, error=..., warnings=std::vector of length 0, capacity 0) at wallet/wallet.cpp:2948
2948	{
(gdb) n
2949	   interfaces::Chain* chain = context.chain;
(gdb) 
2024-04-03T18:21:31.566625Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1860 started
2024-04-03T18:21:31.566715Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1860 completed (1μs)
2950	   ArgsManager& args = *Assert(context.args);
(gdb) 
2024-04-03T18:21:33.071865Z [msghand] [logging/timer.h:58] [Log] [lock] Enter: lock contention connman.m_nodes_mutex, ./net.h:1622 started
2024-04-03T18:21:33.071947Z [msghand] [logging/timer.h:58] [Log] [lock] Enter: lock contention connman.m_nodes_mutex, ./net.h:1622 completed (1μs)
2024-04-03T18:21:33.071995Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1932 started
2024-04-03T18:21:33.072075Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1932 completed (1μs)
2951	   const std::string& walletFile = database->Filename();
(gdb) n
2024-04-03T18:21:47.648919Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1932 started
2024-04-03T18:21:47.649023Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1932 completed (1μs)
2953	   const auto start{SteadyClock::now()};
(gdb) 
2956	   std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, std::move(database)), ReleaseWallet);
(gdb) 
2024-04-03T18:21:49.734108Z [msghand] [logging/timer.h:58] [Log] [lock] Enter: lock contention connman.m_nodes_mutex, ./net.h:1622 started
2024-04-03T18:21:49.734220Z [msghand] [logging/timer.h:58] [Log] [lock] Enter: lock contention connman.m_nodes_mutex, ./net.h:1622 completed (3μs)
1765		_M_enable_shared_from_this_with(_Yp*) noexcept
(gdb) 
2957	   walletInstance->m_keypool_size = std::max(args.GetIntArg("-keypool", DEFAULT_KEYPOOL_SIZE), int64_t{1});
(gdb) 
88	     __new_allocator() _GLIBCXX_USE_NOEXCEPT { }
(gdb) 
2024-04-03T18:21:55.765728Z [addcon] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_reconnections_mutex, net.cpp:3814 started
2024-04-03T18:21:55.765826Z [addcon] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_reconnections_mutex, net.cpp:3814 completed (1μs)
2957	   walletInstance->m_keypool_size = std::max(args.GetIntArg("-keypool", DEFAULT_KEYPOOL_SIZE), int64_t{1});
(gdb) 
88	     __new_allocator() _GLIBCXX_USE_NOEXCEPT { }
(gdb) 
1665	     get() const noexcept
(gdb) 
2024-04-03T18:21:59.177777Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_reconnections_mutex, net.cpp:1923 started
2024-04-03T18:21:59.177864Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_reconnections_mutex, net.cpp:1923 completed (1μs)
2958	   walletInstance->m_notify_tx_changed_script = args.GetArg("-walletnotify", "");
(gdb) 
2024-04-03T18:22:01.358006Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1860 started
2024-04-03T18:22:01.358112Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_nodes_mutex, net.cpp:1860 completed (1μs)
1665	     get() const noexcept
(gdb) 
2024-04-03T18:22:02.173997Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_reconnections_mutex, net.cpp:1923 started
2024-04-03T18:22:02.174068Z [net] [logging/timer.h:58] [Log] [lock] Enter: lock contention m_reconnections_mutex, net.cpp:1923 completed (3μs)
2024-04-03T18:22:02.174550Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Wallet file version = 10500, last client version = 279900
2024-04-03T18:22:02.743008Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Descriptors: 8, Descriptor Keys: 1 plaintext, 0 encrypted, 1 total.
2024-04-03T18:22:02.920795Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 7bb07d3df110f36af92db5568fb8d4cc1381dd0a6d24b17182ed87cad6ab1d33, type = legacy, internal = false
2024-04-03T18:22:02.920836Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 5cb8f1604559d7b3612008ed3307ca1e21328301d1117b3acdd8b22d5b277219, type = p2sh-segwit, internal = false
2024-04-03T18:22:02.920851Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 68a4834fa805e997434b5c4f2f31625be6f3c5aebae0757293c4215675614a1b, type = bech32, internal = false
2024-04-03T18:22:02.920864Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 19d3e9f0d167b24e3c5330462a0c6cbc3d6e4e06e469967a395835102c0aea4a, type = bech32m, internal = false
2024-04-03T18:22:02.920891Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 09212e585c214fb06d197863920ed50181b984dc6bace73a865ff06a84ec3e61, type = legacy, internal = true
2024-04-03T18:22:02.920907Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 05db3056830116eafc425f192ee58033d44772bbf3bdd62ab50e8d014ecab772, type = p2sh-segwit, internal = true
2024-04-03T18:22:02.920919Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 2fe605d1acd8e46f55fbb47c8162545449df0ab59839219a7541b770a948fa3c, type = bech32, internal = true
2024-04-03T18:22:02.920932Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [funds] Setting spkMan to active: id = 115308b94096b7f96245e3ed280290ac5c627c5d666abf5249e4a16bcd5ac79e, type = bech32m, internal = true
2963	   if (nLoadWalletRet != DBErrors::LOAD_OK) {

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
Copy link
Member

theuni commented Apr 3, 2024

@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
Copy link
Member

theuni commented Apr 3, 2024

Note that for local hacking (with clang), you can use:

diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 96c4397504..6bc408e843 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2944,7 +2944,7 @@ std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, cons
     return MakeDatabase(wallet_path, options, status, error_string);
 }

-std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings)
+std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings) __attribute__ ((optnone))
 {
     interfaces::Chain* chain = context.chain;
     ArgsManager& args = *Assert(context.args);

To get the best of both worlds:

Thread 1 "b-test" hit Breakpoint 1, wallet::CWallet::Create (context=..., name="/tmp/test_common_Bitcoin Core/231b391a2079bb9568d880b8e884ab0b1c6a21c39361735a83653cf8256a247e/test_wallet_2950041828", database=std::unique_ptr<wallet::WalletDatabase> = {...}, wallet_creation_flags=25769803776, error=..., warnings=std::vector of length 0, capacity 0) at ./src/wallet/wallet.cpp:2949
2949	    interfaces::Chain* chain = context.chain;
(gdb) n
2950	    ArgsManager& args = *Assert(context.args);
(gdb)
2951	    const std::string& walletFile = database->Filename();
(gdb)
2953	    const auto start{SteadyClock::now()};
(gdb)
2956	    std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, std::move(database)), ReleaseWallet);
(gdb)
2957	    walletInstance->m_keypool_size = std::max(args.GetIntArg("-keypool", DEFAULT_KEYPOOL_SIZE), int64_t{1});
(gdb)
2958	    walletInstance->m_notify_tx_changed_script = args.GetArg("-walletnotify", "");
(gdb)
2961	    bool rescan_required = false;

@fanquake
Copy link
Member Author

fanquake commented Apr 4, 2024

One thing to investigate is if -ggdb(n) is useful here at all.

@fanquake fanquake force-pushed the depends_0g_debug_flags branch from 458216e to 38ab095 Compare April 7, 2024 09:59
@DrahtBot DrahtBot removed the CI failed label Apr 7, 2024
@fanquake fanquake force-pushed the depends_0g_debug_flags branch from 38ab095 to d7f2024 Compare June 26, 2024 14:36
@fanquake fanquake force-pushed the depends_0g_debug_flags branch from d7f2024 to be857c0 Compare August 9, 2024 15:28
@fanquake
Copy link
Member Author

fanquake commented Aug 9, 2024

@theuni reminder that you might want to followup here at some point, re recent discussion/debugging.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK a435069. 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 DrahtBot requested review from hebasto and theuni September 10, 2024 14:47
@fanquake fanquake force-pushed the depends_0g_debug_flags branch from a435069 to 296def1 Compare September 10, 2024 14:50
@fanquake
Copy link
Member Author

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 fanquake marked this pull request as ready for review September 10, 2024 14:50
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 296def1.

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.

@fanquake fanquake changed the title [RFC] Align debugging flags to -O0 build: align debugging flags to -O0 Jan 31, 2025
@DrahtBot DrahtBot mentioned this pull request Feb 1, 2025
@fanquake fanquake force-pushed the depends_0g_debug_flags branch 2 times, most recently from 7e5cf50 to 381ab3f Compare February 7, 2025 10:23
@fanquake fanquake force-pushed the depends_0g_debug_flags branch from 381ab3f to d4e8743 Compare February 10, 2025 10:53
@fanquake fanquake force-pushed the depends_0g_debug_flags branch from d4e8743 to 6d33581 Compare February 18, 2025 12:12
@fanquake fanquake marked this pull request as ready for review February 18, 2025 12:13
@fanquake fanquake force-pushed the depends_0g_debug_flags branch from 6d33581 to 07907e7 Compare February 20, 2025 21:24
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 07907e7

Would be good to update the PR description to match current state of the PR and how it is changing depends debug flags from -O1 to -O0. Could also update the "I'm not completely sure yet what the right choice is" part to say what the problems were with other alternatives tried here.

@maflcko
Copy link
Member

maflcko commented Feb 26, 2025

Not sure about this. Going from O1 to O0 in the CI will make the CI tasks a lot slower. For example the multiprocess task is now taking almost two hours https://cirrus-ci.com/task/6440292238229504, whereas it never was that slow in the whole history of CI: https://0xb10c.github.io/bitcoin-core-ci-stats/graph/execution/#multiprocess,%20i686,%20DEBUG (the uppper outliers are this pull request)

I understand that O0 can be used to detect more bugs, but when it comes to the CI, we have to realize that there aren't infinite resources and it will never be possible to put everything into the CI in this repo to run on every push to every pull request.

There are already CI tasks that are run outside this repo and when it comes to O0, this is probably something to run externally as well.

fanquake added a commit that referenced this pull request Mar 13, 2025
1ef22ce depends: patch around PlacementNew issue in capnp (fanquake)

Pull request description:

  See #31772 and capnproto/capnproto#2235.

  Given there isn't agreement in #29796, pulled this out so it could be merged separately, and it's easier to run different test configurations externally.

  Closes #31772.

ACKs for top commit:
  ryanofsky:
    Code review ACK 1ef22ce. Confirmed patch is identical to one merged upstream. Only change since last review was tweaking the file paths and commit data in the patch.
  TheCharlatan:
    ACK 1ef22ce

Tree-SHA512: 9c9ecf50c43cf74315f6659afab55aeafb436f70e83b328016ad574136dce46867220c6e1a85aefd8d3d3d027cd94cc807c79721a4983da9428de70f11224e52
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:
qt/qtbase@8c8b9a4.
@fanquake fanquake force-pushed the depends_0g_debug_flags branch from 07907e7 to 4bdc609 Compare March 13, 2025 03:27
@maflcko
Copy link
Member

maflcko commented Mar 13, 2025

no opinion about the build changes here, but about the CI changes I slightly tend toward Approach NACK, as per my previous comment #29796 (comment)

@theuni
Copy link
Member

theuni commented Mar 13, 2025

@fanquake Can you describe why you think it's important that they align? I think they're 2 different concerns, really. It seems like it'd be a pretty rare circumstance where we'd need depends compiled with max gdb debugability, but pretty common that we'd want Core built that way.

Aligning depends and Core builds both at -Og seemed reasonable to me, but @achow101 has a compelling argument against that. I'm not so excited about both at -O0 because that's basically only useful for debugging an issue deep in a dependency. And as @maflcko said above, it comes with some noticeable real-world downsides.

So my question is.. what does depends built with -O0 actually get us?

@maflcko
Copy link
Member

maflcko commented Mar 14, 2025

So my question is.. what does depends built with -O0 actually get us?

It can't hurt to have the option to have a stronger msan build for depends (see #22064 (comment)), but I don't know if it will be beneficial by default or in other scenarios.

Edit: When it comes to the CI, we could even consider to set -DCMAKE_CXX_FLAGS_DEBUG='-g0 -O2' by default, like it is done in

-DCMAKE_CXX_FLAGS_DEBUG='-g0 -O2' \

@fanquake
Copy link
Member Author

Can you describe why you think it's important that they align?

Mostly for more intuitive behaviour. I think this was more interesting when it was going to be -Og or -O1. Maybe the better approach is to discuss this (and the passing through of flags) further as part of #31920. I'll split out the Qt cherry-pick and close this PR. At least this has surfaced a couple bugs.

@fanquake fanquake closed this Mar 17, 2025
@theuni
Copy link
Member

theuni commented Mar 17, 2025

Fwiw I do think it's interesting to test this somehow now and then to surface bugs like that. I'm just not convinced that -O0 is necessary for every debug build.

@fanquake fanquake deleted the depends_0g_debug_flags branch May 12, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants