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

[integrity] static release build fails to register QML plugins

    XMLWordPrintable

Details

    • Integrity
    • e749605ecbe76c392552d0e3a75f47b31bed9ba1 (qt/qtdeclarative/5.15)

    Description

      When building applications in release static mode. It seems that QML plugin registration functions are optimized out and therefore it fails to load the plugins.
      So for example in case of QML Window plugin we get the following error from Qt:

      qrc:/main.qml:2:1: static plugin for module "QtQuick.Window" with name "QtQuick2WindowPlugin" cannot be loaded: Cannot protect module QtQuick.Window 2 as it was never registered
      

      Looking the code here:
      https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/imports/window/plugin.cpp?h=5.15.1

      In line 44 we have:

      extern void qml_register_types_QtQuick_Window();

      and in line 71 we have:

      volatile auto registration = &qml_register_types_QtQuick_Window;

      It seems that despite volatile it gets optimized away in our release builds.
      Checking the application binary built in debug mode I can see

      readelf testapp -a |grep qml_register

      37772: 000000000028cc28   164 FUNC    GLOBAL DEFAULT    2 qml_register_types_QtQuic
      56045: 00000000003511c4  2532 FUNC    GLOBAL DEFAULT    2 qml_register_types_QtQuic
      304008: 0000000000d5e9e0   212 FUNC    GLOBAL DEFAULT    2 qml_register_types_QtQml_
      307329: 0000000000d6f098    52 FUNC    GLOBAL DEFAULT    2 qml_register_types_QtQml_
      437273: 00000000011b53c0   196 FUNC    GLOBAL DEFAULT    2 qml_register_types_QtQml_
      

      ...and in case of release build these are missing

      The difference between optimization flags used in builds:

      debug build: -g -Omaxdebug
      release build: -Ospeed -Olink -Omax

      Attachments

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

        Activity

          People

            kiollila Kimmo Ollila
            karimpinter Karim Pinter (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes