rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.19k stars 12.81k forks source link

[Link][Win10][MinGW] cannot perform PE operations on non PE output file #117929

Closed qiji2023 closed 3 weeks ago

qiji2023 commented 1 year ago

rust version: 1.26.0 OS: win10 target: x86_64-pc-windows-gnu

I have a c++ library about opencl gpu, I want to use rust to warp the library.

I get the following error log:

  = note: C:/Users/sh7799/xxxxx/applications/winlibs-x86_64-mcf-seh-gcc-13.2.0-mingw-w64ucrt-11.0.1-r2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot perform PE operations on non PE output file 'C:\Users\sh7799\xxx\projects\aleo_snarkvm_bench\target\x86_64-pc-windows-gnu\release\deps\prover-2851aaf3149e5425.exe'
          collect2.exe: error: ld returned 1 exit status

obviously, it is a link-runtime error,

ChrisDenton commented 1 year ago

That's a very old version of Rust you're using. I'd suggest using something newer which may be more compatible.

Also from the paths, it seems like the C++ library was compiled against the ucrt. Rust's windows-gnu toolchain uses msvcrt. I'd suggest using a C++ library compiled with a compatible C++ toolchain.

There's a newer Rust toolchain (windows-gnullvm) that does use the ucrt but it's tier 3 so not currently distributed via rustup.

qiji2023 commented 1 year ago

That's a very old version of Rust you're using. I'd suggest using something newer which may be more compatible.

Also from the paths, it seems like the C++ library was compiled against the ucrt. Rust's windows-gnu toolchain uses msvcrt. I'd suggest using a C++ library compiled with a compatible C++ toolchain.

There's a newer Rust toolchain (windows-gnullvm) that does use the ucrt but it's tier 3 so not currently distributed via rustup.

No! my gpu code is c++ code, rust only wrap the gpu code, I think windows-gpu and windows-gnullvm is not necessary.

mati865 commented 6 months ago

I doubt it's ucrt vs msvcrt issue, sounds like you have non coff objects somewhere.

Hi, are there any plans to upgrade gnullvm to Tier1?

Why do you need tier 1 specifically? In the next stable release, gnullvm targets will become tier 2 without host tools which means you can cross-compile for it using, for example, windows-gnu host toolchain. For gnullvm targets to become host compilers, they have to become tier 2 with host tools. I don't know what is necessary for it to happen and how to quantify whether their usefulness is worth additional CI resources. I suppose you could open an issue for it or ask on discourse/zulip.

mati865 commented 6 months ago

That doesn't answer the question why tier 1 is important. Anyway, please move to a new issue if you want to discuss this further since it's unrelated to the original post.

mati865 commented 3 weeks ago

Triage: Not actionable unless the issue also manifests with up-to-date toolchains, which is still unanswered.

ChrisDenton commented 3 weeks ago

Ok, closing this as not actionable. It can be reopened if more information is provided