QOperatingSystemVersion: fix ABI problem with dllimport on Windows

I'm not entirely sure whether this is a toolchain bug or if this is
intended. This commit ODR-uses all the static inline variables in
QOperatingSystemVersion so they are added to the list of exported
symbols in QtCore.

On Windows:

$ objdump -p bin/Qt6Core.dll | grep Windows11E
        [2534] _ZN23QOperatingSystemVersion9Windows11E

On Linux:

$ eu-readelf --dyn-syms lib/libQt6Core.so | grep Windows11E
 1985: 0000000000575430     16 OBJECT  GNU_UNIQUE PROTECTED     18 _ZN23QOperatingSystemVersion9Windows11E@@Qt_6

Pick-to: 6.4
Change-Id: Ia317fd249bcd80dbd02c198803a3a61178c0c219
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Thiago Macieira 2022-10-25 10:50:31 -07:00
parent 887bdc5e73
commit bfd8463f4d
2 changed files with 45 additions and 0 deletions

View File

@ -399,6 +399,7 @@ const QOperatingSystemVersion QOperatingSystemVersion::Windows10 =
Version 1809 (version 10.0.17763).
\since 6.3
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows10_1809;
/*!
\variable QOperatingSystemVersion::Windows10_1903
@ -406,6 +407,7 @@ const QOperatingSystemVersion QOperatingSystemVersion::Windows10 =
Version 1903 (version 10.0.18362).
\since 6.3
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows10_1903;
/*!
\variable QOperatingSystemVersion::Windows10_1909
@ -413,6 +415,7 @@ const QOperatingSystemVersion QOperatingSystemVersion::Windows10 =
Version 1909 (version 10.0.18363).
\since 6.3
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows10_1909;
/*!
\variable QOperatingSystemVersion::Windows10_2004
@ -420,6 +423,7 @@ const QOperatingSystemVersion QOperatingSystemVersion::Windows10 =
Version 2004 (version 10.0.19041).
\since 6.3
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows10_2004;
/*!
\variable QOperatingSystemVersion::Windows10_20H2
@ -427,6 +431,7 @@ const QOperatingSystemVersion QOperatingSystemVersion::Windows10 =
Version 20H2 (version 10.0.19042).
\since 6.3
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows10_20H2;
/*!
\variable QOperatingSystemVersion::Windows10_21H1
@ -434,6 +439,7 @@ const QOperatingSystemVersion QOperatingSystemVersion::Windows10 =
Version 21H1 (version 10.0.19043).
\since 6.3
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows10_21H1;
/*!
\variable QOperatingSystemVersion::Windows10_21H2
@ -441,6 +447,7 @@ const QOperatingSystemVersion QOperatingSystemVersion::Windows10 =
Version 21H2 (version 10.0.19044).
\since 6.3
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows10_21H2;
/*!
\variable QOperatingSystemVersion::Windows10_22H2
@ -448,6 +455,7 @@ const QOperatingSystemVersion QOperatingSystemVersion::Windows10 =
Version 22H2 (version 10.0.19045).
\since 6.5
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows10_22H2;
/*!
\variable QOperatingSystemVersion::Windows11
@ -455,18 +463,21 @@ const QOperatingSystemVersion QOperatingSystemVersion::Windows10 =
(version 10.0.22000).
\since 6.3
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows11;
/*!
\variable QOperatingSystemVersion::Windows11_21H2
\brief a version corresponding to Windows 11 Version 21H2 (version 10.0.22000).
\since 6.4
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows11_21H2;
/*!
\variable QOperatingSystemVersion::Windows11_22H2
\brief a version corresponding to Windows 11 Version 22H2 (version 10.0.22621).
\since 6.4
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Windows11_22H2;
/*!
\variable QOperatingSystemVersion::OSXMavericks
@ -558,6 +569,7 @@ const QOperatingSystemVersion QOperatingSystemVersion::MacOSMonterey =
\brief a version corresponding to macOS Ventura (version 13).
\since 6.4
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::MacOSVentura;
/*!
\variable QOperatingSystemVersion::AndroidJellyBean
@ -680,18 +692,21 @@ const QOperatingSystemVersion QOperatingSystemVersion::Android11 =
\brief a version corresponding to Android 12 (version 12.0, API level 31).
\since 6.5
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Android12;
/*!
\variable QOperatingSystemVersion::Android12L
\brief a version corresponding to Android 12L (version 12.0, API level 32).
\since 6.5
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Android12L;
/*!
\variable QOperatingSystemVersion::Android13
\brief a version corresponding to Android 13 (version 13.0, API level 33).
\since 6.5
*/
const QOperatingSystemVersionBase QOperatingSystemVersion::Android13;
#endif // !QT_BOOTSTRAPPED

View File

@ -10,6 +10,8 @@ class tst_QOperatingSystemVersion : public QObject
private slots:
void construction_data();
void construction();
void globals_data();
void globals();
void anyOf();
@ -52,6 +54,34 @@ void tst_QOperatingSystemVersion::construction()
QVERIFY(!systemVersion.name().isEmpty());
}
void tst_QOperatingSystemVersion::globals_data()
{
QTest::addColumn<QOperatingSystemVersion>("osver");
QTest::addColumn<QOperatingSystemVersion::OSType>("osType");
#define ADDROW(os) QTest::newRow(#os) << QOperatingSystemVersion(QOperatingSystemVersion::os)
// legacy ones (global variables)
ADDROW(Windows7) << QOperatingSystemVersion::Windows;
ADDROW(Windows10) << QOperatingSystemVersion::Windows;
ADDROW(OSXMavericks) << QOperatingSystemVersion::MacOS;
ADDROW(MacOSMonterey) << QOperatingSystemVersion::MacOS;
ADDROW(AndroidJellyBean) << QOperatingSystemVersion::Android;
ADDROW(Android11) << QOperatingSystemVersion::Android;
// new ones (static constexpr)
ADDROW(Windows11) << QOperatingSystemVersion::Windows;
ADDROW(Android12) << QOperatingSystemVersion::Android;
#undef ADDROW
}
void tst_QOperatingSystemVersion::globals()
{
QFETCH(QOperatingSystemVersion, osver);
QFETCH(QOperatingSystemVersion::OSType, osType);
QCOMPARE(osver.type(), osType);
QCOMPARE_NE(osver.majorVersion(), 0);
}
void tst_QOperatingSystemVersion::anyOf()
{
std::initializer_list<QOperatingSystemVersion::OSType> typesToCheck = {