rust-lang / rust-lang/rust

Rustc can't find windows tools in non-standard location

Open
#149,099 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-linkers C-discussion O-windows-msvc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

When building rust on windows for use in chromium, we get the following error:

error: linker `link.exe` not found
   |
   = note: program not found
 
 note: the msvc targets depend on the msvc linker but `link.exe` was not found
 
 note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.
 
 note: VS Code is a different product, and is not sufficient.

The machine in question does have a windows toolchain installed, including link.exe, but it's not in the "normal" place. Rather than installing the SDK on our bots, we bundle all the windows tools together in a separate package, but as far as I can tell there's no way to inform the compiler of this fact.

Doing a little digging myself, it seems like the error is emitted here and the linker lookup happens here, which calls out to the find_msvc_tools crate, which then does a search based on the registry. Since our package isn't included in the registry, it doesn't get found.

It seems like the solution would be to pass a flag pointing to the location of the windows tools, e.g. something like clang's -winsysroot flag. I don't know how to go about adding that, however.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading compiler/rustc_codegen_ssa/src/back/link.rs at the reported error and linker.rs at the linker lookup, then inspect how find-msvc-tools searches for tools. Define how a flag for a non-standard Windows tool location should be passed through; done means a bundled toolchain containing link.exe can be found without registry installation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.