diff options
| author | Tatiana Borisova <tatiana.borisova@qt.io> | 2021-07-22 19:57:34 +0300 |
|---|---|---|
| committer | Tatiana Borisova <tatiana.borisova@qt.io> | 2021-08-02 18:58:47 +0300 |
| commit | 682f783937a8bdb36407c089bf1bdb8ab43d80e6 (patch) | |
| tree | 8183c79a9b70a9f5b2ba80ad32d5d45251648713 /src | |
| parent | 1ff3785348f1b6c1ccc49908f1c94c8b49b1712f (diff) | |
Avoid GHS linker to optimize away QML type registrations
GHS linker optimizes away QML type registrations despite volatile.
To prevent this we add #pragma ghs reference(s) to avoid such linker
optimization.
Task-number: QTBUG-94846
Pick-to: 6.2
Change-Id: I6ae2d350e532d2035c300a024cb000014293e1a0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 2 | ||||
| -rw-r--r-- | src/qml/qml/qqmlextensionplugin.h | 6 | ||||
| -rw-r--r-- | src/quick/qtquickplugin.cpp | 3 | ||||
| -rw-r--r-- | src/quickshapes/qquickshapesplugin.cpp | 3 |
4 files changed, 13 insertions, 1 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index 5f8313db5a..92ac050bcc 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -975,7 +975,7 @@ function(qt6_add_qml_plugin target) # These are all substituted in the template file used further below set(qt_qml_plugin_class_name "${arg_CLASS_NAME}") set(qt_qml_plugin_moc_include_name "${generated_cpp_file_name_base}.moc") - set(qt_qml_plugin_intro "extern void ${register_types_function_name}();") + set(qt_qml_plugin_intro "extern void ${register_types_function_name}();\nQ_GHS_KEEP_REFERENCE(${register_types_function_name});") set(qt_qml_plugin_outro "") if(QT_BUILDING_QT) string(APPEND qt_qml_plugin_intro "\n\nQT_BEGIN_NAMESPACE") diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h index 09018e0dc7..34c8af7a14 100644 --- a/src/qml/qml/qqmlextensionplugin.h +++ b/src/qml/qml/qqmlextensionplugin.h @@ -44,6 +44,12 @@ #include <QtCore/QUrl> #include <QtQml/qqmlextensioninterface.h> +#if defined(Q_CC_GHS) +# define Q_GHS_KEEP_REFERENCE(S) QT_DO_PRAGMA(ghs reference S ##__Fv) +#else +# define Q_GHS_KEEP_REFERENCE(S) +#endif + #define Q_IMPORT_QML_PLUGIN(PLUGIN) \ Q_IMPORT_PLUGIN(PLUGIN) diff --git a/src/quick/qtquickplugin.cpp b/src/quick/qtquickplugin.cpp index e4ceee15a9..eeca8eac5e 100644 --- a/src/quick/qtquickplugin.cpp +++ b/src/quick/qtquickplugin.cpp @@ -42,6 +42,9 @@ QT_BEGIN_NAMESPACE +Q_GHS_KEEP_REFERENCE(qml_register_types_QtQuick); +Q_GHS_KEEP_REFERENCE(QQuick_initializeModule); + class QtQuick2Plugin : public QQmlEngineExtensionPlugin { Q_OBJECT diff --git a/src/quickshapes/qquickshapesplugin.cpp b/src/quickshapes/qquickshapesplugin.cpp index 587c546fca..513160db60 100644 --- a/src/quickshapes/qquickshapesplugin.cpp +++ b/src/quickshapes/qquickshapesplugin.cpp @@ -41,6 +41,9 @@ #include <QtQml/qqml.h> #include <QtQuickShapes/private/qquickshape_p.h> +Q_GHS_KEEP_REFERENCE(qml_register_types_QtQuick_Shapes); +Q_GHS_KEEP_REFERENCE(QQuickShapes_initializeModule); + QT_BEGIN_NAMESPACE class QmlShapesPlugin : public QQmlEngineExtensionPlugin |
