diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index cdad83a4670..70cf942a4a1 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -2268,6 +2268,20 @@ struct QDataStreamOperatorForType static constexpr QMetaTypeInterface::DataStreamInFn dataStreamIn = nullptr; }; +// Performance optimization: +// +// Don't add all these symbols to the dynamic symbol tables on ELF systems and +// on Darwin. Each library is going to have a copy anyway and QMetaType already +// copes with some of these being "hidden" (see QMetaType::idHelper()). We may +// as well let the linker know it can always use the local copy. +// +// This is currently not enabled for GCC due to +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106023 + +#if !defined(Q_OS_WIN) && defined(Q_CC_CLANG) +# pragma GCC visibility push(hidden) +#endif + template class QMetaTypeForType { @@ -2358,6 +2372,9 @@ struct QMetaTypeInterfaceWrapper }; }; +#if !defined(Q_OS_WIN) && defined(Q_CC_CLANG) +# pragma GCC visibility pop +#endif template<> class QMetaTypeInterfaceWrapper diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp index 11dc593ebb7..265ec3095f5 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp @@ -522,6 +522,14 @@ void tst_QMetaType::operatorEqAcrossLibs() QCOMPARE(QByteArray(lib2Type.name()), QByteArray(localType.name())); QCOMPARE(lib1Type, localType); QCOMPARE(lib2Type, localType); + +#if !defined(Q_OS_WIN) && !defined(Q_OS_INTEGRITY) + if (actualTypeId < QMetaType::FirstGuiType && actualTypeId != QMetaType::Void) { + // for built-in QtCore types, we expect the interfaces to be the same too + QCOMPARE(lib1Iface, localIface); + QCOMPARE(lib2Iface, localIface); + } +#endif } class WithPrivateDTor {