macOS: Account for LC_BUILD_VERSION when checking SDK version and deployment target
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 <morten.sorvig@qt.io>
This commit is contained in:
parent
1314d2688c
commit
b82559244e
@ -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<load_command *>(commandCursor);
|
||||
if (loadCommand->cmd == LC_VERSION_MIN_MACOSX) {
|
||||
auto versionCommand = reinterpret_cast<version_min_command *>(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<build_version_command *>(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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user