This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Explicitly set VS 2017 compatibility
ClosedPublic

Authored by smeenai on Dec 13 2017, 12:42 AM.

Details

Summary

When cross-compiling using clang-cl 5.0 (which is currently the latest
stable release of the compiler), the default MS compatibility level is
set to VS 2013, which is too low to build LLVM. Explicitly set the
compatibility level to VS 2017 to support cross-compiling LLVM for
Windows using clang-cl 5.0. This will be a no-op when using clang-cl 6.0
and above, where the default MS compatibility level is already VS 2017.

Event Timeline

smeenai created this revision.Dec 13 2017, 12:42 AM
zturner accepted this revision.Dec 13 2017, 8:59 AM
This revision is now accepted and ready to land.Dec 13 2017, 8:59 AM

I'm confused by this.

The default is used only when the MSVC installation cannot be found. Successful compilation with clang-cl depends on finding the MSVC toolset. So either you have a toolset installed that's recent enough to compile or you don't, in which case overriding the compatibility level won't make much difference. Right? Is this because the detection method changed and that the old method won't find VC 2017?

I think it's because older versions of clang had their default hardcoded to VS 2013, regardless of what environment was actually found. I think newer versions still have this issue, but it's not a problem in practice because the hardcoded version is the newest version. But it will be in the future. Long term we should default to whatever is detected in the headers and libraries that are found.

The default is used only when the MSVC installation cannot be found. Successful compilation with clang-cl depends on finding the MSVC toolset. So either you have a toolset installed that's recent enough to compile or you don't, in which case overriding the compatibility level won't make much difference. Right? Is this because the detection method changed and that the old method won't find VC 2017?

This is for cross-compilation, in which case clang-cl explicitly won't be able to find an MSVC installation/toolset. We're supplying the MSVC toolset and Windows SDK headers and libraries manually.

This revision was automatically updated to reflect the committed changes.