From b82559244e2dc03f1ceff66bb67630df4300dc7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 30 Nov 2018 14:51:18 +0100 Subject: macOS: Account for LC_BUILD_VERSION when checking SDK version and deployment target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The more modern LC_BUILD_VERSION load command was introduced in the 10.13 SDK to unify the various versions of the LC_*_VERSION_MIN command. When building with a deployment target of 10.14, the linker will use this load command instead. Change-Id: Ic3571fdbfdf4dfb9346128c6f6e75d1e06f86cd2 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/cocoa/qcocoahelpers.mm') diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 36841c77ab..d86e935788 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -402,23 +402,30 @@ QOperatingSystemVersion QMacVersion::currentRuntime() QMacVersion::VersionTuple QMacVersion::versionsForImage(const mach_header *machHeader) { + static auto makeVersionTuple = [](uint32_t dt, uint32_t sdk) { + return qMakePair( + QOperatingSystemVersion(QOperatingSystemVersion::MacOS, + dt >> 16 & 0xffff, dt >> 8 & 0xff, dt & 0xff), + QOperatingSystemVersion(QOperatingSystemVersion::MacOS, + sdk >> 16 & 0xffff, sdk >> 8 & 0xff, sdk & 0xff) + ); + }; + auto commandCursor = uintptr_t(machHeader) + sizeof(mach_header_64); for (uint32_t i = 0; i < machHeader->ncmds; ++i) { load_command *loadCommand = reinterpret_cast(commandCursor); if (loadCommand->cmd == LC_VERSION_MIN_MACOSX) { auto versionCommand = reinterpret_cast(loadCommand); - uint32_t dt = versionCommand->version; // Deployment target - uint32_t sdk = versionCommand->sdk; // Build SDK - return qMakePair( - QOperatingSystemVersion(QOperatingSystemVersion::MacOS, - dt >> 16 & 0xffff, dt >> 8 & 0xff, dt & 0xff), - QOperatingSystemVersion(QOperatingSystemVersion::MacOS, - sdk >> 16 & 0xffff, sdk >> 8 & 0xff, sdk & 0xff) - ); + return makeVersionTuple(versionCommand->version, versionCommand->sdk); +#if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13) + } else if (loadCommand->cmd == LC_BUILD_VERSION) { + auto versionCommand = reinterpret_cast(loadCommand); + return makeVersionTuple(versionCommand->minos, versionCommand->sdk); +#endif } commandCursor += loadCommand->cmdsize; } - Q_ASSERT_X(false, "QCocoaIntegration", "Could not find version-min load command"); + Q_ASSERT_X(false, "QCocoaIntegration", "Could not find any version load command"); Q_UNREACHABLE(); } -- cgit v1.2.3