Open novafacing opened 3 months ago
Here's a godbolt with the generated headers (test cconv.rs): https://godbolt.org/z/MqPhhzqcf
There are a few compile errors which I intentionally left in (like requesting sysv64 on clang/gcc non-x86_64). I can change that behavior so a compile error is never emitted and a warning is instead if that's preferred.
Realized I had a misunderstanding about what the extern_decl flag was doing (toggling extern
keyword in output). I put it back to how it was, so now that plays nice with the ABI detection and dispatching.
Documented the configuration option added for this feature. Should be ready to merge :)
Calling convention predefines are now emitted in a defined order, should actually be ready to merge.
This PR adds support for other calling conventions as discussed in #55 and #718. It adds an ABI field (instead of just an extern field) to
Function
s and adds a concept ofPredefines
which right now only contains the compiler/platform-specific#defines
needed to make the calling conventions work nicely but may be useful in the future for other cases where something needs to look at all the code, then conditionally emit some lines at the top of the file.This use case is very important to my work to adopt Rust for UEFI/firmware programming, since cbindgen is needed to integrate Rust into existing C codebases easily. Most of these environments define an explicit calling convention, which we need to be able to export from Rust code for interoperability.