This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Use UniversalCRT on Windows if available
ClosedPublic

Authored by ikudrin on Sep 8 2015, 8:05 AM.

Details

Summary

With Visual Studio 2015 release, a part of runtime library was extracted and now comes with Windows Kits. This patch enables clang to use Universal CRT library if %INCLUDE or %LIB environment varaibles are not specified.

See also https://llvm.org/bugs/show_bug.cgi?id=24741

Diff Detail

Event Timeline

ikudrin updated this revision to Diff 34213.Sep 8 2015, 8:05 AM
ikudrin retitled this revision from to [Driver] Use UniversalCRT on Windows if available.
ikudrin updated this object.
ikudrin added a subscriber: cfe-commits.
rnk edited edge metadata.Sep 10 2015, 9:02 AM
rnk added a subscriber: ruiu.

FYI @ruiu is moving this code to LLVM in D12604.

lib/Driver/MSVCToolChain.cpp
328–340

Refactor this into a helper like StringRef getWindowsSDKArch(llvm::Triple::Arch) and share it with getWindowsSDKLibraryPath.

lib/Driver/Tools.cpp
8956–8959

Does this have to be conditional on the version of the CRT in use? If I install VS 2013 and the ucrt and am trying to use the 2013 CRT, this will put both on the libpath. Is that a problem?

ikudrin updated this revision to Diff 34462.Sep 10 2015, 10:51 AM
ikudrin edited edge metadata.
  • Extracted a function to convert an architecture type to a library subfolder name.
  • Added a method to check if we should use Universal CRT depending on the chosen version of Visual Studio.
ikudrin updated this revision to Diff 34465.Sep 10 2015, 10:54 AM
ikudrin marked an inline comment as done.

Just added more context to the patch.

ikudrin marked an inline comment as done.Sep 10 2015, 11:05 AM
In D12695#243320, @rnk wrote:

FYI @ruiu is moving this code to LLVM in D12604.

Thanks. I think I'll move my changes to the new place when he's finished.

rnk added a comment.Sep 10 2015, 11:17 AM

There's a bunch of whitespace issues that clang-format can resolve. We also have the convention that variables are StudlyCaps, which isn't followed in a few places.

Do you need someone to commit this for you? If so, I can patch this in, test it manually, and deal with the style stuff if you deal with the VSDir part.

lib/Driver/MSVCToolChain.cpp
293

This should really take VSDir as a parameter instead of recomputing it, since all the callers are already computing it.

In D12695#243552, @rnk wrote:

There's a bunch of whitespace issues that clang-format can resolve.

Thanks! I'll reformat it.

We also have the convention that variables are StudlyCaps, which isn't followed in a few places.

I've tried to follow the style of the source file. Do you think I should force this rule here?

Do you need someone to commit this for you? If so, I can patch this in, test it manually, and deal with the style stuff if you deal with the VSDir part.

I'd really appreciate it. I'll prepare a new version in a few minutes.

ikudrin updated this revision to Diff 34475.Sep 10 2015, 12:26 PM
  • Fixed formatting issues.
  • Normalized VariableNames.
  • Reworked the useUniversalCRT method to receive a path of Visual Studio.
ruiu added a comment.Sep 10 2015, 12:54 PM

I'm sorry about leave D12604 hanging. I didn't notice that it got a new review message. Don't mind my patch -- please just submit when you got LGTM

This revision was automatically updated to reflect the committed changes.