Bug 1392643 Turn on c++14 for MinGW globally r=bagder,froydnj
authorTom Ritter <tom@mozilla.com>
Fri, 22 Sep 2017 12:26:42 -0500
changeset 433524 b81d24ced5131b5d37c3839efad8dca84e6d0e9f
parent 433523 218757467ee8b8feec1fcf3b028d5397bb748bac
child 433525 0caa5a0f9ccb59e02b3da21b4717644ffdaf6c96
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbagder, froydnj
bugs1392643
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1392643 Turn on c++14 for MinGW globally r=bagder,froydnj Technically this turns on gnu++14. I encountered a few errors when using c++14: 1) _USE_MATH_DEFINES needed to be defined for MinGW 2) MinGW did not define _finite under c++14 3) MinGW's float.h did not define Microsoft specific float functions under c++14 All of these were because c++14 defines _STRICT_ANSI_ which MinGW obeys and avoids defining certain functions. The first two could be patched around, but the third was a blocker, so we switched to gnu++14 MozReview-Commit-ID: 6Y7gEQgApYp
build/moz.configure/toolchain.configure
python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -369,23 +369,34 @@ 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.
+    draft_cxx14_version = 201300
+    cxx14_version = 201402
     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')
+        if target.kernel != 'WINNT':
+            if info.type in ('clang', 'gcc') and info.language_version != 201103:
+                append_flag('-std=gnu++11')
+        else:
+            if info.type == 'clang' 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 != cxx14_version:
+                append_flag('-std=c++14')
+            # GCC 4.9 indicates that it implements draft C++14 features
+            # instead of the full language.
+            elif info.type == 'gcc' and not \
+                (info.language_version == draft_cxx14_version or info.language_version == cxx14_version):
+                append_flag('-std=gnu++14')
 
     # We force clang-cl to emulate Visual C++ 2015 Update 3.
     if info.type == 'clang-cl' and info.version != '19.00.24213':
         # This flag is a direct clang-cl flag that doesn't need -Xclang,
         # add it directly.
         flags.append('-fms-compatibility-version=19.00.24213')
 
     # Check compiler target
old mode 100644
new mode 100755
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -32,28 +32,36 @@ DEFAULT_C11 = {
 DEFAULT_CXX_97 = {
     '__cplusplus': '199711L',
 }
 
 DEFAULT_CXX_11 = {
     '__cplusplus': '201103L',
 }
 
+DRAFT_CXX_14 = {
+    '__cplusplus': '201300L',
+}
+
 DEFAULT_CXX_14 = {
     '__cplusplus': '201402L',
 }
 
 SUPPORTS_GNU99 = {
     '-std=gnu99': DEFAULT_C99,
 }
 
 SUPPORTS_GNUXX11 = {
     '-std=gnu++11': DEFAULT_CXX_11,
 }
 
+SUPPORTS_GNUXX14 = {
+    '-std=gnu++14': DEFAULT_CXX_14,
+}
+
 SUPPORTS_CXX14 = {
     '-std=c++14': DEFAULT_CXX_14,
 }
 
 
 @memoize
 def GCC_BASE(version):
     version = Version(version)
@@ -71,23 +79,26 @@ def GCC_BASE(version):
 def GCC(version):
     return GCC_BASE(version) + SUPPORTS_GNU99
 
 
 @memoize
 def GXX(version):
     return GCC_BASE(version) + DEFAULT_CXX_97 + SUPPORTS_GNUXX11
 
+SUPPORTS_DRAFT_CXX14_VERSION = {
+    '-std=gnu++14': DRAFT_CXX_14,
+}
 
 GCC_4_7 = GCC('4.7.3')
 GXX_4_7 = GXX('4.7.3')
 GCC_4_9 = GCC('4.9.3')
-GXX_4_9 = GXX('4.9.3')
+GXX_4_9 = GXX('4.9.3') + SUPPORTS_DRAFT_CXX14_VERSION
 GCC_5 = GCC('5.2.1') + DEFAULT_C11
-GXX_5 = GXX('5.2.1')
+GXX_5 = GXX('5.2.1') + SUPPORTS_GNUXX14
 
 GCC_PLATFORM_LITTLE_ENDIAN = {
     '__BYTE_ORDER__': 1234,
 }
 
 GCC_PLATFORM_BIG_ENDIAN = {
     '__BYTE_ORDER__': 4321,
 }
@@ -158,26 +169,29 @@ def CLANG_BASE(version):
 @memoize
 def CLANG(version):
     return GCC_BASE('4.2.1') + CLANG_BASE(version) + SUPPORTS_GNU99
 
 
 @memoize
 def CLANGXX(version):
     return (GCC_BASE('4.2.1') + CLANG_BASE(version) + DEFAULT_CXX_97 +
-            SUPPORTS_GNUXX11)
+            SUPPORTS_GNUXX11 + SUPPORTS_GNUXX14)
 
 
 CLANG_3_3 = CLANG('3.3.0') + DEFAULT_C99
 CLANGXX_3_3 = CLANGXX('3.3.0')
 CLANG_3_6 = CLANG('3.6.2') + DEFAULT_C11
 CLANGXX_3_6 = CLANGXX('3.6.2') + {
     '-std=gnu++11': {
         '__has_feature(cxx_alignof)': '1',
     },
+    '-std=gnu++14': {
+        '__has_feature(cxx_alignof)': '1',
+    },
 }
 
 
 def CLANG_PLATFORM(gcc_platform):
     base = {
         '--target=x86_64-linux-gnu': GCC_PLATFORM_X86_64_LINUX[None],
         '--target=x86_64-darwin11.2.0': GCC_PLATFORM_X86_64_OSX[None],
         '--target=i686-linux-gnu': GCC_PLATFORM_X86_LINUX[None],
@@ -896,19 +910,31 @@ class WindowsToolchainTest(BaseToolchain
         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
     GCC_4_7_RESULT = LinuxToolchainTest.GCC_4_7_RESULT
     GCC_4_9_RESULT = LinuxToolchainTest.GCC_4_9_RESULT
-    GXX_4_9_RESULT = LinuxToolchainTest.GXX_4_9_RESULT
+    GXX_4_9_RESULT = CompilerResult(
+        flags=['-std=gnu++14'],
+        version='4.9.3',
+        type='gcc',
+        compiler='/usr/bin/g++',
+        language='C++',
+    )
     GCC_5_RESULT = LinuxToolchainTest.GCC_5_RESULT
-    GXX_5_RESULT = LinuxToolchainTest.GXX_5_RESULT
+    GXX_5_RESULT = CompilerResult(
+        flags=['-std=gnu++14'],
+        version='5.2.1',
+        type='gcc',
+        compiler='/usr/bin/g++-5',
+        language='C++',
+    )
 
     # VS2015u3 or greater is required.
     def test_msvc(self):
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.VS_2015u3_RESULT,
             'cxx_compiler': self.VSXX_2015u3_RESULT,
         })