qt6: Fix linking when configured with -DENABLE_WALLET=OFF #837

pull hebasto wants to merge 1 commits into bitcoin-core:master from hebasto:240918-wallet-header changing 1 files +2 −0
  1. hebasto commented at 5:38 pm on September 18, 2024: member

    Split from https://github.com/bitcoin/bitcoin/pull/30997.

    When building with Qt 6 in my dev branch, I encountered a linker error when configured with -DENABLE_WALLET=OFF:

     0$ cmake -B build -DENABLE_WALLET=OFF -DBUILD_GUI=ON
     1$ cmake --build build -t bitcoin-qt
     2<snip>
     3[100%] Linking CXX executable bitcoin-qt
     4/usr/bin/ld: libbitcoinqt.a(rpcconsole.cpp.o): in function `QtPrivate::MetaObjectForType<WalletModel const*, void>::metaObjectFunction(QtPrivate::QMetaTypeInterface const*)':
     5/usr/include/x86_64-linux-gnu/qt6/QtCore/qmetatype.h:903:(.text._ZN9QtPrivate17MetaObjectForTypeIPK11WalletModelvE18metaObjectFunctionEPKNS_18QMetaTypeInterfaceE[_ZN9QtPrivate17MetaObjectForTypeIPK11WalletModelvE18metaObjectFunctionEPKNS_18QMetaTypeInterfaceE]+0x2b): undefined reference to `WalletModel::staticMetaObject'
     6/usr/bin/ld: libbitcoinqt.a(rpcconsole.cpp.o): in function `QMetaTypeIdQObject<WalletModel const*, 8>::qt_metatype_id()':
     7/usr/include/x86_64-linux-gnu/qt6/QtCore/qmetatype.h:1313:(.text._ZZN9QtPrivate16QMetaTypeForTypeIPK11WalletModelE17getLegacyRegisterEvENUlvE_4_FUNEv[_ZZN9QtPrivate16QMetaTypeForTypeIPK11WalletModelE17getLegacyRegisterEvENUlvE_4_FUNEv]+0x53): undefined reference to `WalletModel::staticMetaObject'
     8collect2: error: ld returned 1 exit status
     9gmake[3]: *** [src/qt/CMakeFiles/bitcoin-qt.dir/build.make:154: src/qt/bitcoin-qt] Error 1
    10gmake[2]: *** [CMakeFiles/Makefile2:2107: src/qt/CMakeFiles/bitcoin-qt.dir/all] Error 2
    11gmake[1]: *** [CMakeFiles/Makefile2:2114: src/qt/CMakeFiles/bitcoin-qt.dir/rule] Error 2
    12gmake: *** [Makefile:998: bitcoin-qt] Error 2
    

    This PR resolves the issue.

  2. qt: Fix linking when configured with `-DENABLE_WALLET=OFF`
    This change is required for Qt 6, but it is meaningful on its own.
    5be34bacf6
  3. hebasto added the label Qt 6 on Sep 18, 2024
  4. DrahtBot commented at 5:38 pm on September 18, 2024: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK pablomartin4btc, promag

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #692 (Debug Console implementation of generate method by hernanmarino)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. fanquake commented at 5:39 pm on September 18, 2024: member
    What is the error? Why does it only happen with Qt6?
  6. hebasto commented at 5:44 pm on September 18, 2024: member

    What is the error?

    I put it to the PR description.

    Why does it only happen with Qt6?

    Differences in Qt implementation between Qt 5 and Qt 6? (did not dig into the exact code change though)

  7. in src/qt/rpcconsole.cpp:21 in 5be34bacf6
    15@@ -16,7 +16,9 @@
    16 #include <qt/guiutil.h>
    17 #include <qt/peertablesortproxy.h>
    18 #include <qt/platformstyle.h>
    19+#ifdef ENABLE_WALLET
    20 #include <qt/walletmodel.h>
    21+#endif // ENABLE_WALLET
    


    furszy commented at 1:51 am on September 19, 2024:
    How the RPCExecutor::request method compiles when this line doesn’t exist?

    pablomartin4btc commented at 11:35 pm on September 19, 2024:
    I think because the compiler only needs to know WalletModel, it doesn’t need the full definition unless you dereference the pointer (eg as in RPCConsole::RPCParseCommandLine -> wallet_model->getWalletName() - which is guarded).

    hebasto commented at 3:41 pm on October 3, 2024:
    ~Reworked.~

    hebasto commented at 8:55 am on October 4, 2024:

    Reworked.

    Reverted back.

    How the RPCExecutor::request method compiles when this line doesn’t exist?

    Due to https://github.com/bitcoin-core/gui/blob/5be34bacf6d07fb73a0cedfb63a384968d538f3e/src/qt/rpcconsole.h#L24

  8. pablomartin4btc approved
  9. pablomartin4btc commented at 11:16 pm on September 19, 2024: contributor

    tACK 5be34bacf6d07fb73a0cedfb63a384968d538f3e

    It builds correctly on Qt5 and qt runs fine, with both -DENABLE_WALLET=OFF & -DENABLE_WALLET=ON. When wallet support is off also tested the rpc console and several rpc commands.

  10. hebasto renamed this:
    Fix linking when configured with `-DENABLE_WALLET=OFF` (Qt 6)
    qt6: Fix linking when configured with `-DENABLE_WALLET=OFF`
    on Oct 3, 2024
  11. hebasto force-pushed on Oct 3, 2024
  12. hebasto added the label Wallet on Oct 3, 2024
  13. pablomartin4btc commented at 5:16 pm on October 3, 2024: contributor

    utACK 33657e1c958146312e4c68765a92871920401396

    Guarded all WalletModel references (and overriding functions without it) in rpcconsole.

  14. promag commented at 6:41 pm on October 3, 2024: contributor
    I’ll try a different approach.
  15. promag commented at 8:29 am on October 4, 2024: contributor
    ACK 5be34bacf6d07fb73a0cedfb63a384968d538f3e, all other changes in 33657e1c958146312e4c68765a92871920401396 are not required, makes the code harder to read.
  16. DrahtBot requested review from promag on Oct 4, 2024
  17. hebasto force-pushed on Oct 4, 2024
  18. hebasto merged this on Oct 4, 2024
  19. hebasto closed this on Oct 4, 2024

  20. hebasto deleted the branch on Oct 4, 2024
  21. furszy commented at 2:02 pm on October 4, 2024: member
    Arrived a bit late, but see #841. It drops WalletModel linkage and removes an extra #ifdef ENABLE_WALLET in the RPC executor class.

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-11 14:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me