Skip to content
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

[release/6.0.1] add support for macOS 12 #61028

Merged
merged 4 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

<!-- When building from source, ensure the RID we're building for is part of the RID graph -->
<AdditionalRuntimeIdentifiers Condition="'$(DotNetBuildFromSource)' == 'true'">$(AdditionalRuntimeIdentifiers);$(OutputRID)</AdditionalRuntimeIdentifiers>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ServicingVersion>1</ServicingVersion>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5252,6 +5252,73 @@
"any",
"base"
],
"osx.12": [
"osx.12",
"osx.11.0",
"osx.10.16",
"osx.10.15",
"osx.10.14",
"osx.10.13",
"osx.10.12",
"osx.10.11",
"osx.10.10",
"osx",
"unix",
"any",
"base"
],
"osx.12-arm64": [
"osx.12-arm64",
"osx.12",
"osx.11.0-arm64",
"osx.11.0",
"osx.10.16-arm64",
"osx.10.16",
"osx.10.15-arm64",
"osx.10.15",
"osx.10.14-arm64",
"osx.10.14",
"osx.10.13-arm64",
"osx.10.13",
"osx.10.12-arm64",
"osx.10.12",
"osx.10.11-arm64",
"osx.10.11",
"osx.10.10-arm64",
"osx.10.10",
"osx-arm64",
"osx",
"unix-arm64",
"unix",
"any",
"base"
],
"osx.12-x64": [
"osx.12-x64",
"osx.12",
"osx.11.0-x64",
"osx.11.0",
"osx.10.16-x64",
"osx.10.16",
"osx.10.15-x64",
"osx.10.15",
"osx.10.14-x64",
"osx.10.14",
"osx.10.13-x64",
"osx.10.13",
"osx.10.12-x64",
"osx.10.12",
"osx.10.11-x64",
"osx.10.11",
"osx.10.10-x64",
"osx.10.10",
"osx-x64",
"osx",
"unix-x64",
"unix",
"any",
"base"
],
"rhel": [
"rhel",
"linux",
Expand Down
17 changes: 17 additions & 0 deletions src/libraries/Microsoft.NETCore.Platforms/src/runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,23 @@
"osx.10.16-x64"
]
},
"osx.12": {
"#import": [
"osx.11.0"
]
},
"osx.12-arm64": {
"#import": [
"osx.12",
"osx.11.0-arm64"
]
},
"osx.12-x64": {
"#import": [
"osx.12",
"osx.11.0-x64"
]
},
"rhel": {
"#import": [
"linux"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<RuntimeGroup Include="osx">
<Parent>unix</Parent>
<Architectures>x64;arm64</Architectures>
<Versions>10.10;10.11;10.12;10.13;10.14;10.15;10.16;11.0</Versions>
<Versions>10.10;10.11;10.12;10.13;10.14;10.15;10.16;11.0;12</Versions>
</RuntimeGroup>

<RuntimeGroup Include="freebsd">
Expand Down
61 changes: 30 additions & 31 deletions src/native/corehost/hostmisc/pal.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,48 +533,47 @@ pal::string_t pal::get_current_os_rid_platform()
pal::string_t ridOS;

char str[256];

// There is no good way to get the visible version of OSX (i.e. something like 10.x.y) as
// certain APIs work till 10.9 and have been deprecated and others require linking against
// UI frameworks to get the data.
//
// We will, instead, use kern.osrelease and use its major version number
// as a means to formulate the OSX 10.X RID.
//
size_t size = sizeof(str);
int ret = sysctlbyname("kern.osrelease", str, &size, nullptr, 0);

// returns something like 10.5.2 or 11.6
int ret = sysctlbyname("kern.osproductversion", str, &size, nullptr, 0);
if (ret == 0)
{
std::string release(str, size);
size_t pos = release.find('.');
if (pos != std::string::npos)
// the value _should_ be null terminated but let's make sure
str[size - 1] = 0;

char* pos = strchr(str, '.');
if (pos != NULL)
{
int majorVersion = stoi(release.substr(0, pos));
// compat path with 10.x
if (majorVersion < 20)
int major = atoi(str);
if (major > 11)
{
// 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)
{
// On OSX, our minimum supported RID is 10.12.
minorVersion = 12;
}
// starting with 12.0 we track only major release
*pos = 0;

ridOS.append(_X("osx.10."));
ridOS.append(pal::to_string(minorVersion));
}
else if (major == 11)
{
// for 11.x we publish RID as 11.0
// if we return anything else, it would break the RID graph processing
strcpy(str, "11.0");
}
else
{
// 11.0 shipped with kernel 20.0
ridOS.append(_X("osx.11."));
ridOS.append(pal::to_string(majorVersion - 20));
// for 10.x the significant releases are actually the second digit
pos = strchr(pos + 1, '.');

if (pos != NULL)
{
// strip anything after second dot and return something like 10.5
*pos = 0;
}
}
}

std::string release(str, strlen(str));
ridOS.append(_X("osx."));
ridOS.append(release);
}

return ridOS;
Expand Down