Skip to content
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

Tracking issue for RFC 2627: #[link(kind="raw-dylib")] #58713

Open
10 of 15 tasks
Tracked by #3
joshtriplett opened this issue Feb 24, 2019 · 137 comments
Open
10 of 15 tasks
Tracked by #3

Tracking issue for RFC 2627: #[link(kind="raw-dylib")] #58713

joshtriplett opened this issue Feb 24, 2019 · 137 comments
Assignees
Labels
A-linkage Area: linking into static, shared libraries and binaries B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-raw_dylib `#![feature(raw_dylib)]` O-windows Operating system: Windows S-tracking-impl-incomplete Status: The implementation is incomplete. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@joshtriplett
Copy link
Member

joshtriplett commented Feb 24, 2019

This is the tracking issue for RFC 2627, #[link(kind="raw-dylib")].

Note: raw-dylib and link_ordinal are now stabilized in 1.65 on Windows for x86_64, aarch64, and thumbv7a (not 32-bit x86) via #99916.

Opens:

joshtriplett added a commit to rust-lang/rfcs that referenced this issue Feb 24, 2019
🎉 RFC 2627 is now `#[link(kind="raw-dylib")]`! 🎉

Tracking issue: rust-lang/rust#58713
@jonas-schievink jonas-schievink added A-linkage Area: linking into static, shared libraries and binaries B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. labels Feb 24, 2019
@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Feb 25, 2019
@crlf0710
Copy link
Member

cc rust-lang/rfcs#1061

@ZerothLaw
Copy link

I don't think I have the expertise to implement this feature, but I could write some (currently failing) tests for use by the implementor?

(Background, Ran into this exact problem linking mscorlib.dll into executables. Had to write a C++ level wrapper to get it to work.)

@Centril Centril added the F-raw_dylib `#![feature(raw_dylib)]` label Aug 27, 2019
Centril added a commit to Centril/rust that referenced this issue Sep 20, 2019
Add feature gate for raw_dylib.

This PR adds the feature gate for RFC 2627 (rust-lang#58713). It doesn't contain the actual functionality.
Add I'm not sure whether i did it correctly, since this is the first time i did this.

r? @Centril
bors added a commit that referenced this issue Sep 22, 2019
Add feature gate for raw_dylib.

This PR adds the feature gate for RFC 2627 (#58713). It doesn't contain the actual functionality.
Add I'm not sure whether i did it correctly, since this is the first time i did this.

r? @Centril
Centril added a commit to Centril/rust that referenced this issue Oct 7, 2019
Add feature gate for raw_dylib.

This PR adds the feature gate for RFC 2627 (rust-lang#58713). It doesn't contain the actual functionality.
Add I'm not sure whether i did it correctly, since this is the first time i did this.

r? @Centril
@crlf0710
Copy link
Member

crlf0710 commented Oct 8, 2019

A very first PR has landed, now the link_ordinal attribute is added. Want to say thank you to @Centril for helping me on this~

@retep998
Copy link
Member

There's now a bounty for this issue to incentivize someone to work on implementing this feature.

https://www.bountysource.com/issues/70533351-tracking-issue-for-rfc-2627-link-kind-raw-dylib

@est31
Copy link
Member

est31 commented Apr 20, 2020

Some information I've gathered:

  • The spec can be found here. It's a bit hard to understand in isolation as it's incomplete and some numbers are given in bits and others in bytes. You need to figure this out from other resources (see below).
  • We ONLY have to worry about the .idata section. Despite the syntax suggesting the opposite, the information is purely additive and doesn't change ANYTHING about the import itself (additional attribute in LLVM IR, etc). Roughly, .lib files that this feature wants to make unneccessary are condensed idata sections and the linker extracts the relevant ones for us. This is good for us because we don't need LLVM to support any custom attributes. Not tried it, but emitting additional sections should be enough, and there is LLVM API support for adding sections.
  • We'll have to generate not a single .idata section but rather multiple .idata$2, .idata$3, .idata$4, .idata$6, .idata$7 ones. See this part of the spec that explains the rationale
  • @SlugFiller has given a nice example in the original issue Produce idata content for dll/dylib import on windows #30027 in terms of llvm IR code what has to be done.
  • Basically, one "only" needs to create this IR code via the llvm API wrappers. The place for this is the librustc_codegen_llvm crate. One probably has to invoke the llvm::LLVMSetSection function in some fashion (just giving you something to grep for)
  • The current size check as of Add feature gate for raw_dylib. #63948 for the ordinals is too tolerant. The spec (section "import lookup table") only allocates 16 bits for both PE32 and PE32+.

To my best knowledge, these are the meanings of the .idata$* sections. See the spec/example for further understanding:

section name in the MS spec description
.idata$2 Import directory table main list containing pointers into the other tables. Each entry in the list concerns one dll and contains pointers to the import address/lookup table, dll name table
.idata$3 Import Address Table At compile time same as import lookup table. Just duplicate the output! Not sure whether it's actually .idata$5
.idata$4 Import Lookup Table Has pointers to the function names
.idata$6 Hint/Name Table Contains the names of the functions we want to import. Also contains export name table hints which are NOT the same as ordinals and we'll probably have to set to 0
.idata$7 No name in the MS spec, let's call it DLL name table Contains the names for the dll files

The main table is the import directory table which contains pointers into the other tables. Linkers are smart enough to assemble all the relative pointers.

As for who's implementing it, I've stopped contributing patches to the compiler years ago. Better someone else does it. Hope that with my help instructions and @retep998 's bounty there will be some movement on this. Of course I'm around to answer questions.

@tinaun
Copy link
Contributor

tinaun commented Apr 22, 2020

that has been invaluable so far, thank you

@luser
Copy link
Contributor

luser commented May 5, 2020

Just as a note about prior art, Apple stopped shipping .dylibs in their SDKs a while ago in favor of "TBD files" which are just YAML descriptions of shared libraries with enough information to link against them. Unfortunately they have zero actual documentation about them available, but the Swift compiler seems to support both generating and linking against them:
https://github.com/apple/swift/blob/5d8af8ccf55f3d3dd7ad55dd8fbdc97d15c5b6bf/test/TBD/linking-with-tbd.swift
https://github.com/apple/swift/blob/5d8af8ccf55f3d3dd7ad55dd8fbdc97d15c5b6bf/lib/FrontendTool/TBD.cpp

@retep998
Copy link
Member

retep998 commented May 5, 2020

Those "TBD files" are just the YAML equivalent of import libraries on Windows and are still separate files from the source code, so it isn't that novel.

bors added a commit to rust-lang-ci/rust that referenced this issue Mar 23, 2023
Fix cross-compiling with dlltool for raw-dylib

Fix for rust-lang#103939

Issue Details:
When attempting to cross-compile using the `raw-dylib` feature and the GNU toolchain, rustc would attempt to find a cross-compiling version of dlltool (e.g., `i686-w64-mingw32-dlltool`). The has two issues 1) on Windows dlltool is always `dlltool` (no cross-compiling named versions exist) and 2) it only supported compiling to i686 and x86_64 resulting in ARM 32 and 64 compiling as x86_64.

Fix Details:
* On Windows always use the normal `dlltool` binary.
* Add the ARM64 cross-compiling dlltool name (support for this is coming: https://sourceware.org/bugzilla/show_bug.cgi?id=29964)
* Provide the `-m` argument to dlltool to indicate the target machine type.

(This is the first of two PRs to fix the remaining issues for the `raw-dylib` feature (rust-lang#58713) that is blocking stabilization (rust-lang#104218))
@dpaoliello
Copy link
Contributor

dpaoliello commented Mar 27, 2023

Request for Stabilization

I'd like to stabilize raw-dylib for all architectures (i.e., x86 as it is stabilized for all other architectures). A stabilization PR has been submitted as #109677.

Summary

The following four features will be stabilized:

  • The raw-dylib kind for the link attribute:
    #[link(name = "exporter", kind = "raw-dylib")]
    extern "stdcall" {
        fn imported_function_stdcall(i: i32);
    }
  • The link_ordinal attribute:
    #[link(name = "exporter", kind = "raw-dylib")]
    extern "stdcall" {
        #[link_ordinal(15)]
        fn imported_function_stdcall(i: i32);
    }
  • The import_name_type option for the link attribute:
    #[link(name = "exporter", kind = "raw-dylib", import_name_type = "decorated")]
    extern "stdcall" {
        fn imported_function_stdcall(i: i32);
    }
  • The -Cdlltool codegen option:
rustc --crate-type lib lib.rs -Cdlltool=/path/to/dlltool

Documentation

I've submitted the following PRs:

Tests

You can find test cases in:

Additionally, raw-dylib is supported in the windows-rs crate (microsoft/windows-rs#2164) and the windows-rs crate with raw-dylib support enabled is being used in the Rust compiler, bootstrap and compilertest (#106610).

Unresolved issues

None currently known.

@simonbuchan
Copy link
Contributor

Now it's seemingly unblocked, for clarification, what would that last checklist item mean?

Implementation of a pure Rust target for Windows (no libc, no msvc, no mingw). This may require another RFC

Given that seems to want a break from msvc or whatever CRT compatibility, would that, other than the literal adding the target, mean "just" adding branches to std that call windows-rs (or equivalent I guess) for sys impls and not initializing the CRT?

At least the former seems like it could be unconditional on windows (not sure if eg. gnu wants anything special) and the latter seems like a small change?

@ChrisDenton
Copy link
Member

I think it would require a new target or at least significant changes elsewhere. And that is beyond the scope of this feature.

It could be tracked separately if someone is interested in pushing that forward.

@simonbuchan
Copy link
Contributor

Don't disagree, but if I'm not missing something big that sounds like something I could take a stab at (no promises!)

@ChrisDenton
Copy link
Member

Well I guess the big thing to implement would be panic handling. But being panic=abort only would be fine to start with.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 1, 2023
…ister,wesleywiser

Stabilize raw-dylib, link_ordinal, import_name_type and -Cdlltool

This stabilizes the `raw-dylib` feature (rust-lang#58713) for all architectures (i.e., `x86` as it is already stable for all other architectures).

Changes:
* Permit the use of the `raw-dylib` link kind for x86, the `link_ordinal` attribute and the `import_name_type` key for the `link` attribute.
* Mark the `raw_dylib` feature as stable.
* Stabilized the `-Zdlltool` argument as `-Cdlltool`.
* Note the path to `dlltool` if invoking it failed (we don't need to do this if `dlltool` returns an error since it prints its path in the error message).
* Adds tests for `-Cdlltool`.
* Adds tests for being unable to find the dlltool executable, and dlltool failing.
* Fixes a bug where we were checking the exit code of dlltool to see if it failed, but dlltool always returns 0 (indicating success), so instead we need to check if anything was written to `stderr`.

NOTE: As previously noted (rust-lang#104218 (comment)) using dlltool within rustc is temporary, but this is not the first time that Rust has added a temporary tool use and argument: rust-lang#104218 (comment)

Big thanks to `@tbu-` for the first version of this PR (rust-lang#104218)
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 2, 2023
…ister,wesleywiser

Stabilize raw-dylib, link_ordinal, import_name_type and -Cdlltool

This stabilizes the `raw-dylib` feature (rust-lang#58713) for all architectures (i.e., `x86` as it is already stable for all other architectures).

Changes:
* Permit the use of the `raw-dylib` link kind for x86, the `link_ordinal` attribute and the `import_name_type` key for the `link` attribute.
* Mark the `raw_dylib` feature as stable.
* Stabilized the `-Zdlltool` argument as `-Cdlltool`.
* Note the path to `dlltool` if invoking it failed (we don't need to do this if `dlltool` returns an error since it prints its path in the error message).
* Adds tests for `-Cdlltool`.
* Adds tests for being unable to find the dlltool executable, and dlltool failing.
* Fixes a bug where we were checking the exit code of dlltool to see if it failed, but dlltool always returns 0 (indicating success), so instead we need to check if anything was written to `stderr`.

NOTE: As previously noted (rust-lang#104218 (comment)) using dlltool within rustc is temporary, but this is not the first time that Rust has added a temporary tool use and argument: rust-lang#104218 (comment)

Big thanks to ``@tbu-`` for the first version of this PR (rust-lang#104218)
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 3, 2023
…ister,wesleywiser

Stabilize raw-dylib, link_ordinal, import_name_type and -Cdlltool

This stabilizes the `raw-dylib` feature (rust-lang#58713) for all architectures (i.e., `x86` as it is already stable for all other architectures).

Changes:
* Permit the use of the `raw-dylib` link kind for x86, the `link_ordinal` attribute and the `import_name_type` key for the `link` attribute.
* Mark the `raw_dylib` feature as stable.
* Stabilized the `-Zdlltool` argument as `-Cdlltool`.
* Note the path to `dlltool` if invoking it failed (we don't need to do this if `dlltool` returns an error since it prints its path in the error message).
* Adds tests for `-Cdlltool`.
* Adds tests for being unable to find the dlltool executable, and dlltool failing.
* Fixes a bug where we were checking the exit code of dlltool to see if it failed, but dlltool always returns 0 (indicating success), so instead we need to check if anything was written to `stderr`.

NOTE: As previously noted (rust-lang#104218 (comment)) using dlltool within rustc is temporary, but this is not the first time that Rust has added a temporary tool use and argument: rust-lang#104218 (comment)

Big thanks to ```@tbu-``` for the first version of this PR (rust-lang#104218)
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 3, 2023
…ister,wesleywiser

Stabilize raw-dylib, link_ordinal, import_name_type and -Cdlltool

This stabilizes the `raw-dylib` feature (rust-lang#58713) for all architectures (i.e., `x86` as it is already stable for all other architectures).

Changes:
* Permit the use of the `raw-dylib` link kind for x86, the `link_ordinal` attribute and the `import_name_type` key for the `link` attribute.
* Mark the `raw_dylib` feature as stable.
* Stabilized the `-Zdlltool` argument as `-Cdlltool`.
* Note the path to `dlltool` if invoking it failed (we don't need to do this if `dlltool` returns an error since it prints its path in the error message).
* Adds tests for `-Cdlltool`.
* Adds tests for being unable to find the dlltool executable, and dlltool failing.
* Fixes a bug where we were checking the exit code of dlltool to see if it failed, but dlltool always returns 0 (indicating success), so instead we need to check if anything was written to `stderr`.

NOTE: As previously noted (rust-lang#104218 (comment)) using dlltool within rustc is temporary, but this is not the first time that Rust has added a temporary tool use and argument: rust-lang#104218 (comment)

Big thanks to ````@tbu-```` for the first version of this PR (rust-lang#104218)
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 3, 2023
…ister,wesleywiser

Stabilize raw-dylib, link_ordinal, import_name_type and -Cdlltool

This stabilizes the `raw-dylib` feature (rust-lang#58713) for all architectures (i.e., `x86` as it is already stable for all other architectures).

Changes:
* Permit the use of the `raw-dylib` link kind for x86, the `link_ordinal` attribute and the `import_name_type` key for the `link` attribute.
* Mark the `raw_dylib` feature as stable.
* Stabilized the `-Zdlltool` argument as `-Cdlltool`.
* Note the path to `dlltool` if invoking it failed (we don't need to do this if `dlltool` returns an error since it prints its path in the error message).
* Adds tests for `-Cdlltool`.
* Adds tests for being unable to find the dlltool executable, and dlltool failing.
* Fixes a bug where we were checking the exit code of dlltool to see if it failed, but dlltool always returns 0 (indicating success), so instead we need to check if anything was written to `stderr`.

NOTE: As previously noted (rust-lang#104218 (comment)) using dlltool within rustc is temporary, but this is not the first time that Rust has added a temporary tool use and argument: rust-lang#104218 (comment)

Big thanks to `````@tbu-````` for the first version of this PR (rust-lang#104218)
JohnTitor added a commit to JohnTitor/rust that referenced this issue May 6, 2023
…ister,wesleywiser

Stabilize raw-dylib, link_ordinal, import_name_type and -Cdlltool

This stabilizes the `raw-dylib` feature (rust-lang#58713) for all architectures (i.e., `x86` as it is already stable for all other architectures).

Changes:
* Permit the use of the `raw-dylib` link kind for x86, the `link_ordinal` attribute and the `import_name_type` key for the `link` attribute.
* Mark the `raw_dylib` feature as stable.
* Stabilized the `-Zdlltool` argument as `-Cdlltool`.
* Note the path to `dlltool` if invoking it failed (we don't need to do this if `dlltool` returns an error since it prints its path in the error message).
* Adds tests for `-Cdlltool`.
* Adds tests for being unable to find the dlltool executable, and dlltool failing.
* Fixes a bug where we were checking the exit code of dlltool to see if it failed, but dlltool always returns 0 (indicating success), so instead we need to check if anything was written to `stderr`.

NOTE: As previously noted (rust-lang#104218 (comment)) using dlltool within rustc is temporary, but this is not the first time that Rust has added a temporary tool use and argument: rust-lang#104218 (comment)

Big thanks to ``````@tbu-`````` for the first version of this PR (rust-lang#104218)
@top-master
Copy link

top-master commented May 18, 2023

I was redirected to here from:
https://users.rust-lang.org/t/can-i-compile-on-windows-using-nothing-but-the-llvm-toolchain/25683

There, people complain that MSVC is huge, and that they prefer clang (instead of MingW).

But LLVM and/or clang is not yet (if ever) stand-alone for Windows,
and it needs to be mixed either with MSVC or MingW to be a full compiler.

Said mixing is rather complicated, hence is worth an entire project of it's own, see:
https://github.com/mstorsjo/llvm-mingw

And at time of writting, linked project has ready to use releases for Windows, like:
llvm-mingw-20220906-msvcrt-i686.zip (117 MiB)


Long story short; rust may already support compiling with clang,
because there is a project that wraps clang into MingW, see above links.

@ChrisDenton
Copy link
Member

We have *-pc-windows-gnullvm targets (currently tier 3) that use llvm with mingw.

Using llvm with msvc is tracked here: #71520. You can already replace msvc's link with lld-link, however libraries for panic handling and the C runtime are still required.

@ChrisDenton
Copy link
Member

tl;dr I propose adding a "system" value to import_name_type.

To illustrate the issue with the current MVP implementation, this works on x64 but not x86:

#[link(name="kernel32", kind="raw-dylib")]
extern "system" {
    fn GetLastError() -> u32;
}

To make it work you have to know about name mangling and do:

#[link(name="kernel32", kind="raw-dylib", import_name_type="undecorated")]

But then this won't work on x64, so you'll need to make it conditional on the target arch. You'll likely end up using a macro to abstract over that, e.g. https://github.com/microsoft/windows-rs/blob/c70019f5126555754e02358758b5a24f2100db85/crates/libs/targets/src/lib.rs#L7-L31. This means that you not only have to know about name mangling but also you're forced to update the code when a new target is added. For example, if we got a ARM64EC target then we'd need to update the windows crate's raw-dylib macro to support the new import_name_type.

I believe targets should already know how linking works for their target and not unnecessarily push that on the users of that target. Therefore I suggest adding a "system" value for import_name_type and allow setting it on all targets that support raw-dylib. E.g.:

// This works for all architectures
#[link(name="kernel32", kind="raw-dylib", import_name_type="system")]

@dpaoliello
Copy link
Contributor

tl;dr I propose adding a "system" value to import_name_type.

To illustrate the issue with the current MVP implementation, this works on x64 but not x86:

#[link(name="kernel32", kind="raw-dylib")]
extern "system" {
    fn GetLastError() -> u32;
}

To make it work you have to know about name mangling and do:

#[link(name="kernel32", kind="raw-dylib", import_name_type="undecorated")]

But then this won't work on x64, so you'll need to make it conditional on the target arch. You'll likely end up using a macro to abstract over that, e.g. https://github.com/microsoft/windows-rs/blob/c70019f5126555754e02358758b5a24f2100db85/crates/libs/targets/src/lib.rs#L7-L31. This means that you not only have to know about name mangling but also you're forced to update the code when a new target is added. For example, if we got a ARM64EC target then we'd need to update the windows crate's raw-dylib macro to support the new import_name_type.

I believe targets should already know how linking works for their target and not unnecessarily push that on the users of that target. Therefore I suggest adding a "system" value for import_name_type and allow setting it on all targets that support raw-dylib. E.g.:

// This works for all architectures
#[link(name="kernel32", kind="raw-dylib", import_name_type="system")]

If you're using raw-dylib, then you do need to be aware of name mangling, since you are opting out of using vendor-provided import libraries (which would have the correct names) and instead getting the Rust compiler to generate the mangled names itself from whatever information you provide.

I also don't believe that a system option for import_name_type would help, since system on x86 would decorate the name (it would be strange not to). Something like undecorate_on_x86 would be clearer and produce the behavior that you want but is a design dead-end.

Not supporting import_name_type outside of x86 was an explicit design choice for this feature to match #87678 rather than adding more debt for that item to clean up. In theory, Rust is moving to a model where using a feature that is unsupported on an arch results in an error rather than doing nothing - if that's something that you disagree with then I suggest you comment on #87678 or file an RFC so that we can have that discussion. If #87678 is adopted then you'll need to use macros anyway to get the correct calling convention on x86 so included import_name_type in that macro is moot.

As for ARM64EC, when (not "if" 😉) we add support for that, then the current design gives us the space to decide how to support it: with the current design using import_name_type on ARM64EC will result in an error, and so making it meaningful later will not be a breaking change. If we had system, then we'd need to decide what it means ("to decorate, or not to decorate, that is the question" 🫴💀) and, if we get it wrong, changing it later would be a breaking change. If we went down the route of adding undecorate_on_x86 and then decide that undecorated on ARM64EC was the correct behavior, would we change the meaning of undecorate_on_x86 to include ARM64EC? Or create a new undecorate_on_x86_and_arm64ec then tell folks to migrate?

@ChrisDenton
Copy link
Member

We already have extern "system" that means "pick the right calling convention for system imports". I don't think #87678 changes that? To be clear, I'm not proposing that import_name_type be ignored on x64, I'm proposing that setting it to the special "system" value means something analogous to the "system" calling convention (i.e. "pick the right name type for system imports"). I would be very surprised if the system import libraries (aka kernel32.lib, etc) would change their name mangling. This is stable and something that could be encoded with the target spec, no? Why force crates to have to figure it out for themselves?

Btw, ARM64EC is especially weird because its mangling scheme is to a prefix a # to the function name (e.g. #GetACP) which is unlike any of the current options we have for import_name_type.

Having a "system" import_name_type would also allow (along with extern system) raw-dylib system imports to just work without having to wait 6-12 months for crates to update their dependencies to use the latest bindings.

@dpaoliello
Copy link
Contributor

We already have extern "system" that means "pick the right calling convention for system imports". I don't think #87678 changes that? To be clear, I'm not proposing that import_name_type be ignored on x64, I'm proposing that setting it to the special "system" value means something analogous to the "system" calling convention (i.e. "pick the right name type for system imports"). I would be very surprised if the system import libraries (aka kernel32.lib, etc) would change their name mangling. This is stable and something that could be encoded with the target spec, no? Why force crates to have to figure it out for themselves?

I wish that were true, but unfortunately it isn't the case. If you look at the docs for __cdecl is describes the name decoration as "Underscore character (_) is prefixed to names, except when __cdecl functions that use C linkage are exported." - so for extern "C" in Rust, do we decorate with _ or not?

Btw, ARM64EC is especially weird because its mangling scheme is to a prefix a # to the function name (e.g. #GetACP) which is unlike any of the current options we have for import_name_type.

I suspect we'll eventually want to support decorated (prefix with # which would link to the ARM64EC function) and undecorated (which would link to an x86_64 function), or we might add new options that explicitly state the arch of the function to decorate for. Either way, by not supporting it for now we can take our time to figure out what we want to support rather than being forced into a decision as soon as ARM64EC is added (and so changing it later would be a breaking change).

Having a "system" import_name_type would also allow (along with extern system) raw-dylib system imports to just work without having to wait 6-12 months for crates to update their dependencies to use the latest bindings.

I only really expect crates like winapi and windows-sys to use raw-dylib. It is an advanced feature that requires knowledge of calling conventions and decorations since you're taking full control of the name and shape of the function to call rather than relying on an import library. Anyone who thinks that they can simply replace dylib with raw-dylib is in for a world of pain (i.e., bizarre linking bugs and mismatched calling conventions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-raw_dylib `#![feature(raw_dylib)]` O-windows Operating system: Windows S-tracking-impl-incomplete Status: The implementation is incomplete. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests