-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
P/Invokes should use C types not C++. #94942
Conversation
/cc @jkotas @elinor-fung |
src/tests/Interop/DisabledRuntimeMarshalling/DisabledRuntimeMarshallingNative.cpp
Outdated
Show resolved
Hide resolved
We do not seem to have the difference between managed and unmanaged x86/x64 calling conventions for small return types noted in https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/clr-abi.md . It would be nice to fix that. For unmanaged calling conventions, the state of unused bits in the value returned in RAX or XMM0 is undefined. (https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170#return-values) For managed calling conventions, the primitive values smaller than 32-bits must be zero-extended (or sign-extended?) to 32-bits. @dotnet/jit-contrib What is the exact rule that the JIT implements? |
For managed methods, the callee widens small return values. For native methods, the caller widens small return values.
runtime/src/coreclr/jit/importercalls.cpp Lines 1428 to 1445 in 8a1b985
|
@AndyAyersMS Is there a follow up issue to file here? |
You mean for codegen? I don't see one, unless we're not actually doing what is outlined above. |
This reverts commit 7f6898c.
This is step one of the fix. The current update works and passes on macOS. Pushing to CI to make sure Windows and Linux remain in the same state. |
@jkotas Please take another look at this. I'd like to get the CI unblocked. Feel free to merge if you are okay with the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
A recent C++ toolchain update uncovered an invalid P/Invoke signature using C++ types as opposed to C types. This caused the test to fail due to invalid assumptions. The test was updated to be valid.
Fixes #94931