summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-01-26 16:35:59 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-08 01:25:30 +0000
commit6555141dde9e09ac5b1a0ebe7896433c88dbd437 (patch)
tree2b6c2a9d14ad8d6f65cf08943410411391cfb390
parent541a13f1ad80a114ceeffaeabdc2d385bcc0aa20 (diff)
macOS: Skip deployment target runtime check when detecting compat version
When the main executable is built with a pre-macOS 11 SDK, the macOS kernel and system libraries will enable a compatibility mode for reporting the system version, reporting 10.16 instead of 11/12/13 etc. This happens at at such a low level that even manually reading the version from /System/Library/CoreServices/SystemVersion.plist is intercepted. Working around this by temporarily setting the SYSTEM_VERSION_COMPAT environment variable is unfortunately not possible, as it's only read on process creation/initialization. The same goes for the kern.system_version_compat sysctl, as once it's set it can not be changed back to its original value, and it's not clear whether this sysctl should even be touched. As long as we have no reliable way of reading the actual current operating system version, we need to bail out of the deployment target verification, to avoid false negatives where a plugin or library, built with a deployment target of say 11.0, is loaded into an application built with a pre-11.0 SDK, but running on macOS 11+. Change-Id: I9c757a276726175c5dda694ffc1b88f1681d00fb Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit bac93ce5eba10ae1e5d165b464a7a9e3b4dd6561) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/kernel/qcore_mac.mm8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_mac.mm b/src/corelib/kernel/qcore_mac.mm
index fd8f5084f5..1da41484ec 100644
--- a/src/corelib/kernel/qcore_mac.mm
+++ b/src/corelib/kernel/qcore_mac.mm
@@ -606,6 +606,14 @@ void qt_apple_check_os_version()
const NSOperatingSystemVersion required = (NSOperatingSystemVersion){
version / 10000, version / 100 % 100, version % 100};
const NSOperatingSystemVersion current = NSProcessInfo.processInfo.operatingSystemVersion;
+
+#if defined(Q_OS_MACOS)
+ // Check for compatibility version, in which case we can't do a
+ // comparison to the deployment target, which might be e.g. 11.0
+ if (current.majorVersion == 10 && current.minorVersion >= 16)
+ return; // FIXME: Find a way to detect the real OS version
+#endif
+
if (![NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:required]) {
NSDictionary *plist = NSBundle.mainBundle.infoDictionary;
NSString *applicationName = plist[@"CFBundleDisplayName"];