diff options
Diffstat (limited to 'build/moz.configure/toolchain.configure')
-rw-r--r-- | build/moz.configure/toolchain.configure | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index 5f03cb2b74..cc0540ea1c 100644 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -171,6 +171,9 @@ include('compilers-util.configure') def try_preprocess(compiler, language, source): return try_invoke_compiler(compiler, language, source, ['-E']) +def msvc_std14(): return '-std:c++14' +def msvc_std17(): return '-std:c++17' + @imports(_from='mozbuild.configure.constants', _import='CompilerType') @imports(_from='mozbuild.configure.constants', _import='CPU_preprocessor_checks') @@ -279,6 +282,13 @@ def get_compiler_info(compiler, language): 'Unknown compiler or compiler not supported.') cplusplus = int(data.get('cplusplus', '0L').rstrip('L')) + if language == 'C++' and type=='msvc' and cplusplus == 199711: + # Note: MSVC still reports 199711L for __cplusplus. Fix the report by + # assuming it does what we asked it to do. + if msvc_std14() in compiler: + cplusplus = 201402 + elif msvc_std17() in compiler: + cplusplus = 201703 stdc_version = int(data.get('STDC_VERSION', '0L').rstrip('L')) version = data.get('VERSION') @@ -330,16 +340,17 @@ def check_compiler(compiler, language, target): 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. + # -std=gnu++14. + cxx14_version = 201402 if info.language == 'C++': - if info.type in ('clang', 'gcc') and info.language_version != 201103: - append_flag('-std=gnu++11') + if info.type in ('clang', 'gcc') and info.language_version != cxx14_version: + append_flag('-std=gnu++14') # 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: + if info.type == 'clang-cl' and info.language_version != cxx14_version: append_flag('-std=c++14') + # MSVC from 2015 on defaults to C++14. # We force clang-cl to emulate Visual C++ 2015 Update 3 with fallback to # cl.exe. @@ -644,11 +655,17 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None, host_or_target) # Check that the additional flags we got are enough to not require any - # more flags. - if info.flags: - flags += info.flags - info = check_compiler(wrapper + [compiler] + flags, language, - host_or_target) + # more flags. If we get an exception, just ignore it; it's liable to be + # invalid command-line flags, which means the compiler we're checking + # doesn't support those command-line flags and will fail one or more of + # the checks below. + try: + if info.flags: + flags += info.flags + info = check_compiler(wrapper + [compiler] + flags, language, + host_or_target) + except FatalCheckError: + pass if not info.target_cpu or info.target_cpu != host_or_target.cpu: raise FatalCheckError( @@ -674,10 +691,6 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None, info.target_endianness or 'unknown', host_or_target_str, host_or_target.endianness)) - if info.flags: - raise FatalCheckError( - 'Unknown compiler or compiler not supported.') - # Compiler version checks # =================================================== # Check the compiler version here instead of in `compiler_version` so @@ -689,7 +702,7 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None, % info.version) # If you want to bump the version check here search for - # __cpp_static_assert above, and see the associated comment. + # cxx_alignof above, and see the associated comment. if info.type == 'clang' and not info.version: raise FatalCheckError( 'Only clang/llvm 3.6 or newer is supported.') @@ -704,6 +717,10 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None, 'See https://developer.mozilla.org/en/' 'Windows_Build_Prerequisites' % info.version) + if info.flags: + raise FatalCheckError( + 'Unknown compiler or compiler not supported.') + return namespace( wrapper=wrapper, compiler=compiler, |