Skip to content

rustc uses non-hermetic libs/paths on Windows #3256

@carpenterjc

Description

@carpenterjc

The rust compiler doesn't use the path of the linker to determine where it should look for libraries/other paths.
On windows if you don't specify the environmental variables from vcvars it will use the registry to guess what version of VS you want to use.

If you have VC 17.10 and VC10.12 installed and compile rust with your C++ toolchain configured to VC17.10 the linker path passed in to the rust compiler is that from VC17.10, however rustc looks in the registry and finds 17.12 installed and provides the standard libs from 17.12 instead.

You will then notice that features which are highly coupled to the linker/lib combinations stop working, for example asan.

See:
https://docs.rs/cc/latest/src/cc/windows/find_tools.rs.html#1190-1191

The workaround is to set VSINSTALLDIR and VCINSTALLDIR in the env.

The main problem from rust/rules/linker combination is this can appear to be working correctly, but your not actually getting the compiled output you expect, and even just installing a trial patch version of the latest VS can generate different binary outputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions