-
Notifications
You must be signed in to change notification settings - Fork 371
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
FnAbi Compatability check #4185
Conversation
I have made changes only in a single place to make sure that this what we want. |
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.
Thanks for the PR!
Judging from the CI failures, this does not seem to be quite right. And (as noted inline) I think this will never be able to do the "proper" check. So I don't think this is the right approach.
The right approach has to be somewhat similar to what happens for regular function calls in Miri. Basically, we need a helper function that takes a list of types (the expected argument types) and a return type, and then somehow checks that against the FnAbi
that is passed around in the Miri shim handling. This likely involved constructing our own FnAbi
to compare, and I have no idea how to do that...
Also, I would suggest to not touch intrinsics for now. They are somewhat special ABI-wise. Let's start with normal shims, i.e. all the things on foreign_items
.
For non variadic fn's can't we just simply create FnAbi struct using the types available in docs. The issue only comes for variadic fn's as we dont know the types of the extra args. |
Yes we "just" have to do that but it is not necessarily so easy. :) |
Why can't we directly instantiate an object of |
That involves computing a
Yes. It can be invoked in Miri via |
To resolve I was thinking of implementing the following things: Create a fn |
That sounds like a good plan. There are methods defined in https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/call.rs that are probably useful but have to be made |
Are you talking about Also |
Yes.
You can use these methods: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/?search=mk_type_list. |
I am mostly done with the code now I just need |
Okay, please make a PR against the rustc repo to make that function public then. :) |
made check_argument_compat public for use in miri Links to [issue](rust-lang/miri#3842) and it's [PR](rust-lang/miri#4185 (comment)) in miri.
Rollup merge of rust-lang#137056 - geetanshjuneja:pub, r=RalfJung made check_argument_compat public for use in miri Links to [issue](rust-lang/miri#3842) and it's [PR](rust-lang/miri#4185 (comment)) in miri.
209151e
to
b2b430e
Compare
This comment has been minimized.
This comment has been minimized.
Please don't do rustup in the middle of a regular PR. I did a regular rustup, so if you rebase your PR should pick that up. :) |
@rustbot author |
b2b430e
to
c6629a6
Compare
@rustbot ready |
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.
@rustbot author
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.
Sorry for the long wait!
Also do I need to add a test for return type mismatch? |
@rustbot author |
@rustbot ready |
Yes please do. |
This looks great, thanks! Please squash the commits, then we can land this. Please use the @rustbot author |
5f4f8bb
to
8bbf8b2
Compare
Hmm on my macOS |
Just use |
8bbf8b2
to
fe06f18
Compare
added input arg mismatch test added detailed ub messages added return type mismatch test
fe06f18
to
c67186a
Compare
Thanks for the PR and the patience. :) |
So the next step would be to use |
Yeah the next step is to use this for all the existing shims. Please don't do them all in one PR. :) Pick one file, e.g. |
Links to #3842