-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Proposal: extern "uefi" ABI #54527
Comments
cc @rust-lang/compiler @alexcrichton |
Is this discussion better had here or on internals? |
Whichever way you like best 😉 |
How do the C compilers handle this? |
I wonder if it's possible to support custom ABIs through some plugin-based interface. (Disclaimer: I have no idea how the current ABI definitions work, and what interface the ABI plugin should have, especially for calling conventions.) |
@petrochenkov It's very close to being pure data, so I would prefer to have it mostly be described in JSON, or something like that, if possible. (I've considered it before, albeit not in a purely declarative manner, it's mostly a matter of "resource categorization and allocation") Everything other than calling conventions is already described through the "datalayout" string, and I'd prefer to avoid adding plugin systems to rustc, as they impose significant technical burden. OTOH, us gathering call ABIs ("calling conventions") for various targets comes at almost 0 cost and since it's all isolated in a The "mainstream" approach of rewriting all the rules for all the targets, by hand, in every compiler, is a waste of effort, and unshares knowledge, and rustc can do a public service here. |
I say let's do it :) |
The C compilers make a distinction between "different calling conventions" and "same calling convention name, different ABIs". GCC and Clang support custom function attributes which allow one to write Also, this attribute has no effect on non-x86_64, so everything fits perfectly. In our use case, As for usage of this feature: it is used in
Interesting, but my question is, how can we make this composable and allow this to work with libraries? |
I believe the point is to make it configurable on our end, so that adding new |
This seems like a good idea to me. Like |
Add new EFIAPI ABI Fixes rust-lang#54527 Adds a new ABI, "efiapi", which reflects the calling convention as specified by [the current spec UEFI spec](https://uefi.org/sites/default/files/resources/UEFI%20Spec%202_7_A%20Sept%206.pdf#G6.999903). When compiling for x86_64, we should select the `win64` ABI, while on all other architectures (Itanium, x86, ARM and ARM64 and RISC-V), we should select the `C` ABI. Currently, this is done by just turning it into the C ABI everywhere except on x86_64, where it's turned into the win64 ABI. Should we prevent this ABI from being used on unsupported architectures, and if so, how would this be done?
Add new EFIAPI ABI Fixes rust-lang#54527 Adds a new ABI, "efiapi", which reflects the calling convention as specified by [the current spec UEFI spec](https://uefi.org/sites/default/files/resources/UEFI%20Spec%202_7_A%20Sept%206.pdf#G6.999903). When compiling for x86_64, we should select the `win64` ABI, while on all other architectures (Itanium, x86, ARM and ARM64 and RISC-V), we should select the `C` ABI. Currently, this is done by just turning it into the C ABI everywhere except on x86_64, where it's turned into the win64 ABI. Should we prevent this ABI from being used on unsupported architectures, and if so, how would this be done?
The UEFI firmware interface has some calling conventions which are documented in chapter 2.3 of the current spec.
For the most part, these are pretty close to the Windows ABI conventions ("cdecl" on IA-32, "win64" on AMD64...), which should come as no surprise given the strong influence that Microsoft has on the UEFI forum. However, the UEFI spec also defines calling conventions for hardware architectures like RISC-V where Windows has not been ported.
UEFI applications (such as OS loaders) must be extra careful to use the right ABI when calling into UEFI, since unless you are Windows,
extern "C"
will not necessarily map into what the firmware expects.In rust-osdev/uefi-rs#41 , @GabrielMajeri proposed to make the life of UEFI application developers easier by adding language-level support for the UEFI FFI in the form of an
extern "uefi"
ABI. How open would you be to this idea?The text was updated successfully, but these errors were encountered: