summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains/Clang.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-08-20 16:28:11 +0000
committerNico Weber <nicolasweber@gmx.de>2019-08-20 16:28:11 +0000
commitfe91b9d6da99d346abbd1063b1456a30664b215b (patch)
tree5b7e3ebb9f516888812b818bf95fe583ccfaca52 /clang/lib/Driver/ToolChains/Clang.cpp
parent184bc069c60c2e8eb11f18af47b85e584d64f65c (diff)
downloadbcm5719-llvm-fe91b9d6da99d346abbd1063b1456a30664b215b.tar.gz
bcm5719-llvm-fe91b9d6da99d346abbd1063b1456a30664b215b.zip
win: Enable /Zc:twoPhase by default if targeting MSVC 2017 update 3 or newer
MSVC 2017 update 3 (_MSC_VER 1911) enables /Zc:twoPhase by default, and so should clang-cl: https://docs.microsoft.com/en-us/cpp/build/reference/zc-twophase clang-cl takes the MSVC version it emulates from the -fmsc-version flag, or if that's not passed it tries to check what the installed version of MSVC is and uses that, and failing that it uses a default version that's currently 1911. So this changes the default if no -fmsc-version flag is passed and no installed MSVC is detected. (It also changes the default if -fmsc-version is passed or MSVC is detected, and either indicates _MSC_VER >= 1911.) As mentioned in the MSDN article, the Windows SDK header files in version 10.0.15063.0 (Creators Update or Redstone 2) and earlier versions do not work correctly with /Zc:twoPhase. If you need to use these old SDKs with a new clang-cl, explicitly pass /Zc:twoPhase- to get the old behavior. Fixes PR43032. Differential Revision: https://reviews.llvm.org/D66394 llvm-svn: 369402
Diffstat (limited to 'clang/lib/Driver/ToolChains/Clang.cpp')
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 690d4fa3fa4..c0f914bf989 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4883,12 +4883,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
!IsWindowsMSVC || IsMSVC2015Compatible))
CmdArgs.push_back("-fno-threadsafe-statics");
- // -fno-delayed-template-parsing is default, except when targeting MSVC.
- // Many old Windows SDK versions require this to parse.
- // FIXME: MSVC introduced /Zc:twoPhase- to disable this behavior in their
- // compiler. We should be able to disable this by default at some point.
+ // -fno-delayed-template-parsing is default, except when targeting MSVC
+ // earlier than MSVC 2017 15.3 (_MSC_VER 1911). Windows SDK versions
+ // 10.0.15063.0 (Creators Update or Redstone 2) and earlier require this to
+ // parse.
+ bool IsMSVCBefore2017Update3 = !MSVT.empty() && MSVT < VersionTuple(19, 11);
if (Args.hasFlag(options::OPT_fdelayed_template_parsing,
- options::OPT_fno_delayed_template_parsing, IsWindowsMSVC))
+ options::OPT_fno_delayed_template_parsing,
+ IsMSVCBefore2017Update3))
CmdArgs.push_back("-fdelayed-template-parsing");
// -fgnu-keywords default varies depending on language; only pass if
OpenPOWER on IntegriCloud