From f30e7fab1fe52b1f0ae5065f1a23104a4b9f231c Mon Sep 17 00:00:00 2001 From: Tomas Weinfurt Date: Wed, 10 Nov 2021 10:39:07 -0800 Subject: [PATCH] [release/6.0.1] add support for macOS 12 (#61028) * 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 Co-authored-by: Anirudh Agnihotry --- .../src/Microsoft.NETCore.Platforms.csproj | 2 + .../src/runtime.compatibility.json | 67 +++++++++++++++++++ .../src/runtime.json | 17 +++++ .../src/runtimeGroups.props | 2 +- src/native/corehost/hostmisc/pal.unix.cpp | 61 +++++++++-------- 5 files changed, 117 insertions(+), 32 deletions(-) diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj b/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj index b941586e3d673..2106f0b732f10 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj +++ b/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj @@ -19,6 +19,8 @@ $(AdditionalRuntimeIdentifiers);$(OutputRID) + true + 1 diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json index 9966d06dc38ea..98b9472e508d1 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json @@ -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", diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json index d40191ceaae15..4021d59c82005 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json @@ -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" diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props index 0dce8cdd98876..83837f9c19c02 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props @@ -155,7 +155,7 @@ unix x64;arm64 - 10.10;10.11;10.12;10.13;10.14;10.15;10.16;11.0 + 10.10;10.11;10.12;10.13;10.14;10.15;10.16;11.0;12 diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index 1ea7817900cd5..59597646e0373 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -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;