diff options
author | Adrian McCarthy <amccarth@google.com> | 2016-05-13 23:20:11 +0000 |
---|---|---|
committer | Adrian McCarthy <amccarth@google.com> | 2016-05-13 23:20:11 +0000 |
commit | e4b26fc7a7573aff71ca3d3b9c21ae3556e7d659 (patch) | |
tree | 54b6cba9453513daa7ba362ed5c72489e45410f7 /clang/lib/Driver/Tools.cpp | |
parent | 3e42b22e599dbf2f36751af1c736d6900db09389 (diff) | |
download | llvm-e4b26fc7a7573aff71ca3d3b9c21ae3556e7d659.zip llvm-e4b26fc7a7573aff71ca3d3b9c21ae3556e7d659.tar.gz llvm-e4b26fc7a7573aff71ca3d3b9c21ae3556e7d659.tar.bz2 |
Get default -fms-compatibility-version from cl.exe's version
-fms-compatibility-version was defaulting to 18 (VS 2013), which is a pain if your environment is pointing to version 19 (VS 2015) libraries.
If cl.exe can be found, this patch uses its version number as the default instead. It re-uses the existing code to find the Visual Studio binaries folder and WinAPI methods to check its version. You can still explicitly specify a compatibility version on the command line. If you don't have cl.exe, this should be a no-op and you'll get the old default of 18.
This affected the tests, which assumed that if you didn't specific a version, that it would default to 18, but this won't be true for all machines. So a couple test cases had to be eliminated and a couple others had to be tweaked to allow for various outputs.
Addresses: https://llvm.org/bugs/show_bug.cgi?id=27215
Differential Revision: http://reviews.llvm.org/D20136
llvm-svn: 269515
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index cbc2e65..c408e6c7 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -3293,7 +3293,7 @@ static void appendUserToPath(SmallVectorImpl<char> &Result) { Result.append(UID.begin(), UID.end()); } -VersionTuple visualstudio::getMSVCVersion(const Driver *D, +VersionTuple visualstudio::getMSVCVersion(const Driver *D, const ToolChain &TC, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, bool IsWindowsMSVC) { @@ -3335,8 +3335,14 @@ VersionTuple visualstudio::getMSVCVersion(const Driver *D, if (Major || Minor || Micro) return VersionTuple(Major, Minor, Micro); - // FIXME: Consider bumping this to 19 (MSVC2015) soon. - return VersionTuple(18); + if (IsWindowsMSVC) { + VersionTuple MSVT = TC.getMSVCVersionFromExe(); + if (!MSVT.empty()) + return MSVT; + + // FIXME: Consider bumping this to 19 (MSVC2015) soon. + return VersionTuple(18); + } } return VersionTuple(); } @@ -5226,7 +5232,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // -fms-compatibility-version=18.00 is default. VersionTuple MSVT = visualstudio::getMSVCVersion( - &D, getToolChain().getTriple(), Args, IsWindowsMSVC); + &D, getToolChain(), getToolChain().getTriple(), Args, IsWindowsMSVC); if (!MSVT.empty()) CmdArgs.push_back( Args.MakeArgString("-fms-compatibility-version=" + MSVT.getAsString())); |