-
Notifications
You must be signed in to change notification settings - Fork 495
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
Conversation
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)); | ||
|
There was a problem hiding this comment.
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.
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
There was a problem hiding this 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> { |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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.
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! |
I've published this as 0.3.47 |
Thanks for the review @retep998. I'll circle back later to clean up. |
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. |
That's actually perfect, thanks @luser! |
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