-
Notifications
You must be signed in to change notification settings - Fork 742
default ABI #2257
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
Comments
I dug a bit around this issue and couldn't figure out when I guess one alternative would be to do this in postprocessing (or even inside codegen I guess) and add a new family of regex options to bindgen so we can set the ABI to whatever we want but I'm not sure that's the right approach as it would change the calling convention arbitrarily without respecting the target or the header inputs. |
Yeah, so right now we make the assumption that the default ABI is "C": rust-bindgen/bindgen/ir/function.rs Line 243 in 63bf643
Ideally we'd just do the right thing based on the target. If clang exposes the resolved "default" ABI that'd be preferrable to adding a new option. |
But AFAIK Edit: Just wanted to make it clear that I changed exactly that line expecting it would work but it does not :(. Apparently what happens is that this |
Yep, if you check libclang's code, you'll notice that So no idea where this As a consequence. I think there's no way to distingush a function without any calling convention attributes and one with the |
Given that it seems there's no way to override the default calling convention without changing items that explicitly use the builder.override_abi("matching_function", ABI::Stdcall); so this input: void matching_function();
void other_function(); emits this output: extern "stdcall" {
fn matching_function();
}
extern "C" {
fn other_function();
} This would also fix #2224 |
This option can be used from the CLI with the <abi>:<regex> syntax and it overrides the ABI of a function if it matches <regex>. Fixes rust-lang#2257 as the `".*"` regex can be used to match every function.
Hi, I've been expermenting with Windows driver APIs and Bindgen and stumbled into this thread. I'm not sure if it's relevant but here are my observations. I'm very new to this so please excuse me if I'm stating the obvious or doing something wrong.
The wrapper file:
and relevant snippets from build.rs (commented lines are variants):
As far as I understand, compiling for x64 doesn't differentiate between cdecl and stdcall because they are converted to a different calling convention. So if I understand correctly, I should be able to use Also regarding:
I'd like to ask where one learns this kind of info because searching for a confirmation of this is what lead me here in the first place. |
the default ABI of the windows kernel is stdcall, so the most functions do not specify ABI.
Is it possible to increase the default ABI option?
example
default_abi(name: &str)
Input C/C++ Header
Bindgen Invocation
Actual Results
Expected Results
The text was updated successfully, but these errors were encountered: