Skip to content
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

Add MSVC 2017 detection #160

Merged
merged 1 commit into from May 25, 2017
Merged

Add MSVC 2017 detection #160

merged 1 commit into from May 25, 2017

Conversation

brson
Copy link
Contributor

@brson brson commented May 24, 2017

This teaches gcc-rs to find tools installed by MSVC 2017. It's not
obvious to what extent the new COM interfaces are expected to be
used. This patch only uses it to find the product installation
directory, then infers everything else. A lot of COM scaffolding to do
very little. The toolchains seem to have a different directory
structure in this release to better support cross-compilation.

It looks to me like all the lib/include logic is pretty much the same
as it always has been.

This is tested to fix the rustup installation logic, and to fix
rustc in basic use cases on x86_64.

cc #143
cc rust-lang/rustup#1003
cc rust-lang/rust#38584
cc alexcrichton/curl-rust#161

let sub = otry!(lib_subdir(target));
let (ucrt, ucrt_version) = otry!(get_ucrt_dir());

tool.path.push(ucrt.join("bin").join(&ucrt_version).join(sub));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line may fix alexcrichton/curl-rust#161. It found 'rc.exe' on my machine at least.

@brson
Copy link
Contributor Author

brson commented May 24, 2017

cc @alexcrichton @retep998 @Diggsey

@brson
Copy link
Contributor Author

brson commented May 24, 2017

The COM code is copied from https://github.com/retep998/msvc-bunny

This teaches gcc-rs to find tools installed by MSVC 2017. It's not
obvious to what extent the new COM interfaces are expected to be
used. This patch only uses it to find the product installation
directory, then infers everything else. A lot of COM scaffolding to do
very little. The toolchains seem to have a different directory
structure in this release to better support cross-compilation.

It looks to me like all the lib/include logic is pretty much the same
as it always has been.

This is tested to fix the rustup installation logic, and to fix
rustc in basic use cases on x86_64.

cc rust-lang#143
cc rust-lang/rustup#1003
cc rust-lang/rust#38584
cc alexcrichton/curl-rust#161
Copy link
Member

@retep998 retep998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS 2015 is 14. VS 2017 is 15.

// the Windows 10 SDK or Windows 8.1 SDK.
fn find_msvc_latest(tool: &str, target: &str, ver: &str) -> Option<Tool> {
fn find_msvc_14_or_15(tool: &str, target: &str, ver: &str) -> Option<Tool> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code only works for 14. The only reason this was used for 15 was due to the early preview versions of 15 before they switched over to the new installer, but those preview versions have all expired so there's nothing left to support there.

// For MSVC 14 or newer we need to find the Universal CRT as well as either
// In MSVC 17 MS once again changed the scheme for locating the tooling.
// Now we must go through some COM interfaces, which is super fun for Rust.
fn find_msvc_17(tool: &str, target: &str) -> Option<Tool> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that while it is called VS 2017, the version number is actually 15, not 17.

@alexcrichton
Copy link
Member

I barely understand all the COM business or what's going on here really, it'd be awesome if there was a document we could link to on MSDN or something like that saying "here's the structure and here's how to run tools", but alas!

In the meantime if it works it works, thanks @brson!

@alexcrichton alexcrichton merged commit c111f13 into rust-lang:master May 25, 2017
@alexcrichton
Copy link
Member

I've published this as 0.3.47

@brson
Copy link
Contributor Author

brson commented May 25, 2017

Thanks for the review @retep998. I'll circle back later to clean up.

@luser
Copy link

luser commented May 26, 2017

I barely understand all the COM business or what's going on here really, it'd be awesome if there was a document we could link to on MSDN or something like that saying "here's the structure and here's how to run tools", but alas!

See https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/. Specifically the "Identifying the VC++ compiler tools version" paragraph.

@alexcrichton
Copy link
Member

That's actually perfect, thanks @luser!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants