Bug 1296737 - make clang-cl compile in c++14 mode; r=glandium

MSVC headers have C++14 features without appropriate guards, so clang-cl
needs to be instructed to default to a C++14-compatible mode by default.
This commit is contained in:
Nathan Froyd 2016-10-04 20:34:04 +00:00
Родитель 4c172cc0bd
Коммит d05eb39d9d
2 изменённых файлов: 24 добавлений и 11 удалений

Просмотреть файл

@ -345,16 +345,20 @@ def check_compiler(compiler, language, target):
# Note: MSVC, while supporting C++11, still reports 199711L for __cplusplus.
# Note: this is a strict version check because we used to always add
# -std=gnu++11.
if info.language == 'C++' and info.language_version != 201103:
if info.type in ('clang-cl', 'clang', 'gcc'):
if info.language == 'C++':
if info.type in ('clang', 'gcc') and info.language_version != 201103:
append_flag('-std=gnu++11')
# MSVC 2015 headers include C++14 features, but don't guard them
# with appropriate checks.
if info.type == 'clang-cl' and info.language_version != 201402:
append_flag('-std=c++14')
# We force clang-cl to emulate Visual C++ 2013 Update 3 with fallback to
# We force clang-cl to emulate Visual C++ 2015 Update 2 with fallback to
# cl.exe.
if info.type == 'clang-cl' and info.version != '18.00.30723':
if info.type == 'clang-cl' and info.version != '19.00.23918':
# Those flags are direct clang-cl flags that don't need -Xclang, add
# them directly.
flags.append('-fms-compatibility-version=18.00.30723')
flags.append('-fms-compatibility-version=19.00.23918')
flags.append('-fallback')
# Check compiler target

Просмотреть файл

@ -37,6 +37,10 @@ DEFAULT_CXX_11 = {
'__cplusplus': '201103L',
}
DEFAULT_CXX_14 = {
'__cplusplus': '201402L',
}
SUPPORTS_GNU99 = {
'-std=gnu99': DEFAULT_C99,
}
@ -45,6 +49,10 @@ SUPPORTS_GNUXX11 = {
'-std=gnu++11': DEFAULT_CXX_11,
}
SUPPORTS_CXX14 = {
'-std=c++14': DEFAULT_CXX_14,
}
@memoize
def GCC_BASE(version):
@ -220,12 +228,12 @@ VS_PLATFORM_X86_64 = {
# Note: In reality, the -std=gnu* options are only supported when preceded by
# -Xclang.
CLANG_CL_3_9 = (CLANG_BASE('3.9.0') + VS('18.00.00000') + DEFAULT_C11 +
SUPPORTS_GNU99 + SUPPORTS_GNUXX11) + {
SUPPORTS_GNU99 + SUPPORTS_GNUXX11 + SUPPORTS_CXX14) + {
'*.cpp': {
'__STDC_VERSION__': False,
'__cplusplus': '201103L',
},
'-fms-compatibility-version=18.00.30723': VS('18.00.30723')[None],
'-fms-compatibility-version=19.00.23918': VS('19.00.23918')[None],
}
CLANG_CL_PLATFORM_X86 = FakeCompiler(VS_PLATFORM_X86, GCC_PLATFORM_X86[None])
@ -772,15 +780,16 @@ class WindowsToolchainTest(BaseToolchainTest):
)
CLANG_CL_3_9_RESULT = CompilerResult(
flags=['-Xclang', '-std=gnu99',
'-fms-compatibility-version=18.00.30723', '-fallback'],
version='18.00.30723',
'-fms-compatibility-version=19.00.23918', '-fallback'],
version='19.00.23918',
type='clang-cl',
compiler='/usr/bin/clang-cl',
language='C',
)
CLANGXX_CL_3_9_RESULT = CompilerResult(
flags=['-fms-compatibility-version=18.00.30723', '-fallback'],
version='18.00.30723',
flags=['-Xclang', '-std=c++14',
'-fms-compatibility-version=19.00.23918', '-fallback'],
version='19.00.23918',
type='clang-cl',
compiler='/usr/bin/clang-cl',
language='C++',