This is an archive of the discontinued LLVM Phabricator instance.

clang-cl: Enable /Zc:twoPhase by default if targeting MSVC 2017 update 3 or newer
ClosedPublic

Authored by thakis on Aug 18 2019, 11:08 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

thakis created this revision.Aug 18 2019, 11:08 AM
rnk accepted this revision.Aug 19 2019, 2:24 PM

lgtm! I can't believe we didn't notice this for a year. Not long ago a Firefox developer filed a bug for a crash with -fdelayed-template-parsing, and if this works for them, we won't have to debug it. :)

This revision is now accepted and ready to land.Aug 19 2019, 2:24 PM
hans accepted this revision.Aug 20 2019, 2:17 AM

Nice! Please include a mention in docs/ReleaseNotes.rst :-)

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2019, 9:30 AM