summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-06-06 13:26:42 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-12 12:34:44 +0200
commite99fc91c585d5a5a6ec9e9196874f18b69254a5a (patch)
tree27c7a267e589331642dea2632f996e8a0131f45b
parentba1aefa85da937b20b47e21e31feb2d330d005e3 (diff)
iOS: Remove need for -force_load of platform plugin
Instead of force-loading the whole static library of the platform plugin we tell the linker to look for the missing symbol qt_registerPlatformPlugin. This symbol is provided by the same object file as the plugin's static initializer, so the object file is included in the final binary and the static initializer is run, resulting in the plugin registering with Qt. We could have marked the actual static initializer wrapper provided by Q_IMPORT_PLUGIN(QIOSIntegrationPlugin) as undefined, but due to the C++ mangling this would look less intuitive on the linker command line than the custom dummy function that we provide, which has C linkage. Change-Id: I6805537e1f49260a41d48c555376964cb1fe75d8 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
-rw-r--r--mkspecs/features/ios/default_post.prf24
-rw-r--r--src/plugins/platforms/ios/plugin.mm4
2 files changed, 18 insertions, 10 deletions
diff --git a/mkspecs/features/ios/default_post.prf b/mkspecs/features/ios/default_post.prf
index e55228ed4a..31efc4d418 100644
--- a/mkspecs/features/ios/default_post.prf
+++ b/mkspecs/features/ios/default_post.prf
@@ -11,17 +11,21 @@ isEmpty(MAKEFILE_GENERATOR) {
}
gui_app {
- # We have to do the link and dependency resolution for the platform plugin
- # manually, since QTPLUGIN and the prl lookup logic does not support
- # the -force_load link style. The -force_load option ensures that all
- # symbols from the static library are included, not just the ones the
- # linker have seen a use for so far. We need this because we load the platform
- # plugin from the platform plugin itself, using Q_IMPORT_PLUGIN.
- lib_path_and_base = $$[QT_INSTALL_PLUGINS/get]/platforms/libqios$$qtPlatformTargetSuffix()
- LIBS += -Wl,-force_load,$${lib_path_and_base}.$${QMAKE_EXTENSION_STATICLIB}
- LIBS += $$fromfile($${lib_path_and_base}.prl, QMAKE_PRL_LIBS)
+ LIBS *= -L$$[QT_INSTALL_PLUGINS/get]/platforms
- # Which means we don't want the auto-generated import for the platform plugin
+ lib_name = qios
+ lib_path_and_base = $$[QT_INSTALL_PLUGINS/get]/platforms/lib$${lib_name}$$qtPlatformTargetSuffix()
+ LIBS += -l$${lib_name}$$qtPlatformTargetSuffix() $$fromfile($${lib_path_and_base}.prl, QMAKE_PRL_LIBS)
+
+ # By marking qt_registerPlatformPlugin as undefined, we ensure that
+ # the plugin.o translation unit is considered for inclusion in
+ # the final binary, which in turn ensures that the plugin's
+ # static initializer is included and run.
+ QMAKE_LFLAGS += -u _qt_registerPlatformPlugin
+
+ # We do link and dependency resolution for the platform plugin
+ # manually, since we know we always need the plugin, so we don't
+ # need to generate an import for it.
CONFIG -= import_qpa_plugin
!no_main_wrapper {
diff --git a/src/plugins/platforms/ios/plugin.mm b/src/plugins/platforms/ios/plugin.mm
index a93b6037ad..ca8ec936ae 100644
--- a/src/plugins/platforms/ios/plugin.mm
+++ b/src/plugins/platforms/ios/plugin.mm
@@ -66,4 +66,8 @@ QT_END_NAMESPACE
#include "plugin.moc"
+// Dummy function that we explicitly tell the linker to look for,
+// so that the plugin's static initializer is included and run.
+extern "C" void qt_registerPlatformPlugin() {}
+
Q_IMPORT_PLUGIN(QIOSIntegrationPlugin)