Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
6.0.0 Beta2
-
found on macOS, but probably affecting all platforms
-
e99cfb21d6018b36cdbc9832f9ce107569a92bf3 (qt/qtquickcontrols2/dev)
Description
The current method to ensure the initialisation of qml plugins with static builds is insufficient, and might skip the initialisation of them.
The main issue is that currently the registration code is just a registration function and a static const variable that initialises a QQmlModuleRegistration that does the registration.
The issue is that if no symbols from a compilation unit from a .a library are used, then the linker is free not to include it (this is not the case for an explicitly linked .o file).
This is for example the case for example for
libqtquickcontrols2macosstyleplugin.a(qtquickcontrols2macosstyleplugin_qmltyperegistrations.cpp.o):
0000000000000050 s _GLOBAL_sub_I_qtquickcontrols2macosstyleplugin_qmltyperegistrations.cpp
U __Z17qmlRegisterModulePKcii
0000000000000000 T __Z41qml_register_types_QtQuick_Controls_macOSv
0000000000005898 b __ZL12registration
U __ZN22QQmlModuleRegistrationC1EPKcPFvvE
U __ZN22QQmlModuleRegistrationD1Ev
U ___cxa_atexit
U ___dso_handle
Indeed it might be surprising that this was not seen before, but there is another things that hides it and makes it work in many occasions: the registration of QMetaTypes, templates or other stuff fro .h files that then make the module "used" and thus trigger its inclusion in the final binary.
To fix this one we need to either include an explicit external symbol from there, explicitly call the initialisation function or similar approaches.