Skip to content

Commit

Permalink
[release/6.0.1] add support for macOS 12 (#61028)
Browse files Browse the repository at this point in the history
* RID work for macOS 12 (#59066)

* fix rid processing on macOS (#60494)

* fix rid processing on macOS

* Update src/native/corehost/hostmisc/pal.unix.cpp

* Update src/native/corehost/hostmisc/pal.unix.cpp

* remove extra size calculation

* Fix "fix rid processing on macOS" (#60668)

The `else if (major == 12)` is dead code, since the previous if `if (major > 11)` would be true for `major == 12`. Judging by the comment and code, it looks like the intention of this `else if` statement was to match `major == 11`.

* add the packaging for platforms package

Co-authored-by: Austin Wise <[email protected]>
Co-authored-by: Anirudh Agnihotry <[email protected]>
  • Loading branch information
3 people authored Nov 10, 2021
1 parent e1b589c commit f30e7fa
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 32 deletions.
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

0 comments on commit f30e7fa

Please sign in to comment.