-
Notifications
You must be signed in to change notification settings - Fork 494
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
Add optional support for raw-dylib
#2164
Conversation
In addition to waiting on stabilization, testing uncovered an issue blocking support on And cross compilation is also missing: |
Thanks for doing this! Looking forward to taking it for a spin shortly! |
You're welcome! This certainly makes it easier to kick the tires with |
macro_rules! link { | ||
($library:literal $abi:literal $(#[$($doc:tt)*])* fn $name:ident($($arg:ident: $argty:ty),*)->$ret:ty) => ( | ||
#[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim")] | ||
extern "system" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason this was made to ignore $abi? (it's now "C" rather than "system", as a workaround for variadic functions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a workaround for this: rust-lang/rust#110505
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's why it's C now, but why was it "system" rather than $abi?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the ABI is generally only relevant for x86 and "system" should work for all ARM64 and x64 Windows APIs.
Following on from #2149, this update adds optional support for
raw-dylib
in thewindows
andwindows-sys
crates. This is currently only supported on nightly but is on track for stabilization. Thelink
macro is "overloaded" to adjust the way the Rustlink
attribute is configured depending on whether thewindows_raw_dylib
flag is specified.The
link
macro will generate the traditional form if thewindows_raw_dylib
flag is not specified. In that mode, it continues to rely on the target libs provided by thewindows-targets
crate. However, thewindows_raw_dylib
flag ensures that no libs are needed or downloaded. The name of the DLL is then used to instruct the Rust compiler to inject the appropriate import table entry directly and without the use of an import lib.I'll probably switch the
windows
crate over toraw-dylib
unconditionally once the feature is stabilized but keep thewindows-sys
crate optional to retain support for an older MSRV.