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

trans: Try to detect the Universal CRT on MSVC #27250

Merged
merged 2 commits into from
Jul 28, 2015
Merged

Conversation

alexcrichton
Copy link
Member

Visual Studio 2015, recently released, includes the Universal CRT, a different
flavor than was provided before. The binaries and header files for this library
are included in new locations not previously known about by gcc-rs, and this
commit adds support for the necessary probing to find these.

Unfortunately there are no prior examples of this probing to be found in
frameworks like CMake or clang, so this is done is a bit of a sketchy method
today. It assumes that the installation is in a relatively standard format and
then blindly looks for the location of the UCRT. I'd love to switch this over to
using registry keys for probing, but I was currently unable to find such keys.

This should enable the compiler to work outside VS 2015 dev tools prompts.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member Author

r? @brson

cc @retep998, @vadimcn

I'm.. not actually sure this is the best way to do this, but it's nice to not have to spin up dev tool shells for a number of reasons!

@rust-highfive rust-highfive assigned brson and unassigned nikomatsakis Jul 23, 2015
@alexcrichton
Copy link
Member Author

Another example of where this helps is that all our appveyor.yml files for external crates have this line which can be removed after this lands.

@alexcrichton alexcrichton force-pushed the ucrt branch 2 times, most recently from 4ee257e to a6ce70b Compare July 24, 2015 01:59
Adds support to the configure script for detecting Visual Studio 2015 being
installed and builds LLVM/uses cl with that compiler. The compiler will
automatically use this MSVC linker anyway because it's the highest version.
@vadimcn
Copy link
Contributor

vadimcn commented Jul 24, 2015

MSBuild's logic for finding uCRT can be found in this file: C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\uCRT.props (if you have VS2015 installed).
Looks like they start with directory specified in this registry entry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots@KitsRoot10, then append lib\$(TargetUniversalCRTVersion)\ucrt\$(Arch)

@alexcrichton
Copy link
Member Author

@vadimcn oh nice! Do you know if there's a better way to detect whether an VS installation is using the uCRT? Right now the logic would be something along the lines of "If the VS installation folder '14.0' in it then look at the registry entry (you specified above), find the max 'KitsRootXXX' key, probe for the version of the ucrt (max numerical value in the Lib/ folder), and then add the appropriate LIB path".

I'm somewhat uncomfortable about:

  • Looking for the uCRT only if we see "14.0" in a folder name
  • Looking for the uCRT in KitsRootXX (for the maximum XX). Or is this always going to be KitsRoot10?
  • Probing for the version of the uCRT by just iterating over some folders.

I definitely think though that finding the installation root through the registry is probably better than "find the 8.1 one and then pop a directory and add a 10 onto it" :)

@alexcrichton
Copy link
Member Author

Also, it looks like TargetUniversalCRTVersion comes from TargetPlatformVersion, but I can't seem to find where that originates from, would you happen to know where that is?

Visual Studio 2015, recently released, includes the Universal CRT, a different
flavor than was provided before. The binaries and header files for this library
are included in new locations not previously known about by gcc-rs, and this
commit adds support for the necessary probing to find these.

Unfortunately there are no prior examples of this probing to be found in
frameworks like CMake or clang, so this is done is a bit of a sketchy method
today. It assumes that the installation is in a relatively standard format and
then blindly looks for the location of the UCRT. I'd love to switch this over to
using registry keys for probing, but I was currently unable to find such keys.

This should enable the compiler to work outside VS 2015 dev tools prompts.
@brson
Copy link
Contributor

brson commented Jul 27, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Jul 27, 2015

📌 Commit 7bb585d has been approved by brson

@bors
Copy link
Contributor

bors commented Jul 27, 2015

⌛ Testing commit 7bb585d with merge 8b83557...

bors added a commit that referenced this pull request Jul 27, 2015
Visual Studio 2015, recently released, includes the Universal CRT, a different
flavor than was provided before. The binaries and header files for this library
are included in new locations not previously known about by gcc-rs, and this
commit adds support for the necessary probing to find these.

Unfortunately there are no prior examples of this probing to be found in
frameworks like CMake or clang, so this is done is a bit of a sketchy method
today. It assumes that the installation is in a relatively standard format and
then blindly looks for the location of the UCRT. I'd love to switch this over to
using registry keys for probing, but I was currently unable to find such keys.

This should enable the compiler to work outside VS 2015 dev tools prompts.
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.

6 participants