build: make BITCOIN_QT_PATH_PROGS always check $PATH before failure #29653

pull cbergqvist wants to merge 1 commits into bitcoin:master from cbergqvist:bitcoin_qt_path_fallback changing 1 files +3 −0
  1. cbergqvist commented at 10:33 PM on March 14, 2024: contributor

    BITCOIN_QT_PATH_PROGS should conform to it's documentation for parameter $3:

    dnl Inputs: $3: Look for $2 here before $PATH

    Prior to the change, when $3 was specified, the function would not check $PATH. Fixing this resolves the case where the lrelease, lupdate and lconvert binaries live in a different directory than the other QT Base binaries, hindering ./configure from detecting them. The issue was observed on Nix(OS) which has different binary folders for nixpkgs.qt5.qtbase and nixpkgs.qt5.qttools, causing ./configure to not allow building bitcoin-qt.

    (This issue is GUI-related but involves the build system).

    Testing

    1. Install NixOS or the nix package manager (https://nixos.org/download/).
    2. Clone the Bitcoin Core repo.
    3. Copy shell.nix from https://gist.github.com/cbergqvist/7d9ce7663414214bb991007ab8138725 into the repo directory
    4. Run nix-shell from the CLI inside the repo directory.
    5. Run make clean && ./configure and observe change in output depending on whether this change is applied to the repo or not.

    Expected output from ./configure without the change

    checking for Qt5Core >= 5.11.3... yes
    checking for Qt5Gui >= 5.11.3... yes
    checking for Qt5Widgets >= 5.11.3... yes
    checking for Qt5Network >= 5.11.3... yes
    checking for Qt5Test >= 5.11.3... yes
    checking for Qt5DBus >= 5.11.3... yes
    checking for static Qt... no
    checking whether -fPIE can be used with this Qt config... no
    checking for moc-qt5... no
    checking for moc5... no
    checking for moc... /nix/store/78yxzzk2fb6am5v4dihalw9hrrj0rg8l-qtbase-5.15.12-dev/bin/moc
    checking for uic-qt5... no
    checking for uic5... no
    checking for uic... /nix/store/78yxzzk2fb6am5v4dihalw9hrrj0rg8l-qtbase-5.15.12-dev/bin/uic
    checking for rcc-qt5... no
    checking for rcc5... no
    checking for rcc... /nix/store/78yxzzk2fb6am5v4dihalw9hrrj0rg8l-qtbase-5.15.12-dev/bin/rcc
    checking for lrelease-qt5... no
    checking for lrelease5... no
    checking for lrelease... no
    configure: WARNING: LRELEASE not found; bitcoin-qt frontend will not be built
    checking whether to build Bitcoin Core GUI... no
    

    Expected output from ./configure with the change

    checking for Qt5Core >= 5.11.3... yes
    checking for Qt5Gui >= 5.11.3... yes
    checking for Qt5Widgets >= 5.11.3... yes
    checking for Qt5Network >= 5.11.3... yes
    checking for Qt5Test >= 5.11.3... yes
    checking for Qt5DBus >= 5.11.3... yes
    checking for static Qt... no
    checking whether -fPIE can be used with this Qt config... no
    checking for moc-qt5... no
    checking for moc5... no
    checking for moc... /nix/store/78yxzzk2fb6am5v4dihalw9hrrj0rg8l-qtbase-5.15.12-dev/bin/moc
    checking for uic-qt5... no
    checking for uic5... no
    checking for uic... /nix/store/78yxzzk2fb6am5v4dihalw9hrrj0rg8l-qtbase-5.15.12-dev/bin/uic
    checking for rcc-qt5... no
    checking for rcc5... no
    checking for rcc... /nix/store/78yxzzk2fb6am5v4dihalw9hrrj0rg8l-qtbase-5.15.12-dev/bin/rcc
    checking for lrelease-qt5... no
    checking for lrelease5... no
    checking for lrelease... no
    checking for lrelease-qt5... no
    checking for lrelease5... no
    checking for lrelease... /nix/store/4dc19x6k1ma72s13i4gs75amgsxz5jmy-qttools-5.15.12-dev/bin/lrelease
    checking for lupdate-qt5... no
    checking for lupdate5... no
    checking for lupdate... no
    checking for lupdate-qt5... no
    checking for lupdate5... no
    checking for lupdate... /nix/store/4dc19x6k1ma72s13i4gs75amgsxz5jmy-qttools-5.15.12-dev/bin/lupdate
    checking for lconvert-qt5... no
    checking for lconvert5... no
    checking for lconvert... no
    checking for lconvert-qt5... no
    checking for lconvert5... no
    checking for lconvert... /nix/store/4dc19x6k1ma72s13i4gs75amgsxz5jmy-qttools-5.15.12-dev/bin/lconvert
    checking whether to build Bitcoin Core GUI... yes (Qt5)
    
  2. build: make BITCOIN_QT_PATH_PROGS always check $PATH before failure
    `BITCOIN_QT_PATH_PROGS` should conform to it's documentation for parameter `$3`:
    > dnl Inputs: $3: Look for $2 here before $PATH
    
    Prior to the change, when `$3` was specified, the function would *not* check `$PATH`. Fixing this resolves the case where the `lrelease`, `lupdate` and `lconvert` binaries live in a different directory than the other QT Base binaries, hindering `./configure` from detecting them. The issue was observed on Nix(OS) which has different binary folders for `nixpkgs.qt5.qtbase` and `nixpkgs.qt5.qttools`, causing `./configure` to not allow building `bitcoin-qt`.
    7da77ee17d
  3. DrahtBot commented at 10:33 PM on March 14, 2024: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  4. DrahtBot added the label Build system on Mar 14, 2024
  5. hebasto commented at 10:03 AM on March 15, 2024: member

    cc @0xB10C

  6. hebasto commented at 10:27 AM on March 15, 2024: member

    @cbergqvist

    Thank you for working on this!

    The suggested approach seems fragile to me. For example, if our depends build system fails to build all qt tools, the main build system could silently pick them from the system packages:

    checking for lrelease-qt5... no
    checking for lrelease5... no
    checking for lrelease... no
    checking for lrelease-qt5... no
    checking for lrelease5... no
    checking for lrelease... /usr/bin/lrelease
    checking for lupdate-qt5... no
    checking for lupdate5... no
    checking for lupdate... /home/hebasto/git/bitcoin/depends/x86_64-pc-linux-gnu/native/bin/lupdate
    checking for lconvert-qt5... no
    checking for lconvert5... no
    checking for lconvert... /home/hebasto/git/bitcoin/depends/x86_64-pc-linux-gnu/native/bin/lconvert
    

    We are close to migrating the build system to CMake. You are encouraged to review and test the staging branch on NixOS :)

  7. cbergqvist commented at 3:08 PM on March 15, 2024: contributor

    Thanks for the timely feedback @hebasto! I'll move this to a draft and see if I can figure out a cleaner approach.

    Happy to test out the CMake branch when I get the time. :)

  8. cbergqvist marked this as a draft on Mar 15, 2024
  9. cbergqvist commented at 10:01 PM on March 15, 2024: contributor

    My latest understanding is that this issue stems from an ongoing struggle waged by the nixpkgs maintainers. Whereas other distros install qtbase and qttools binaries in the same dir, Nix has them in separate directories and cannot have qttools modify qtbase. Possible approaches could be to have qttools be an optional part of qtbase, or make some kind of aggregation derivation with symlinks back to the the binaries of the two derivations.

    Exhibits:

    1. https://github.com/NixOS/nixpkgs/pull/280943/files#diff-1842f86517293a0958f8b03fd0c28149b86c88bcd32276f9565b334c8f523610R39-R41
    2. https://github.com/NixOS/nixpkgs/blob/9af9c1c87ed3e3ed271934cb896e0cdd33dae212/pkgs/tools/graphics/gnuplot/default.nix#L44-L45
    3. https://github.com/NixOS/nixpkgs/blob/9af9c1c87ed3e3ed271934cb896e0cdd33dae212/pkgs/tools/graphics/nifskope/qttools-bins.patch#L18-L19

    Alternative solution

    Was able to resolve the situation through:

    • Undoing the change in this PR.
    • Modifying my shell.nix to specify both dirs to ./configure through --with-qt-bindir=${pkgs.qt5.qtbase.dev}/bin:${pkgs.qt5.qttools.dev}/bin (the linked gist in the summary has been updated).

    Possible remaining action

    One could still improve the BITCOIN_QT_PATH_PROGS documentation stating

    https://github.com/bitcoin/bitcoin/blob/015ac13dcc964a31ef06dfdb565f88f901607f0e/build-aux/m4/bitcoin_qt.m4#L33

    with

    dnl Inputs: $3: If specified, look for $2 here instead of $PATH
    

    But especially as it is being phased out in favor of CMake, I'm fine with just closing this PR.

    Will let it linger a few days in case anyone cares to comment.

  10. cbergqvist commented at 8:12 PM on March 19, 2024: contributor

    Closing as cleaner solution not requiring repo modifications was found.

    (Comment is still wrong but just a nit).

  11. cbergqvist closed this on Mar 19, 2024

  12. 0xB10C commented at 10:01 PM on March 19, 2024: contributor

    Tangentially, @cbergqvist do you think moving the shell.nix gist into a repo for better collaboration would make sense?

  13. cbergqvist deleted the branch on Mar 19, 2024
  14. cbergqvist commented at 10:09 PM on March 19, 2024: contributor

    Tangentially, @cbergqvist do you think moving the shell.nix gist into a repo for better collaboration would make sense?

    This Bitcoin Core repo might be a good place for a shell.nix. Someday. :)

    In seriousness, I support you moving it from a gist to a repo under your account which individuals like me might submit PRs to.

  15. bitcoin locked this on Mar 19, 2025

github-metadata-mirror

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: 2026-04-28 06:13 UTC

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