-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Variadic functions don't allow "system" on non-x86 Windows #110505
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
cc #97971 which originally added variadics support to some other calling conventions (though not |
A workaround is to use "C" on non-x86 as I implemented here: microsoft/windows-rs#2458 |
@wesleywiser @nagisa Thoughts on permitting variadic parameters with the |
This work-around is causing pain. Would be great if there was a way that it could be avoided. :) |
There's a comment saying this can't work: rust/compiler/rustc_target/src/spec/abi/mod.rs Lines 70 to 78 in ef7ebaa
I don't understand anything about these ABIs so I can't say how accurate this is. Also I see nothing here special-casing x86, so why does the issue specifically mention non-x86? |
Happy to update |
Can we make |
Went ahead and opened #119587 for this. |
Rollup merge of rust-lang#119587 - beepster4096:system_varargs, r=petrochenkov Varargs support for system ABI This PR allows functions with the `system` ABI to be variadic (under the `extended_varargs_abi_support` feature tracked in rust-lang#100189). On x86 windows, the `system` ABI is equivalent to `C` for variadic functions. On other platforms, `system` is already equivalent to `C`. Fixes rust-lang#110505
…workingjubilee variadic functions: remove list of supported ABIs from error I think this list is problematic for multiple reasons: - It is bound to go out-of-date as it is in a very different place from where we actually define which functions support varagrs (`fn supports_varargs`). - Many of the ABIs we list only work on some targets; it makes no sense to mention "aapcs" as a possible ABI when building for x86_64. (This led to a lot of confusion in rust-lang#110505 where the author thought they should use "cdecl" and then were promptly told that "cdecl" is not a legal ABI on their target.) - Typically, when the programmer wrote `extern "foobar"`, it is because they need the "foobar" ABI. It is of little use to tell them that there are other ABIs with which varargs would work. Cc `@workingjubilee`
…workingjubilee variadic functions: remove list of supported ABIs from error I think this list is problematic for multiple reasons: - It is bound to go out-of-date as it is in a very different place from where we actually define which functions support varagrs (`fn supports_varargs`). - Many of the ABIs we list only work on some targets; it makes no sense to mention "aapcs" as a possible ABI when building for x86_64. (This led to a lot of confusion in rust-lang#110505 where the author thought they should use "cdecl" and then were promptly told that "cdecl" is not a legal ABI on their target.) - Typically, when the programmer wrote `extern "foobar"`, it is because they need the "foobar" ABI. It is of little use to tell them that there are other ABIs with which varargs would work. Cc ``@workingjubilee``
Rollup merge of #142464 - RalfJung:variadic-fn-abi-error, r=workingjubilee variadic functions: remove list of supported ABIs from error I think this list is problematic for multiple reasons: - It is bound to go out-of-date as it is in a very different place from where we actually define which functions support varagrs (`fn supports_varargs`). - Many of the ABIs we list only work on some targets; it makes no sense to mention "aapcs" as a possible ABI when building for x86_64. (This led to a lot of confusion in #110505 where the author thought they should use "cdecl" and then were promptly told that "cdecl" is not a legal ABI on their target.) - Typically, when the programmer wrote `extern "foobar"`, it is because they need the "foobar" ABI. It is of little use to tell them that there are other ABIs with which varargs would work. Cc ``@workingjubilee``
…bilee variadic functions: remove list of supported ABIs from error I think this list is problematic for multiple reasons: - It is bound to go out-of-date as it is in a very different place from where we actually define which functions support varagrs (`fn supports_varargs`). - Many of the ABIs we list only work on some targets; it makes no sense to mention "aapcs" as a possible ABI when building for x86_64. (This led to a lot of confusion in rust-lang/rust#110505 where the author thought they should use "cdecl" and then were promptly told that "cdecl" is not a legal ABI on their target.) - Typically, when the programmer wrote `extern "foobar"`, it is because they need the "foobar" ABI. It is of little use to tell them that there are other ABIs with which varargs would work. Cc ``@workingjubilee``
…bilee variadic functions: remove list of supported ABIs from error I think this list is problematic for multiple reasons: - It is bound to go out-of-date as it is in a very different place from where we actually define which functions support varagrs (`fn supports_varargs`). - Many of the ABIs we list only work on some targets; it makes no sense to mention "aapcs" as a possible ABI when building for x86_64. (This led to a lot of confusion in rust-lang/rust#110505 where the author thought they should use "cdecl" and then were promptly told that "cdecl" is not a legal ABI on their target.) - Typically, when the programmer wrote `extern "foobar"`, it is because they need the "foobar" ABI. It is of little use to tell them that there are other ABIs with which varargs would work. Cc ``@workingjubilee``
Uh oh!
There was an error while loading. Please reload this page.
While testing variadic function support with
raw-dylib
I discovered that Rust requires such functions to use either "C" or "cdecl" ABIs butraw-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 thatraw-dylib
is very strict about calling convention so that's where the issue surfaced.On x64 I should be able to compile this but Rust says no:
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:The practical result is that it is impossible to link this function with
raw-dylib
on non-x86.The text was updated successfully, but these errors were encountered: