-
Notifications
You must be signed in to change notification settings - Fork 5.2k
map macOS compat 10.16 version to 11.0 #41176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -553,7 +553,6 @@ pal::string_t pal::get_current_os_rid_platform() | |
| // We will, instead, use kern.osrelease and use its major version number | ||
| // as a means to formulate the OSX 10.X RID. | ||
| // | ||
| // Needless to say, this will need to be updated if OSX RID were to become 11.* ever. | ||
| size_t size = sizeof(str); | ||
| int ret = sysctlbyname("kern.osrelease", str, &size, nullptr, 0); | ||
| if (ret == 0) | ||
|
|
@@ -562,18 +561,31 @@ pal::string_t pal::get_current_os_rid_platform() | |
| size_t pos = release.find('.'); | ||
| if (pos != std::string::npos) | ||
| { | ||
| // Extract the major version and subtract 4 from it | ||
| // to get the Minor version used in OSX versioning scheme. | ||
| // That is, given a version 10.X.Y, we will get X below. | ||
| int minorVersion = stoi(release.substr(0, pos)) - 4; | ||
| if (minorVersion < 10) | ||
| int majorVersion = stoi(release.substr(0, pos)); | ||
wfurt marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the integer be negative? Should this be |
||
| // compat path with 10.x | ||
| if (majorVersion < 20) | ||
| { | ||
| // On OSX, our minimum supported RID is 10.12. | ||
| minorVersion = 12; | ||
| } | ||
| // Extract the major version and subtract 4 from it | ||
| // to get the Minor version used in OSX versioning scheme. | ||
| // That is, given a version 10.X.Y, we will get X below. | ||
| // | ||
| // macOS Cataline 10.15.5 has kernel 19.5.0 | ||
| int minorVersion = majorVersion - 4; | ||
| if (minorVersion < 10) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a pre-existing bug -- it should be 12, not 10. |
||
| { | ||
| // On OSX, our minimum supported RID is 10.12. | ||
| minorVersion = 12; | ||
| } | ||
|
|
||
| ridOS.append(_X("osx.10.")); | ||
| ridOS.append(pal::to_string(minorVersion)); | ||
| ridOS.append(_X("osx.10.")); | ||
| ridOS.append(pal::to_string(minorVersion)); | ||
| } | ||
| else | ||
| { | ||
| // 11.0 shipped with kernel 20.0 | ||
| ridOS.append(_X("osx.11.")); | ||
| ridOS.append(pal::to_string(majorVersion - 20)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This SO answer suggests that kern.osrelease is not a future proof way to get macOS versions -- https://stackoverflow.com/questions/11072804/how-do-i-determine-the-os-version-at-runtime-in-os-x-or-ios-without-using-gesta#comment40165087_11697362
but again we're clearly already doing it..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should to
kern.osproductversiononce we update SDK and we only support versions where supported.It returns 11.0 on Big Sure and 10.15.5 on Catalina.
10.12 does not have it and I did not check 10.13 and 10.14 yet.
We can also use it when exist and fall-back to kernel mapping for old versions where it is unlikely to change.