Skip to content
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 @@ -5229,6 +5229,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 @@ -2133,6 +2133,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 @@ -156,7 +156,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
50 changes: 16 additions & 34 deletions src/native/corehost/hostmisc/pal.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,48 +568,30 @@ 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
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)
{
// 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;
}
pos = strchr(pos + 1, '.');

ridOS.append(_X("osx.10."));
ridOS.append(pal::to_string(minorVersion));
}
else
if (pos != NULL)
{
// 11.0 shipped with kernel 20.0
ridOS.append(_X("osx.11."));
ridOS.append(pal::to_string(majorVersion - 20));
// strip anything after second dot and return something like 10.5
*pos = 0;
size = pos - str;
}
}

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

return ridOS;
Expand Down