-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Cross-compiling raw-dylib
doesn't work on Windows
#103939
Comments
rust/compiler/rustc_codegen_llvm/src/back/archive.rs Lines 404 to 409 in 31d754a
Looks like rustc expects a toolchain that cross compiles from the host (x86_64 mingw) to the target (i686 mingw) rather than a toolchain native to the target (i686 mingw) like in your case. I guess it could try both executable names. |
On Windows toolchains commonly provide only |
I have it on my radar but cannot tell when when I can find free time to do it. |
@rustbot claim |
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))
I am unsure whether the linked pull request above actually fixed this issue for cross-compilation, but I get the same exact error with the stable-x86_64-pc-windows-gnu toolchain version 1.71.0. In this version, the feature should have been stabilized. Should I open a new issue because this one only regards cross-compilation? |
@eiderdaus what is your host environment (Windows? Linux?) and what dlltool(s) do you have on your |
Looking at tokio-rs/mio#1632 (comment) your issue is a bit different. How did you install mingw-w64 toolchain? |
Alternatively you could try |
Hi, thanks for the prompt responses! My host is Windows, there's no dlltool on my %PATH%. I used Rustup to install Rust and I found a dlltool.exe in the following folder: %USERPROFILE%.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\bin\self-contained I would expect that this should be enough for building working Rust applications. I tried passing this dlltool via
I never mentioned any mingw-w64 but actually I do have MSYS2 at my disposal. It's not on my %PATH% at the moment. I just used |
Correct, the use of I the meantime, having dlltool on your |
I'd expect that as well.
This definitely doesn't seem right, might be worth to create issue for having |
Alright, thanks a lot for this information. To be honest I am a little bit disenchanted after the great feature announcement on the Rust blog - I don't normally expect a stabilized feature to still require such workarounds.
Not sure if another issue makes much sense when the whole dlltool invocation should be removed either way if I understood correctly? |
Removal of dlltool might take years, in the meantime bundled dlltool should be fixed and used by the default. |
I see. Just so I fully understand: If what I described is a new issue in your opinion, then why is this one still open? |
It's been a year since this issue was originally reported. Can we bump the self-contained binutils at least? |
That's my plan for the near future but it's easier said than done. Though, at current pace it should hit nightly before 2024. |
Thanks for the quick reply! And sorry that updating is still an ordeal. |
I tried this code:
I expected to see this happen:
Successful compilation
Instead, this happened:
Worth mentioning it works fine when building natively from x86_64 to x86_64 target.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: