Use extern "C" instead of extern "cdecl"#3622
Conversation
extern "C" instead of extern "cdecl"extern "C" instead of extern "cdecl"
"C" and "system" work on all targets, so why does |
It's due to varargs. You can't currently use "system" if the function is variadic, only "C" or "cdecl": |
|
I don't understand this answer... |
|
I recall it being done this way as a workaround for rust-lang/rust#110505 but maybe that was specific to raw-dylibs at the time. |
|
In any case it would be nice to be able to update the |
|
Is there an urgency or need for an update of these crates to be published? Given how slow adoption is for newer versions of |
|
@ChrisDenton thanks for jumping in with a fix! |
The tracking issue for this lint is rust-lang/rust#137018. It has just been added. The usual timeline for moving the lint to a hard error is on the order of 6-12 months. With a high-profile crate like this being affected, we may have to move a bit slower, but it'd still be nice to get the ball rolling. :) It is not clear to me yet what the fallout from this is here -- does this affect all users of the crate, or just non-Windows users? I guess it used to use "cdecl" on an x86_64 windows target so it'd be all users. |
|
It'll be all users that enable a cdecl function at least. If it's possible to do a point release of the |
|
If we're comfortable that this is not a breaking change to the |
|
Oh, the latest version of |
|
That does complicate that idea. In that case I think it's ok to wait until the next release of windows-sys. Then it's on rust to wait until crates have updated their |
|
Here's what I'm planning to release in response: #3624 |
|
So there's no way to do this without a semver break? Bummer :/ |
|
Yes for |
|
And they have been published: https://github.com/microsoft/windows-rs/releases/tag/66 |
|
Does "release 66" match v0.60.0 on crates.io? Btw the readme on crates.io still says to insert this into my cargo.toml: [dependencies.windows-sys]
version = "0.59"
... |
Yes, the release number/name is just an incremental counter of releases. They used to line up but that became impractical as different crates were published on different frequencies.
Grr! I forgot to update the readme. Will bump those shortly. Thanks for the heads up. One more thing to automate. 🙃 |
That's fair. But right now, reading the announcement at https://github.com/microsoft/windows-rs/releases/tag/66, I have no clue which versions of which crate it is talking about. |
|
#3625 fixes the readmes - I'll update the release notes with specific crate version numbers once that update is published. |
As a consumer of crates that use windows-sys or windows-bindgen, it really sucks when crates use windows-bindgen and I have to audit them, as they usually provide no help whatsoever in verifying that the source code they checked in was actually generated from windows-bindgen. Quite frequently they tweak it because they don't like the output of windows-bindgen, and then suddenly every consumer of every such crate has to be an Windows ABI expert and has to do a bunch of reverse-engineering just for the audit. "Luckily" most people just seem to YOLO it. To the extent that having multiple versions of windows-sys in a dependency tree is a significant problem (IMO not really), it would really be great to focus on SemVer-compatible updates instead. I understand that is easier said than done, though. |
|
Indeed, I always use a yml workflow to ensure that the generated code is consistent with what |
As a concrete point, the playground will now print this out for every user using the nightly toolchain: |
|
That'll be fixed soon, we just need rust-lang/rust#142353 to land. |
I'm also updating the crates in the playground so that specific instance of the message should go away in an hour or two. |
Varargs method is already |
Rust is planning on getting stricter about calling conventions so has started issuing future incomparability warnings (similar to how
raw-dylibis stricter).This PR changes uses of
extern "cdecl"toextern "C". This matches the C semantics wherecdeclis used on x86 and ignored for other platforms (i.e. the default C calling convention is used).It also changes the
linkmacros onnot(windows)targets to useextern "C"exclusively. This matches the windowsnot(target_arch = "x86")targets so should be fine.fixes rust-lang/rust#142330