Blame SOURCES/0007-Avoid-GHS-linker-to-optimize-away-QML-type-registrat.patch

b602f4
From e749605ecbe76c392552d0e3a75f47b31bed9ba1 Mon Sep 17 00:00:00 2001
b602f4
From: Kimmo Ollila <kimmo.ollila@qt.io>
b602f4
Date: Wed, 11 Nov 2020 12:23:53 +0200
b602f4
Subject: [PATCH 07/28] Avoid GHS linker to optimize away QML type
b602f4
 registrations
b602f4
b602f4
GHS linker optimizes away QML type registrations despite volatile.
b602f4
To prevent this we add #pragma ghs reference(s) to avoid such linker
b602f4
optimization.
b602f4
b602f4
Fixes: QTBUG-88033
b602f4
Change-Id: I7c8983506360710185c37028873234b1464847d5
b602f4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
b602f4
---
b602f4
 src/imports/folderlistmodel/plugin.cpp          | 1 +
b602f4
 src/imports/labsanimation/plugin.cpp            | 1 +
b602f4
 src/imports/labsmodels/plugin.cpp               | 1 +
b602f4
 src/imports/layouts/plugin.cpp                  | 1 +
b602f4
 src/imports/localstorage/plugin.cpp             | 1 +
b602f4
 src/imports/settings/plugin.cpp                 | 1 +
b602f4
 src/imports/sharedimage/plugin.cpp              | 1 +
b602f4
 src/imports/statemachine/plugin.cpp             | 1 +
b602f4
 src/imports/testlib/main.cpp                    | 1 +
b602f4
 src/imports/wavefrontmesh/plugin.cpp            | 1 +
b602f4
 src/imports/window/plugin.cpp                   | 1 +
b602f4
 src/particles/qtquickparticlesglobal_p.h        | 1 +
b602f4
 src/qml/qml/qqmlextensionplugin.h               | 7 +++++++
b602f4
 src/qml/qtqmlglobal_p.h                         | 2 ++
b602f4
 src/qmlmodels/qtqmlmodelsglobal_p.h             | 1 +
b602f4
 src/qmlworkerscript/qtqmlworkerscriptglobal_p.h | 1 +
b602f4
 src/quick/qtquickglobal_p.h                     | 1 +
b602f4
 src/quickshapes/qquickshapesglobal_p.h          | 2 ++
b602f4
 18 files changed, 26 insertions(+)
b602f4
b602f4
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp
b602f4
index 7a38769b77..7206df6664 100644
b602f4
--- a/src/imports/folderlistmodel/plugin.cpp
b602f4
+++ b/src/imports/folderlistmodel/plugin.cpp
b602f4
@@ -43,6 +43,7 @@
b602f4
 #include "qquickfolderlistmodel.h"
b602f4
 
b602f4
 extern void qml_register_types_Qt_labs_folderlistmodel();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_Qt_labs_folderlistmodel);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/imports/labsanimation/plugin.cpp b/src/imports/labsanimation/plugin.cpp
b602f4
index 9c985f0dcf..c35be764f9 100644
b602f4
--- a/src/imports/labsanimation/plugin.cpp
b602f4
+++ b/src/imports/labsanimation/plugin.cpp
b602f4
@@ -43,6 +43,7 @@
b602f4
 #include "qquickboundaryrule_p.h"
b602f4
 
b602f4
 extern void qml_register_types_Qt_labs_animation();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_Qt_labs_animation);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/imports/labsmodels/plugin.cpp b/src/imports/labsmodels/plugin.cpp
b602f4
index ab5e0023a6..b06491e663 100644
b602f4
--- a/src/imports/labsmodels/plugin.cpp
b602f4
+++ b/src/imports/labsmodels/plugin.cpp
b602f4
@@ -51,6 +51,7 @@
b602f4
 #endif
b602f4
 
b602f4
 extern void qml_register_types_Qt_labs_qmlmodels();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_Qt_labs_qmlmodels);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/imports/layouts/plugin.cpp b/src/imports/layouts/plugin.cpp
b602f4
index af270c1732..b6ae516eee 100644
b602f4
--- a/src/imports/layouts/plugin.cpp
b602f4
+++ b/src/imports/layouts/plugin.cpp
b602f4
@@ -43,6 +43,7 @@
b602f4
 #include "qquickstacklayout_p.h"
b602f4
 
b602f4
 extern void qml_register_types_QtQuick_Layouts();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtQuick_Layouts);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
b602f4
index e488b3d43c..0291ed4715 100644
b602f4
--- a/src/imports/localstorage/plugin.cpp
b602f4
+++ b/src/imports/localstorage/plugin.cpp
b602f4
@@ -43,6 +43,7 @@
b602f4
 #include <QtQml/qqml.h>
b602f4
 
b602f4
 extern void qml_register_types_QtQuick_LocalStorage();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtQuick_LocalStorage);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/imports/settings/plugin.cpp b/src/imports/settings/plugin.cpp
b602f4
index e8e640412b..e83147f612 100644
b602f4
--- a/src/imports/settings/plugin.cpp
b602f4
+++ b/src/imports/settings/plugin.cpp
b602f4
@@ -43,6 +43,7 @@
b602f4
 #include "qqmlsettings_p.h"
b602f4
 
b602f4
 extern void qml_register_types_Qt_labs_settings();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_Qt_labs_settings);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/imports/sharedimage/plugin.cpp b/src/imports/sharedimage/plugin.cpp
b602f4
index d7c2ef8d17..79168d933b 100644
b602f4
--- a/src/imports/sharedimage/plugin.cpp
b602f4
+++ b/src/imports/sharedimage/plugin.cpp
b602f4
@@ -100,6 +100,7 @@
b602f4
 */
b602f4
 
b602f4
 extern void qml_register_types_Qt_labs_sharedimage();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_Qt_labs_sharedimage);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp
b602f4
index c370504029..abb238965e 100644
b602f4
--- a/src/imports/statemachine/plugin.cpp
b602f4
+++ b/src/imports/statemachine/plugin.cpp
b602f4
@@ -49,6 +49,7 @@
b602f4
 #include <qqml.h>
b602f4
 
b602f4
 extern void qml_register_types_QtQml_StateMachine();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtQml_StateMachine);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp
b602f4
index 83fc150e6c..1da251c49b 100644
b602f4
--- a/src/imports/testlib/main.cpp
b602f4
+++ b/src/imports/testlib/main.cpp
b602f4
@@ -51,6 +51,7 @@ QML_DECLARE_TYPE(QuickTestEvent)
b602f4
 QML_DECLARE_TYPE(QuickTestUtil)
b602f4
 
b602f4
 extern void qml_register_types_QtTest();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtTest);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/imports/wavefrontmesh/plugin.cpp b/src/imports/wavefrontmesh/plugin.cpp
b602f4
index eea0db19db..edd4d1dba5 100644
b602f4
--- a/src/imports/wavefrontmesh/plugin.cpp
b602f4
+++ b/src/imports/wavefrontmesh/plugin.cpp
b602f4
@@ -43,6 +43,7 @@
b602f4
 #include "qwavefrontmesh.h"
b602f4
 
b602f4
 extern void qml_register_types_Qt_labs_wavefrontmesh();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_Qt_labs_wavefrontmesh);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/imports/window/plugin.cpp b/src/imports/window/plugin.cpp
b602f4
index 5152fa02ec..ff2f10fde3 100644
b602f4
--- a/src/imports/window/plugin.cpp
b602f4
+++ b/src/imports/window/plugin.cpp
b602f4
@@ -42,6 +42,7 @@
b602f4
 #include "plugin.h"
b602f4
 
b602f4
 extern void qml_register_types_QtQuick_Window();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtQuick_Window);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/particles/qtquickparticlesglobal_p.h b/src/particles/qtquickparticlesglobal_p.h
b602f4
index 927bc29050..91c2764060 100644
b602f4
--- a/src/particles/qtquickparticlesglobal_p.h
b602f4
+++ b/src/particles/qtquickparticlesglobal_p.h
b602f4
@@ -66,5 +66,6 @@
b602f4
 #endif
b602f4
 
b602f4
 void Q_QUICKPARTICLES_PRIVATE_EXPORT qml_register_types_QtQuick_Particles();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtQuick_Particles);
b602f4
 
b602f4
 #endif // QTQUICKPARTICLESGLOBAL_P_H
b602f4
diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h
b602f4
index ef7ff422cd..afb3f99c4a 100644
b602f4
--- a/src/qml/qml/qqmlextensionplugin.h
b602f4
+++ b/src/qml/qml/qqmlextensionplugin.h
b602f4
@@ -44,6 +44,13 @@
b602f4
 #include <QtCore/QUrl>
b602f4
 #include <QtQml/qqmlextensioninterface.h>
b602f4
 
b602f4
+#if defined(Q_CC_GHS)
b602f4
+#  define GHS_PRAGMA(S) _Pragma(#S)
b602f4
+#  define GHS_KEEP_REFERENCE(S) GHS_PRAGMA(ghs reference S ##__Fv)
b602f4
+#else
b602f4
+#  define GHS_KEEP_REFERENCE(S)
b602f4
+#endif
b602f4
+
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
 class QQmlEngine;
b602f4
diff --git a/src/qml/qtqmlglobal_p.h b/src/qml/qtqmlglobal_p.h
b602f4
index a729729b67..7b0910fa13 100644
b602f4
--- a/src/qml/qtqmlglobal_p.h
b602f4
+++ b/src/qml/qtqmlglobal_p.h
b602f4
@@ -53,6 +53,7 @@
b602f4
 
b602f4
 #include <QtCore/private/qglobal_p.h>
b602f4
 #include <QtQml/qtqmlglobal.h>
b602f4
+#include <QtQml/qqmlextensionplugin.h>
b602f4
 #ifndef QT_QML_BOOTSTRAPPED
b602f4
 #  include <QtQml/private/qtqml-config_p.h>
b602f4
 #endif
b602f4
@@ -61,6 +62,7 @@
b602f4
 #define Q_QML_PRIVATE_EXPORT Q_QML_EXPORT
b602f4
 
b602f4
 void Q_QML_PRIVATE_EXPORT qml_register_types_QtQml();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtQml);
b602f4
 
b602f4
 #if !defined(QT_QMLDEVTOOLS_LIB) && !defined(QT_BUILD_QMLDEVTOOLS_LIB)
b602f4
 #  define Q_QML_AUTOTEST_EXPORT Q_AUTOTEST_EXPORT
b602f4
diff --git a/src/qmlmodels/qtqmlmodelsglobal_p.h b/src/qmlmodels/qtqmlmodelsglobal_p.h
b602f4
index 1a1157138d..24df6ef7b3 100644
b602f4
--- a/src/qmlmodels/qtqmlmodelsglobal_p.h
b602f4
+++ b/src/qmlmodels/qtqmlmodelsglobal_p.h
b602f4
@@ -59,5 +59,6 @@
b602f4
 #define Q_QMLMODELS_AUTOTEST_EXPORT Q_AUTOTEST_EXPORT
b602f4
 
b602f4
 void Q_QMLMODELS_PRIVATE_EXPORT qml_register_types_QtQml_Models();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtQml_Models);
b602f4
 
b602f4
 #endif // QTQMLMODELSGLOBAL_P_H
b602f4
diff --git a/src/qmlworkerscript/qtqmlworkerscriptglobal_p.h b/src/qmlworkerscript/qtqmlworkerscriptglobal_p.h
b602f4
index c75d5f3129..6452567f6b 100644
b602f4
--- a/src/qmlworkerscript/qtqmlworkerscriptglobal_p.h
b602f4
+++ b/src/qmlworkerscript/qtqmlworkerscriptglobal_p.h
b602f4
@@ -58,5 +58,6 @@
b602f4
 #define Q_QMLWORKERSCRIPT_AUTOTEST_EXPORT Q_AUTOTEST_EXPORT
b602f4
 
b602f4
 void Q_QMLWORKERSCRIPT_PRIVATE_EXPORT qml_register_types_QtQml_WorkerScript();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtQml_WorkerScript);
b602f4
 
b602f4
 #endif // QTQMLWORKERSCRIPTGLOBAL_P_H
b602f4
diff --git a/src/quick/qtquickglobal_p.h b/src/quick/qtquickglobal_p.h
b602f4
index 80e59563c7..97680569e7 100644
b602f4
--- a/src/quick/qtquickglobal_p.h
b602f4
+++ b/src/quick/qtquickglobal_p.h
b602f4
@@ -62,6 +62,7 @@
b602f4
 #define Q_QUICK_PRIVATE_EXPORT Q_QUICK_EXPORT
b602f4
 
b602f4
 void Q_QUICK_PRIVATE_EXPORT qml_register_types_QtQuick();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtQuick);
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
 
b602f4
diff --git a/src/quickshapes/qquickshapesglobal_p.h b/src/quickshapes/qquickshapesglobal_p.h
b602f4
index 40f6cfbdcf..37386c23b2 100644
b602f4
--- a/src/quickshapes/qquickshapesglobal_p.h
b602f4
+++ b/src/quickshapes/qquickshapesglobal_p.h
b602f4
@@ -51,6 +51,7 @@
b602f4
 // We mean it.
b602f4
 //
b602f4
 
b602f4
+#include <QtQml/qqmlextensionplugin.h>
b602f4
 #include "qquickshapesglobal.h"
b602f4
 
b602f4
 QT_BEGIN_NAMESPACE
b602f4
@@ -60,5 +61,6 @@ QT_BEGIN_NAMESPACE
b602f4
 QT_END_NAMESPACE
b602f4
 
b602f4
 void Q_QUICKSHAPES_PRIVATE_EXPORT qml_register_types_QtQuick_Shapes();
b602f4
+GHS_KEEP_REFERENCE(qml_register_types_QtQuick_Shapes);
b602f4
 
b602f4
 #endif // QQUICKSHAPESGLOBAL_P_H
b602f4
-- 
b602f4
2.31.1
b602f4