-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Add support for the win64 calling convention #10527
Conversation
It's unfortunate to not see any tests for this. From what it looks like, if I declare a rust function as |
@alexcrichton: I expect this could expose some functions with a weird calling convention from one crate and call them from another, but you'd actually need to find a difference between the calling conventions and it would be very unlikely that it would segfault (as it's not going to break any memory protection rules in 99.9% of cases). You could write one where it would read the wrong registers or wrong bit of the stack I guess. |
I'm not sure that you can do this, but if you can write code which segfaults before this patch, then you definitely have a test case right there. I would like to at least explore the idea of adding a test before having no tests at all. |
It probably causes a segmentation fault after reading an incorrect value as the parameter (a null pointer from a register that happens to be zero, maybe). |
(temporarily removed r+, waiting for a test) |
An easier test would be finding things which are passed differently, and asserting that a parameter has a specific value. |
I'm working on a test case now. I'm making a function |
Alright, I added the test case. I confirmed on that the test fails with the change that just adds support for the win64 convention, and it passes with the second change. |
Hm, I think that the tests may not pass the Otherwise, thanks! Looks good to me! |
I added the copyright header. Surprisingly, I don't think I did get a rustpkg test failure about rebuilding a C file, but I think that is unrelated to this change. |
Could you also squash these commits into the first one being the win64 ABI/test case, and then the second is the ABI fix in general? |
Make tidy indeed doesn't currently check test cases: #4534. |
Ok, I squashed these down, rebased onto the latest master and made sure |
@alexcrichton - would you might reviewing my latest addition? The tests failed on the 32-bit machines, so I've just substituted the normal calling convention there. |
This was needed to access UEFI boot services in my new Boot2Rust experiment. I also realized that Rust functions declared as extern always use the C calling convention regardless of how they were declared, so this pull request fixes that as well.
Do not propose to simplify a not expression coming from a macro Fixes rust-lang#10523 changelog: FP [`nonminimal_bool`]: do not propose to change code coming from a macro
This was needed to access UEFI boot services in my new Boot2Rust experiment.
I also realized that Rust functions declared as extern always use the C calling convention regardless of how they were declared, so this pull request fixes that as well.