Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.15.1
-
SoC: Nvidia
Integrity version: 11.7.8-r274944
GHS compiler version: v2018.1.4 (patched to resolve ARM Cortex-A53 Erratum ID 1183550)
-
-
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