-
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
rustc cannot find MSVC on Windows arm64 #83043
Comments
Transferred to rust-lang/rust. Cargo isn't responsible for finding or running the linker, that is all done inside |
Yes, sorry, you're right. For some reason I was sure I found the corresponding code in cargo, but it indeed appears to be in rustc. Thanks! I'll update the original post accordingly. |
@alexcrichton Hi, do you think it's best to fix it in |
I think the best solution would be to update |
I reached out on twitter to MS and established a dialogue - thread here - https://twitter.com/rbtcollins/status/1371451812209909761 |
Thanks @rbtcollins ! @alexcrichton I have a machine so it shouldn't be a problem for me to implement the solution. The issue is that apparently there are only 2 ways to get this info, one is the COM component which is not available for an arm64 process, and the other one is vswhere.exe - which in turn uses the same COM component but from an emulated x86 process which works. Unfortunately, the registry doesn't contain any information about VS16, so the only other way to refrain from calling vswhere.exe is probably just guessing the path for now 🤷 |
@Alovchin91 good to hear you've got hardware - I did read the bug and links before reaching out on twitter: I've found clear communication can get an effective dialogue happening. Over to you two now :). |
Ah this sounds somewhat familiar, thanks for the info @Alovchin91! If that's the case then it seems fine to go ahead and just spawn |
Yes, it's actually the only way to run arm64 cargo/rustc on Windows now - using the vsvars.bat which sets the proper environment variables. I also think that rustc could set the environment variables, though I'd probably call them something special (e.g. RUSTC_LINK_PATH or similar). Or maybe cc-rs should set those? 🤔 I think we could use the following approach then:
This could also slightly improve the speed on non-arm64 Windows because of p.2 preventing the creation of a COM object. What do you think? |
Seems reasonable to me! |
Okay, so I've implemented a big part of the functionality I think: https://github.com/Alovchin91/cc-rs/compare/alovchin91/win-arm64 The only thing that's left is the environment variable(s). And now I have a few questions:
Also an important point: I'm an enthusiast-level Rust programmer so a thorough code review would be very welcome 😄 |
Nice! I agree that |
Sounds good to me! I'll check which option would be the sanest and the simplest code wise and will prepare a PR 👍 |
Sorry for the delay; I have opened a Pull Request for cc-rs to use vswhere.exe as a last resort in finding VS2015+ instances: Please give it a strict review 😅 whenever you have time :) |
Recent commits to cc have helped to address rust-lang#83043 and rust-lang#43468
Update cc Recent commits have improved `cc`'s finding of MSVC tools on Windows. In particular it should help to address these issues: rust-lang#83043 and rust-lang#43468
Update cc Recent commits have improved `cc`'s finding of MSVC tools on Windows. In particular it should help to address these issues: rust-lang#83043 and rust-lang#43468
Update cc Recent commits have improved `cc`'s finding of MSVC tools on Windows. In particular it should help to address these issues: rust-lang#83043 and rust-lang#43468
@ChrisDenton So, #85649 fixed this issue? |
@JohnTitor I'm going to check that today. There was another commit to cc-rs to further improve this, so it might need to be updated again: rust-lang/cc-rs#605 |
@Alovchin91 Nice! If rust-lang/cc-rs#597 and rust-lang/cc-rs#605 can close this issue, we need a new release to include the latter. |
@JohnTitor Would the GitHub PR pipeline produce a runnable build? I've never bootstrapped the compiler before and I'm a bit afraid it would take me another week to get it right 😅 |
Hmm, IIRC the GHA itself doesn't, but we upload the build artifacts to s3 so it may be possible. But it needs t-infra's help and I'm not sure how hard it is. |
I just published 1.0.69 to make sure all recent changes are published as well. |
Thanks! Opened #87099 to upgrade the |
…richton Upgrade `cc` crate to 1.0.69 This pulls another fix for rust-lang#83043, i.e., rust-lang/cc-rs#605. r? `@alexcrichton`
…richton Upgrade `cc` crate to 1.0.69 This pulls another fix for rust-lang#83043, i.e., rust-lang/cc-rs#605. r? ``@alexcrichton``
Sorry for the late reply, I have used the latest beta ( Shall there be future work (e.g. using x64-emulated MSVC on Windows 11 as x64 emulation is significantly faster than x86), I believe it can be tracked in cc-rs repo from now on? |
Sounds like a plan. |
Heads up: rust-lang/cc-rs#732 |
Problem
When building Rust projects on Windows 10 arm64, rustc cannot find MSVC installation to use tools like link.exe.
The reason is because Visual Studio Installer doesn't properly register the installation on arm64.
To determine MSVC installation, rustc uses the great cc-rs crate which itself uses the SetupConfiguration COM component (Microsoft.VisualStudio.Setup.Configuration.Native.dll) to determine the path of Visual Studio (or Visual C++ Build Tools) installation. On Windows 10 arm64, it fails to create an instance of a COM class.
Steps
aarch64-pc-windows-msvc
toolchain on a Windows 10 arm64 machinecargo build
Possible Solution(s)
The issue happens because on arm64 VS Installer doesn't register the COM component. To be more precise, it registers the x86 version of the COM component, but there is no arm64 version. Unfortunately Microsoft is not willing to fix the issue, even though it was reported twice, with the reason being that Visual Studio doesn't support running on arm64.
A (rather easy) workaround to the issue is to always run cargo/rustc within the x86_arm64 Developer Console. To do this, the user has to call
vcvarsx86_arm64.bat
before doing anything else in the console. This way, cc-rs can determine Visual Studio installation from the environment variables.For rustc itself, a solution could be to first attempt searching in the known VS Installer path (
%ProgramFiles(x86)%\Microsoft Visual Studio\Installer
) forvswhere.exe
on arm64 Windows and, if found, running it to get information about the installed VS instances.Another option could be spawning a dedicated x86-emulated process that would be able to use the x86 COM component and give the information back to rustc, though this option seems to be an overkill 😅
Meta
rustc --version --verbose
:Environment:
aarch64-pc-windows-msvc
toolchainThe text was updated successfully, but these errors were encountered: