[release/6.0.3xx] [CoreCLR] Avoid having any internal calls in managed code for CoreCLR. Fixes #15343.#15457
Merged
rolfbjarne merged 2 commits intodotnet:release/6.0.3xxfrom Jul 14, 2022
Conversation
Fixes dotnet#15343. CoreCLR does not like running into methods declared as internal calls: [MethodImplAttribute (MethodImplOptions.InternalCall)] and will fail with an error, even if the method is never executed, just encountered by the JIT: ECall methods must be packaged into a system module In the early days of .NET support we solved this by adding an indirection for CoreCLR, where the internal call was hidden inside a managed call that would never be executed at runtime. This seems to work fine in most cases, except when the debugger attached, when I'm guessing the JIT is more aggressive, and looks further ahead (and fails). On the other hand, in the early days of .NET support on macOS the managed code had to work for both Mono and CoreCLR without modification (since the same implementation assembly would be picked by the build independent on the actual runtime). This is no longer the case, since we only support CoreCLR on macOS now, which allows us to put any Mono-specific managed code (such as the internal call) in !macOS conditions. Fixes dotnet#15343.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mandel-macaque
approved these changes
Jul 11, 2022
This comment has been minimized.
This comment has been minimized.
Collaborator
Author
Collaborator
Author
💻 [PR Build] Tests on macOS Mac Catalina (10.15) passed 💻✅ All tests on macOS Mac Catalina (10.15) passed. Pipeline on Agent |
Collaborator
Author
📋 [PR Build] API Diff 📋API Current PR diff✅ API Diff (from PR only) (no change) View dotnet API diffView dotnet legacy API diffAPI diff✅ API Diff from stable View dotnet API diffView dotnet legacy API diffGenerator diff✅ Generator Diff (no change) Pipeline on Agent XAMBOT-1096.Monterey' |
Collaborator
Author
❌ [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌Failed tests are:
Pipeline on Agent |
rolfbjarne
approved these changes
Jul 14, 2022
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
CoreCLR does not like running into methods declared as internal calls:
and will fail with an error, even if the method is never executed, just encountered by the JIT:
In the early days of .NET support we solved this by adding an indirection for
CoreCLR, where the internal call was hidden inside a managed call that would
never be executed at runtime. This seems to work fine in most cases, except
when the debugger attached, when I'm guessing the JIT is more aggressive, and
looks further ahead (and fails).
On the other hand, in the early days of .NET support on macOS the managed code
had to work for both Mono and CoreCLR without modification (since the same
implementation assembly would be picked by the build independent on the actual
runtime). This is no longer the case, since we only support CoreCLR on macOS
now, which allows us to put any Mono-specific managed code (such as the
internal call) in !macOS conditions.
Fixes #15343.
Backport of #15358