Rust and Visual Studio 2017 compatibility updates

Hi.

I spent last week getting Rust to work with Visual Studio 2017. In the
process I learned a few things that crate authors need to know in
order to ensure VS2017 compatibility. Here they are.

TL;DR:

  • rustc 1.19.0-nightly (0418fa9d3 2017-06-04) should work correctly
    with VS 2017 without running vcvars.bat. Sadly, it's now busted
    against gnu toolchains, but that should be fixed soon.
  • Upgrade gcc-rs deps to 0.3.50
  • Upgrade cmake deps to 0.1.24
  • Upgrade lzma-sys to 0.1.6

In VS 2017 the scheme for locating the MSVC compiler changed again, so
I updated the gcc crate (which is actually the general C compiler
driver crate) to do that detection, based on work by @retep998, and
then updated rustc itself to use the gcc crate instead of its own
logic.

Similarly, I replaced some detection logic in cmake-rs to defer again
to gcc-rs, making gcc-rs the source of truth globally for locating
MSVC.

And in the process I discovered that lzma-sys was reporting the wrong
"platform toolset" version to msbuild (it should be "v141"), and
upgraded that.

At this point, cargo, rls, and rustup all appear to build correctly
under VS 2017. So please give it a try and see if it works for you.

References:

3 Likes

How hard is it for a rust noob to get rust and VS2017 working?

@jeramyRR Rust is supposed to just work out of the box if VS is installed (that is - the compiler works; actual integration with the VS IDE is a different story). AFAIK it does with VS 2013 and VS 2015, and until now hasn't with VS 2017.

As of today it should be a matter of following the install instructions, except where they say "VS 2015", use VS 2017, and afterward, switch to the nightly toolchain with rustup default nightly.

Don't want to derail the discussion, but speaking of using VS 2017 IDE for Rust, VS 2017 now supports opening a folder without requiring you to create a project or solution: Open any folder with C++ sources in Visual Studio 2017 RC - C++ Team Blog . So you can now open your Rust crate folder in VS, set up the JSON config files as described in the above-linked page and you should be able to code, build and debug Rust in the VS IDE.