Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-97599

Internal Qt builds prefer target Tools packages over host packages

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 6.3.0 Alpha
    • 6.2.0
    • Build System: CMake
    • None
    • 9ed274a48dc45ec05a834fa02c54dff09613934e (qt/qtbase/dev) 4cf3b724fc652aebaf2a68c60187b40b1507fcfb (qt/qtbase/6.2)

    Description

      While trying to repro locally QTBUG-86533 I tried to configure and build qtbase against a Qt provided yocto sdk.
      In my case "Boot 2 Qt for NXP i.MX 8M Mini" installed at
      /home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/x86_64-pokysdk-linux

      Sourcing the shell environment

      source /home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/environment-setup-cortexa53-crypto-poky-linux
      

      Configuring qtbase with

      cmake ../../../src/qtbase -DQT_HOST_PATH=/home/alex/Dev/qt/official_qt5/6.2.0/gcc_64 -DCMAKE_TOOLCHAIN_FILE=/home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake -DWARNINGS_ARE_ERRORS=OFF -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DFEATURE_developer_build=ON
      

      failed with

      -- Searching for tool 'Qt6::uic' in package Qt6WidgetsTools.
      CMake Error at /home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/cortexa53-crypto-poky-linux/usr/lib/cmake/Qt6GuiTools/Qt6GuiToolsTargets.cmake:85 (message):
        The imported target "Qt6::qvkgen" references the file
      
           "/home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/cortexa53-crypto-poky-linux/usr/libexec/qvkgen"
      
        but this file does not exist.  Possible reasons include:
      
        * The file was deleted, renamed, or moved to another location.
      
        * An install or uninstall procedure did not complete successfully.
      
        * The installation package was faulty and contained
      
           "/home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/cortexa53-crypto-poky-linux/usr/lib/cmake/Qt6GuiTools/Qt6GuiToolsTargets.cmake"
      
        but not all the files it references.
      
      Call Stack (most recent call first):
        /home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/cortexa53-crypto-poky-linux/usr/lib/cmake/Qt6GuiTools/Qt6GuiToolsConfig.cmake:47 (include)
        /home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.19/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
        /home/alex/Dev/qt/official_qt5/6.2.0/gcc_64/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsDependencies.cmake:9 (find_dependency)
        /home/alex/Dev/qt/official_qt5/6.2.0/gcc_64/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake:34 (include)
        cmake/QtToolHelpers.cmake:92 (find_package)
        src/tools/uic/CMakeLists.txt:8 (qt_internal_add_tool)
      
      
      CMake Warning at cmake/QtToolHelpers.cmake:92 (find_package):
        Found package configuration file:
      
          /home/alex/Dev/qt/official_qt5/6.2.0/gcc_64/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake
      
        but it set Qt6WidgetsTools_FOUND to FALSE so package "Qt6WidgetsTools" is
        considered to be NOT FOUND.
      Call Stack (most recent call first):
        src/tools/uic/CMakeLists.txt:8 (qt_internal_add_tool)
      

      Apart from the fact that it's a bug that the SDK ships a package config file saying a tool exists in the device sysroot but actually it doesn't, what's unexpected is that the device package Tools package is picked up instead of the one specified in QT_HOST_PATH.

      It appears it's an issue with how we recursively call find_package from qt_internal_add_tool.
      https://github.com/qt/qtbase/blob/44b7a1a37b18defcf27cee4fb5f6f8695387965d/cmake/QtToolHelpers.cmake#L92

      0) qt_internal_add_tool(uic) successfully finds Qt6WidgetTools in the host path.
      We set CMAKE_PREFIX_PATH to QT_HOST_PATH, flip CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to BOTH, and set all the NO_ options to ensure the host WidgetsTools package is found.

      1)
      Now we try to find Qt6GuiTools as a recursive dependency inside Qt6WidgetsToolsDependencies.cmake.
      This in turn uses different find_package options
      https://github.com/qt/qtbase/blob/44b7a1a37b18defcf27cee4fb5f6f8695387965d/cmake/QtModuleDependencies.cmake.in#L71

      2) I don't yet have a 100% sure explanation on what happens next, but.

      The /target/ Qt6GuiTools is found because despite CMAKE_PREFIX_PATH == QT_HOST_PATH.
      Why? Because now the system env PATH is taken into account as well (because no more NO_ options are used) and the sourced shell script appends the device sysroot to PATH in multiple forms.

      # With CMAKE_FIND_DEBUG_MODE set to TRUE
      
      Standard system environment variables
        [CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].
      /home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/x86_64-pokysdk-linux/usr
          /home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/x86_64-pokysdk-linux
          /home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/x86_64-pokysdk-linux/usr/x86_64-pokysdk-linux
          /home/alex/Dev/qt/official_qt5/6.2.0/Boot2Qt/imx8mm-lpddr4-evk/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux
      

      find_package docs says

      Standard system environment variables
        By default at first the directories listed in CMAKE_FIND_ROOT_PATH are searched, then the CMAKE_SYSROOT directory is searched, and then the non-rooted directories will be searched.
      

      I suspect https://gitlab.kitware.com/cmake/cmake/-/issues/21937 comes into play and somehow CMake ends up preferring one of the the env paths above because the previous qt_internal_add_tool call has set CMAKE_FIND_ROOT_PATH_MODE to BOTH

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              alexandru.croitor Alexandru Croitor
              alexandru.croitor Alexandru Croitor
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes