Bug 1296737 - make clang-cl compile in c++14 mode; r?glandium
MozReview-Commit-ID: 7u60WXegy9T
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -338,26 +338,30 @@ def check_compiler(compiler, language, t
# example)
if info.language == 'C' and info.language_version != 199901:
if info.type in ('clang-cl', 'clang', 'gcc'):
append_flag('-std=gnu99')
# 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=gnu++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
# --------------------------------------------------------------------
if not info.cpu or info.cpu != target.cpu:
if info.type == 'clang':
append_flag('--target=%s' % target.toolchain)
elif info.type == 'gcc':
@@ -667,17 +671,17 @@ def compiler(language, host_or_target, c
'%s %s compiler target endianness (%s) does not match --%s '
'endianness (%s)'
% (host_or_target_str.capitalize(), language,
info.target_endianness or 'unknown', host_or_target_str,
host_or_target.endianness))
if info.flags:
raise FatalCheckError(
- 'Unknown compiler or compiler not supported.')
+ 'Unknown compiler or compiler not supported. ' + str(info.flags))
# Compiler version checks
# ===================================================
# Check the compiler version here instead of in `compiler_version` so
# that the `checking` message doesn't pretend the compiler can be used
# to then bail out one line later.
if info.type == 'gcc' and info.version < '4.8.0':
raise FatalCheckError(
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -213,23 +213,23 @@ VS_PLATFORM_X86 = {
VS_PLATFORM_X86_64 = {
'_M_X64': 100,
'_WIN32': 1,
'_WIN64': 1,
}
# 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 +
+CLANG_CL_3_9 = (CLANG_BASE('3.9.0') + VS('19.00.00000') + DEFAULT_C11 +
SUPPORTS_GNU99 + SUPPORTS_GNUXX11) + {
'*.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])
CLANG_CL_PLATFORM_X86_64 = FakeCompiler(VS_PLATFORM_X86_64, GCC_PLATFORM_X86_64[None])
class BaseToolchainTest(BaseConfigureTest):
def setUp(self):
@@ -766,25 +766,25 @@ class WindowsToolchainTest(BaseToolchain
flags=[],
version='19.00.23918',
type='msvc',
compiler='/usr/bin/cl',
language='C++',
)
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=['-fms-compatibility-version=19.00.23918', '-fallback'],
+ version='19.00.23918',
type='clang-cl',
compiler='/usr/bin/clang-cl',
language='C++',
)
CLANG_3_3_RESULT = LinuxToolchainTest.CLANG_3_3_RESULT
CLANGXX_3_3_RESULT = LinuxToolchainTest.CLANGXX_3_3_RESULT
CLANG_3_6_RESULT = LinuxToolchainTest.CLANG_3_6_RESULT
CLANGXX_3_6_RESULT = LinuxToolchainTest.CLANGXX_3_6_RESULT