-
Notifications
You must be signed in to change notification settings - Fork 739
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
Linking fails with x86_64-pc-windows-gnu toolchain #1632
Comments
Why are you not using |
Do I really need to elaborate? Honestly your question baffles me. There are many reasons:
|
Okay.
But you're running Windows 10? Not judging or disagreeing mind you...
I was merely wondering if you a specific reason not use the default MSVC based target, and looking at the list it seems you do. Currently we don't test with Does changing Alternatively we can try adding it to windows-sys since it's now documented: https://learn.microsoft.com/en-us/windows/win32/devnotes/nt-cancel-io-file-ex (/cc @kennykerr). |
Please forgive my unfriendlyness, I regretted my wording the moment I pressed the comment button.
Well as you might imagine I have my reasons for that, too 😅
Yes both do work. It's
That would be great. I think changing the link attribute without actually providing suitable linker import libraries makes this rather brittle as it depends on an implementation detail of windows-sys or winapi-rs. |
Sure, I'll see about getting this function included in the Win32 metadata. |
I opened microsoft/wdkmetadata#9 - if they can include the function then |
@Thomasdezeeuw In the meantime, you could try calling |
I'm afraid I don't have a Windows machine available at the moment. Maybe someone from @tokio-rs/windows can give this a try? |
Don't read this documentation though! It is very much incorrect, reading it will make you dumber and your program crash. The signature spelled out in the issue description is the right one. |
This problem has massively affected me a month ago and when I found this issue, I left it as that, thinking that I'll get back to my project in the distant future, meanwhile I was also watching when |
@kennykerr Though microsoft/wdkmetadata#9 was fixed in the meantime, I can not find a definition of |
Yep, if you open an issue I'll have a reminder to update the metadata. 😉 |
Rust now redistributes Of course, once the |
windows-targets 0.48.2 will include these imports. |
microsoft/windows-rs#2573 updated the repo with the latest metadata. Please kick the tires and let me know if you experience any issues. |
Gave it a shot in #1688. Windows-sys contains a number of breaking changes, so the next version will likely be 0.49, which means a (slightly) painful update where we have to coordinate a little bit with the ecosystem. Other than that everything |
I just tried an alternative workaround based on the newly introduced I merely updated to Rust 1.71 and replaced the original Can anyone confirm that this does not work before I open an issue against https://github.com/rust-lang/rust/? |
This is a known issue: rust-lang/rust#103939 The |
If all you need is windows_targets::link!("ntdll.dll" "system" fn NtCancelIoFileEx(filehandle: HANDLE, iorequesttocancel: *const IO_STATUS_BLOCK, iostatusblock: *mut IO_STATUS_BLOCK) -> NTSTATUS); Let me know - happy to release an update to |
Yeah I found this issue, too, in the meantime. Though I'd argue using Thanks for your offer regarding an update to |
You can get https://github.com/microsoft/windows-rs/blob/master/.github/workflows/raw_dylib.yml It relies on this workaround to deal with the
I'm working furiously on stabilizing metadata, but until then the crate releases are on-demand only to avoid churn. Of course, if |
Adding |
|
We already use IOCP and iouring is Linux only. |
https://learn.microsoft.com/en-us/windows/win32/api/ioringapi/ |
Mio defines
NtCancelIoFileEx
as follows:If I add
fn main(){}
and build withcargo build
I get the following linker error:Compiling the example from README.md fails with the same error (only with more dependencies in the linker command) and so does my Tokio-dependent application.
The reason is obviously
#[link(name = "ntdll")]
. There's no libntdll.a in my%USERPROFILE%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\self-contained
folder.The windows-sys crate for example also provides some functions from ntdll.dll but those are annotated with link(name = "windows") and they provide their own libwindows.a. This works flawlessly for me. winapi-rs provides libwindows_ntdll.a in addition to many other libraries but it doesn't actually provide any functions from ntdll.dll (I think).
I am using Windows 10 and just reinstalled Rust freshly via Rustup, changing only the platform tuple to
x86_64-pc-windows-gnu
and leaving all other defaults alone. I am uncertain which version of Rust or mio introduced this issue. I only found out when I wanted to recompile a Tokio-dependent project which still worked a few months ago at least.The text was updated successfully, but these errors were encountered: