-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Suggest installing VS Build Tools in more situations #72296
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @varkor (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This looks reasonable to me, but I'd like to double-check this approach is the right one. Presumably there's not a straightforward way to test this? r? @Mark-Simulacrum |
I did consider a number of approaches. One alternative approach would be to test the linker before doing the linking and show an error if not MSVC's A variation on this PR would be to read the "logo" displayed when running a link command without the
Another approach would be for rustc to always test for the existence of MSVC build tools when building with an msvc toolchain (but not msvc compatible toolchains like |
Doing this after the error occurs and not before does seem like the right approach -- it at least optimizes for the happy path of "everything is good." However, I'm not familiar with the details of our current linker story (especially on Windows), so let's r? @petrochenkov here perhaps? |
Doing the diagnostic based on the error code seems a bit shaky to me. If link.exe ever decides to exit with a code in the range [0, 1000) then this code will inform the user they don't have VC++ correctly installed, even if the |
That is a concern. My goal with checking Adding an explicit check using the |
I've updated the diagnostic to be more robust. Sorry about the messy commit history, I need to get better at knowing if I'm in the VM or host when issuing commands. |
I'll explain my reasoning a bit more. A Microsoft linking error is a four digit number in the range 1000 to 9999 inclusive. So an exit code in this range is a successful failure. Any other error indicates a problem with I've added better checks for the possible ways things could have gone wrong and tailored the notes to each situation (though the messages may need work). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is probably good enough for a simple diagnostic to try to help the user figure out what they did wrong. We can always revisit this in a future PR if it turns out some part of this is inaccurate.
r=me with commits squashed |
Sorry, I'm new at this. Should the squishing be done from my end? |
Yes. Squashing involves using git rebase to squash down your multiple commits into a single commit. |
When MSVC's `link.exe` wasn't found but another `link.exe` was, the error message given can be impenetrable to many users. The usual suspect is GNU's `link` tool. In this case, inform the user that they may need to install VS build tools. This only applies when Microsoft's link tool is expected. Not `lld-link` or other MSVC compatible linkers.
@bors r+ rollup |
📌 Commit 2fd504c has been approved by |
🌲 The tree is currently closed for pull requests below priority 9000, this pull request will be tested once the tree is reopened |
…ochenkov Suggest installing VS Build Tools in more situations When MSVC's `link.exe` wasn't found but another `link.exe` was, the error message given can be [impenetrable](https://pastebin.com/MRMCr7HM) to many users. The usual suspect is GNU's `link` tool. In this case, inform the user that they may need to install VS build tools. This only applies when Microsoft's link tool is expected.
…ochenkov Suggest installing VS Build Tools in more situations When MSVC's `link.exe` wasn't found but another `link.exe` was, the error message given can be [impenetrable](https://pastebin.com/MRMCr7HM) to many users. The usual suspect is GNU's `link` tool. In this case, inform the user that they may need to install VS build tools. This only applies when Microsoft's link tool is expected.
Rollup of 7 pull requests Successful merges: - rust-lang#71854 (Make `std::char` functions and constants associated to `char`.) - rust-lang#72111 (rustc-book: Document `-Z strip=val` option) - rust-lang#72272 (Fix going back in history to a search result page on firefox) - rust-lang#72296 (Suggest installing VS Build Tools in more situations) - rust-lang#72365 (Remove unused `StableHashingContext::node_to_hir_id` method) - rust-lang#72371 (FIX - Char documentation for unexperienced users) - rust-lang#72397 (llvm: Expose tiny code model to users) Failed merges: r? @ghost
When MSVC's
link.exe
wasn't found but anotherlink.exe
was, the error message given can be impenetrable to many users. The usual suspect is GNU'slink
tool. In this case, inform the user that they may need to install VS build tools.This only applies when Microsoft's link tool is expected.