-
Notifications
You must be signed in to change notification settings - Fork 538
Description
There's been a bit of discussion recently spread across a number of PRs1 so I'd like to centralize discussion and explain my position here. What follows is my view of the situation. My hope is that a consensus can be found or, if not, then at least we can gain a better understanding of where everyone is coming from.
windows_registry
2 can be used to query Visual Studio for the path of tools and to get associated libraries, binaries and header files. For example, rustc uses it to find link.exe
and also to link required libraries such as the crt and import libraries such as kernel32.lib.
cc-rs finds the tool by first attempting to use current environment variables. These are set up when using a Visual Studio shell or by something else setting the build environment.
However, if the environment is not set, is incomplete, or it is incompatible with the build target (e.g. x86 vs. x64) then cc-rs will use the Visual Studio Installer API to query for the requested tool and other paths.
In this case it mostly ignores the environment variables and prioritises its own, hard coded, set of defaults. This means that any preferences are lost and must be manually reapplied by users of cc-rs. This can also make it harder to integrate with other build systems. My view is that any discrepancies this causes should be considered a bug in cc-rs.
Note that there are currently two case where we do use environment defaults: when the target doesn't match the environment the Visual Studio directory is taken from the environment and when looking for the Windows API SDK, it will first check environment variables instead of always using the latest.
So my question is on a point of policy. What is the role of cc-rs
here? Should should it defer to the environment when setting initial defaults or should it continue to (mostly) override the environment with its own hard-coded defaults?