Description
While testing variadic function support with raw-dylib
I discovered that Rust requires such functions to use either "C" or "cdecl" ABIs but raw-dylib
requires the "system" ABI on non-x86 Windows.
My undertstanding from discussing with @dpaoliello is that this is not an issue with raw-dylib
itself but with Rust's insistence that such functions aren't allowed to use the "system" ABI. It's just that raw-dylib
is very strict about calling convention so that's where the issue surfaced.
#[link(name = "library", modifiers = "+verbatim")]
extern "system" {
pub fn DbgPrint(format: *const u8, ...) -> u32;
}
On x64 I should be able to compile this but Rust says no:
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
--> src\lib.rs:3:5
|
3 | pub fn DbgPrint(format: *const u8, ...) -> u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
This example works if I change the ABI to "cdecl" but that's not meant to be a valid ABI on x64 and so when I try to compile this with raw-dylib
it fails:
#[link(name = "library", kind = "raw-dylib", modifiers = "+verbatim")]
extern "cdecl" {
pub fn DbgPrint(format: *const u8, ...) -> u32;
}
error: ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
--> src\lib.rs:3:5
|
3 | pub fn DbgPrint(format: *const u8, ...) -> u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The practical result is that it is impossible to link this function with raw-dylib
on non-x86.