Skip to content

Conversation

hebasto
Copy link
Owner

@hebasto hebasto commented Feb 11, 2024

A new configuration option is BUILD_GUI_TESTS.


Native Windows / MSVC Notes:

  1. vcpkg configures Qt with -opengl dynamic, which makes the "minimal" platform plugin unusable due to internal Qt bugs.
  2. ctest workarounds this issue by setting the environment variable QT_QPA_PLATFORM=windows.
  3. This approach works nice in the CI for both x64-windows and x64-windows-static triplets. Please note that test_bitcoin-qt.exe fails to run in the CI environment on the master branch.
  4. One who is willing to debug Qt with the "minimal" platform plugin could run the test_bitcoin-qt.exe directly (not driven by ctest).

@hebasto hebasto added the enhancement New feature or request label Feb 11, 2024
@hebasto hebasto force-pushed the 240211-cmake-BP branch 2 times, most recently from 3c071c2 to 197fcce Compare February 11, 2024 17:37
@hebasto hebasto marked this pull request as draft February 11, 2024 18:29
@hebasto hebasto marked this pull request as ready for review February 11, 2024 19:32
Copy link

@theuni theuni left a comment

Choose a reason for hiding this comment

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

I noticed while poking around that cmake adds:
CMakeFiles/test_bitcoin-qt.dir/__/__/__/depends/x86_64-pc-linux-gnu/lib/cmake/Qt5Gui/Qt5Gui_QXcbIntegrationPlugin_Import.cpp.o

The contents of Qt5Gui_QXcbIntegrationPlugin_Import.cpp are:

#include <QtPlugin>
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)

So I think we're doing that twice?

It seems we should either turn that off somehow, or remove the import from our code?

@@ -448,7 +448,7 @@ jobs:

- name: Test Release configuration
run: |
ctest --test-dir build -j $env:NUMBER_OF_PROCESSORS -C Release
ctest --test-dir build -j $env:NUMBER_OF_PROCESSORS -C Release --exclude-regex test_bitcoin-qt
Copy link

Choose a reason for hiding this comment

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

Why? Because it requires a gui? Could you please add a comment?

Copy link
Owner Author

Choose a reason for hiding this comment

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

A "TODO" comment with links to the issues has been added.

@hebasto
Copy link
Owner Author

hebasto commented Feb 24, 2024

I noticed while poking around that cmake adds: CMakeFiles/test_bitcoin-qt.dir/__/__/__/depends/x86_64-pc-linux-gnu/lib/cmake/Qt5Gui/Qt5Gui_QXcbIntegrationPlugin_Import.cpp.o

The contents of Qt5Gui_QXcbIntegrationPlugin_Import.cpp are:

#include <QtPlugin>
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)

So I think we're doing that twice?

It seems we should either turn that off somehow, or remove the import from our code?

Nice catch! It happens on the staging branch as well. Investigating...

@hebasto
Copy link
Owner Author

hebasto commented Feb 25, 2024

I noticed while poking around that cmake adds: CMakeFiles/test_bitcoin-qt.dir/__/__/__/depends/x86_64-pc-linux-gnu/lib/cmake/Qt5Gui/Qt5Gui_QXcbIntegrationPlugin_Import.cpp.o

The contents of Qt5Gui_QXcbIntegrationPlugin_Import.cpp are:

#include <QtPlugin>
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)

So I think we're doing that twice?

It seems we should either turn that off somehow, or remove the import from our code?

@theuni

Thank you for this insight! Please consider #103.

This PR has been rebased on #103 and drafted for now.

@hebasto hebasto marked this pull request as draft February 25, 2024 10:10
@hebasto
Copy link
Owner Author

hebasto commented Mar 4, 2024

On Windows, the statically linked test_bitcoin.exe crashes with the minimal platform plugin, which is used by default.

Specifically, WalletTests and AddressBookTests fail due to an unhandled exception in the QMessageBox class.

This behavior differs from our custom static Qt build in the master branch, which does not crash :)

I believe that the root of the difference in behaviour lies in the following Qt configuration options:

There are two obvious workarounds for this unfortunate issue:

  1. Keep using our custom static Qt build for statically linked executables.
  2. Disable WalletTests and AddressBookTests for the minimal platform plugin as we do on macOS.

Thought?

cc @sipsorcery

@sipsorcery
Copy link

+1 to disable the tests for the dynamically linked version.

Reasoning being that the Windows build is for "developers only" and tracking down Qt bugs for a non-production build doesn't seem to offer a good effort to reward tradeoff.

Copy link

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

tACK cb1a44f

Tested on Ubuntu 22.04.

...
Tests:
  test_bitcoin ........................ ON
  test_bitcoin-qt ..................... ON
...

./build/src/qt/test/test_bitcoin-qt

Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
********* Start testing of AppTests *********
Config: Using QtTest library 5.15.3, Qt 5.15.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.3.0), ubuntu 22.04
...

All tests passed.

~InitExecutor : Stopping thread
~InitExecutor : Stopped thread

@hebasto
Copy link
Owner Author

hebasto commented Mar 5, 2024

#101 (comment):

Why? Because it requires a gui? Could you please add a comment?

A "TODO" comment with links to the issues has been added.

The mentioned issues have been fixed in bitcoin-core/gui#803. Please review it as well :)

hebasto added a commit that referenced this pull request Mar 8, 2024
f3b3928 fixup! cmake: Build `bitcoin-qt` executable (Hennadii Stepanov)
3c27391 qt: Drop `Q_IMPORT_PLUGIN` macros (Hennadii Stepanov)
edc8c18 qt, build: Drop `QT_STATICPLUGIN` macro (Hennadii Stepanov)

Pull request description:

  1. When using CMake, each plugin comes with a C++ stub file that automatically initializes the static plugin. Consequently, any target that links against a plugin has this C++ file added to its `SOURCES`, which makes the removed code redundant and [duplicates](#103 (comment)) the included plugins. For example, on the staging branch @ 1a976ca:
  ```
  2024-03-01T10:51:26Z Bitcoin Core version v26.99.0-1a976ca427ca (release build)
  2024-03-01T10:51:26Z Qt 5.15.11 (static), plugin=windows (static)
  2024-03-01T10:51:26Z Static plugins:
  2024-03-01T10:51:26Z  QWindowsIntegrationPlugin, version 331520
  2024-03-01T10:51:26Z  QWindowsVistaStylePlugin, version 331520
  2024-03-01T10:51:26Z  QWindowsVistaStylePlugin, version 331520
  2024-03-01T10:51:26Z  QWindowsIntegrationPlugin, version 331520
  2024-03-01T10:51:26Z Style: windowsvista / QWindowsVistaStyle
  2024-03-01T10:51:26Z System: Windows 11 Version 2009, x86_64-little_endian-llp64
  2024-03-01T10:51:26Z Screen: \\.\DISPLAY1 1920x1080, pixel ratio=1.0
  ```

  Initially noticed in #101 (review).

  Here are `LogQtInfo()` outputs in the `debug.log`:
  - `x86_64-pc-linux-gnu`:
  ```
  2024-02-25T10:15:18Z Qt 5.15.11 (static), plugin=xcb (static)
  2024-02-25T10:15:18Z Static plugins:
  2024-02-25T10:15:18Z  QXcbIntegrationPlugin, version 331520
  2024-02-25T10:15:18Z Style: fusion / QFusionStyle
  2024-02-25T10:15:18Z System: Ubuntu 22.04.4 LTS, x86_64-little_endian-lp64
  2024-02-25T10:15:18Z Screen: XWAYLAND0 1920x1080, pixel ratio=1.0
  ```
  - `x86_64-w64-mingw32`
  ```
  2024-02-25T10:44:54Z Qt 5.15.11 (static), plugin=windows (static)
  2024-02-25T10:44:54Z Static plugins:
  2024-02-25T10:44:54Z  QWindowsVistaStylePlugin, version 331520
  2024-02-25T10:44:54Z  QWindowsIntegrationPlugin, version 331520
  2024-02-25T10:44:54Z Style: windowsvista / QWindowsVistaStyle
  2024-02-25T10:44:54Z System: Windows 11 Version 2009, x86_64-little_endian-llp64
  2024-02-25T10:44:54Z Screen: \\.\DISPLAY1 1600x900, pixel ratio=1.0
  ```

  ---

  2. Apparently, Qt tries to link its default set of static plugins to every suitable target. When building on Windows, it leads to an insane list of plugins:
  ```
  2024-03-01T19:11:04Z Qt 5.15.10 (static), plugin=windows (dynamic)
  2024-03-01T19:11:04Z Static plugins:
  2024-03-01T19:11:04Z  QGifPlugin, version 331520
  2024-03-01T19:11:04Z  QICNSPlugin, version 331520
  2024-03-01T19:11:04Z  QICOPlugin, version 331520
  2024-03-01T19:11:04Z  QJpegPlugin, version 331520
  2024-03-01T19:11:04Z  QSvgIconPlugin, version 331520
  2024-03-01T19:11:04Z  QSvgPlugin, version 331520
  2024-03-01T19:11:04Z  QTgaPlugin, version 331520
  2024-03-01T19:11:04Z  QTiffPlugin, version 331520
  2024-03-01T19:11:04Z  QWbmpPlugin, version 331520
  2024-03-01T19:11:04Z  QWebpPlugin, version 331520
  2024-03-01T19:11:04Z  QWindowsIntegrationPlugin, version 331520
  2024-03-01T19:11:04Z  QWindowsVistaStylePlugin, version 331520
  ```

  Therefore, in this PR, we prevent Qt from such a behaviour.

ACKs for top commit:
  m3dwards:
    ACK f3b3928

Tree-SHA512: e77aad13349b6938d1c4c48c12a2e32226ef9b2c9e52e021df94a9a21b6bd0e42685f73f032eb5bfded9438f16edf2badac775200e941e18d73da85b0b817d3c
@hebasto hebasto marked this pull request as ready for review March 8, 2024 15:39
@hebasto
Copy link
Owner Author

hebasto commented Mar 9, 2024

Reworked. Rebased. Ready for review.

The PR description has been updated with Windows/MSVC specific notes.

Friendly ping @TheCharlatan @m3dwards @pablomartin4btc @vasild; and @sipsorcery (as a Windows expert) :)

@sipsorcery
Copy link

With a dynamic linked build on Windows I get:

PS C:\dev\github\hebasto-bitcoin\build> ctest -j $env:NUMBER_OF_PROCESSORS -C Release
...
...
99% tests passed, 1 tests failed out of 129

Total Test time (real) = 504.59 sec

The following tests FAILED:
         35 - fs_tests:fs_tests.cpp (Failed)
Errors while running CTest
Output from these tests are in: C:/dev/github/hebasto-bitcoin/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.

@hebasto
Copy link
Owner Author

hebasto commented Mar 9, 2024

With a dynamic linked build on Windows I get:

PS C:\dev\github\hebasto-bitcoin\build> ctest -j $env:NUMBER_OF_PROCESSORS -C Release
...
...
99% tests passed, 1 tests failed out of 129

Total Test time (real) = 504.59 sec

The following tests FAILED:
         35 - fs_tests:fs_tests.cpp (Failed)
Errors while running CTest
Output from these tests are in: C:/dev/github/hebasto-bitcoin/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.

Yes. That happens when a user has no privilege to create symbolic links. This issue is not specific to this PR change. However, it should be fixed.

@sipsorcery
Copy link

tACK 4da7634.

Copy link

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

re tACK e4b4c98

On Ubuntu 22.04.

./build/src/qt/test/test_bitcoin-qt

...

All tests passed.
...

ctest -j $(nproc)

...

100% tests passed, 0 tests failed out of 128

Total Test time (real) =  22.90 sec

Copy link

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

re tACK e4b4c98

Tested cross-building for Windows on WSL Ubuntu 22.04.

All tests passed. (running test_bitcoin-qt.exe successfully in both WSL and Windows 11 Pro)

@hebasto hebasto merged commit 83374fd into cmake-staging Mar 13, 2024
hebasto added a commit that referenced this pull request Mar 13, 2024
593b130 cmake: Add `libqrencode` optional package support (Hennadii Stepanov)

Pull request description:

  A new configuration option `WITH_QRENCODE` has been added.

  This PR, along with #101, concludes the GUI-specific part of the new CMake-based build system.

ACKs for top commit:
  pablomartin4btc:
    tACK 593b130

Tree-SHA512: ba21d65ccff59e29585bd6ce092216034abcbd9866e5452fe6a1b1e2f0957dc3c48a204c170ce443888852ae165be7cb1846483b031b8cf49e6d986dec722f88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants