Bug 1550868 - enforce a minimum version of clang-cl; r=glandium
authorNathan Froyd <froydnj@mozilla.com>
Tue, 14 May 2019 14:22:55 +0000
changeset 532608 0a49234facf2496f920f6ba1ef9e506758466db3
parent 532607 5f0d8832067f71dc9e0bcc4c0b03dc5458d57ea1
child 532609 7d2d7b47ec349aa71ab0a49a18cfced4b92b7189
push id11270
push userrgurzau@mozilla.com
push dateWed, 15 May 2019 15:07:19 +0000
treeherdermozilla-beta@571bc76da583 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1550868
milestone68.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 1550868 - enforce a minimum version of clang-cl; r=glandium We've not been checking the clang-cl version in use. This lack of checking is bad, for a couple of reasons: * Released versions of clang-cl differ drastically in their robustness; * Only the most recent version of clang-cl supports aarch64. We should check for a minimum version of clang-cl, just like our other supported compilers. As a bonus, we can then start depending on features that we know appear in the particular minimum clang-cl version. (The current patch is motivated by `/clang:` command-line support, but one could pick other things.) Differential Revision: https://phabricator.services.mozilla.com/D30723
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
@@ -1025,16 +1025,22 @@ def compiler(language, host_or_target, c
             if host_or_target.os == 'Android':
                 raise FatalCheckError('GCC is not supported on Android.\n'
                                       'Please use clang from the Android NDK instead.')
             if info.version < '6.1.0':
                 raise FatalCheckError(
                     'Only GCC 6.1 or newer is supported (found version %s).'
                     % info.version)
 
+        if info.type == 'clang-cl':
+            if info.version < '8.0.0':
+                raise FatalCheckError(
+                    'Only clang-cl 8.0 or newer is supported (found version %s)'
+                    % info.version)
+
         # If you want to bump the version check here search for
         # builtin_bitreverse8 above, and see the associated comment.
         if info.type == 'clang' and not info.version:
             raise FatalCheckError(
                 'Only clang/llvm 3.9 or newer is supported.')
 
         if info.flags:
             raise FatalCheckError(
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -256,16 +256,23 @@ VS_PLATFORM_X86_64 = {
 # -Xclang.
 CLANG_CL_3_9 = (CLANG_BASE('3.9.0') + VS('18.00.00000') + DEFAULT_C11 +
                 SUPPORTS_GNU99 + SUPPORTS_GNUXX11 + SUPPORTS_CXX14) + {
     '*.cpp': {
         '__STDC_VERSION__': False,
         '__cplusplus': '201103L',
     },
 }
+CLANG_CL_8_0 = (CLANG_BASE('8.0.0') + VS('18.00.00000') + DEFAULT_C11 +
+                SUPPORTS_GNU99 + SUPPORTS_GNUXX11 + SUPPORTS_CXX14) + {
+    '*.cpp': {
+        '__STDC_VERSION__': False,
+        '__cplusplus': '201103L',
+    },
+}
 
 CLANG_CL_PLATFORM_X86 = FakeCompiler(
     VS_PLATFORM_X86, GCC_PLATFORM_X86[None], GCC_PLATFORM_LITTLE_ENDIAN)
 CLANG_CL_PLATFORM_X86_64 = FakeCompiler(
     VS_PLATFORM_X86_64, GCC_PLATFORM_X86_64[None], GCC_PLATFORM_LITTLE_ENDIAN)
 
 LIBRARY_NAME_INFOS = {
     'linux-gnu': {
@@ -869,42 +876,45 @@ class OSXToolchainTest(BaseToolchainTest
 
 class WindowsToolchainTest(BaseToolchainTest):
     HOST = 'i686-pc-mingw32'
 
     # For the purpose of this test, it doesn't matter that the paths are not
     # real Windows paths.
     PATHS = {
         '/usr/bin/cl': VS_2017u8 + VS_PLATFORM_X86,
-        '/usr/bin/clang-cl': CLANG_CL_3_9 + CLANG_CL_PLATFORM_X86,
+        '/usr/bin/clang-cl-3.9': CLANG_CL_3_9 + CLANG_CL_PLATFORM_X86,
+        '/usr/bin/clang-cl': CLANG_CL_8_0 + CLANG_CL_PLATFORM_X86,
         '/usr/bin/gcc': DEFAULT_GCC + GCC_PLATFORM_X86_WIN,
         '/usr/bin/g++': DEFAULT_GXX + GCC_PLATFORM_X86_WIN,
         '/usr/bin/gcc-4.9': GCC_4_9 + GCC_PLATFORM_X86_WIN,
         '/usr/bin/g++-4.9': GXX_4_9 + GCC_PLATFORM_X86_WIN,
         '/usr/bin/gcc-5': GCC_5 + GCC_PLATFORM_X86_WIN,
         '/usr/bin/g++-5': GXX_5 + GCC_PLATFORM_X86_WIN,
         '/usr/bin/gcc-6': GCC_6 + GCC_PLATFORM_X86_WIN,
         '/usr/bin/g++-6': GXX_6 + GCC_PLATFORM_X86_WIN,
         '/usr/bin/clang': DEFAULT_CLANG + CLANG_PLATFORM_X86_WIN,
         '/usr/bin/clang++': DEFAULT_CLANGXX + CLANG_PLATFORM_X86_WIN,
         '/usr/bin/clang-3.6': CLANG_3_6 + CLANG_PLATFORM_X86_WIN,
         '/usr/bin/clang++-3.6': CLANGXX_3_6 + CLANG_PLATFORM_X86_WIN,
         '/usr/bin/clang-3.3': CLANG_3_3 + CLANG_PLATFORM_X86_WIN,
         '/usr/bin/clang++-3.3': CLANGXX_3_3 + CLANG_PLATFORM_X86_WIN,
     }
 
-    CLANG_CL_3_9_RESULT = CompilerResult(
-        version='3.9.0',
+    CLANG_CL_3_9_RESULT = 'Only clang-cl 8.0 or newer is supported (found version 3.9.0)'
+    CLANG_CL_8_0_RESULT = CompilerResult(
+        version='8.0.0',
         flags=['-Xclang', '-std=gnu99'],
         type='clang-cl',
         compiler='/usr/bin/clang-cl',
         language='C',
     )
-    CLANGXX_CL_3_9_RESULT = CompilerResult(
-        version='3.9.0',
+    CLANGXX_CL_3_9_RESULT = 'Only clang-cl 8.0 or newer is supported (found version 3.9.0)'
+    CLANGXX_CL_8_0_RESULT = CompilerResult(
+        version='8.0.0',
         flags=['-Xclang', '-std=c++14'],
         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
     DEFAULT_CLANG_RESULT = LinuxToolchainTest.DEFAULT_CLANG_RESULT
@@ -920,20 +930,27 @@ class WindowsToolchainTest(BaseToolchain
 
     def test_unsupported_msvc(self):
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': 'Unknown compiler or compiler not supported.'
         }, environ={
             'CC': '/usr/bin/cl',
         })
 
+    def test_unsupported_clang_cl(self):
+        self.do_toolchain_test(self.PATHS, {
+            'c_compiler': self.CLANG_CL_3_9_RESULT,
+        }, environ={
+            'CC': '/usr/bin/clang-cl-3.9',
+        })
+
     def test_clang_cl(self):
         self.do_toolchain_test(self.PATHS, {
-            'c_compiler': self.CLANG_CL_3_9_RESULT,
-            'cxx_compiler': self.CLANGXX_CL_3_9_RESULT,
+            'c_compiler': self.CLANG_CL_8_0_RESULT,
+            'cxx_compiler': self.CLANGXX_CL_8_0_RESULT,
         })
 
     def test_gcc(self):
         # We'll pick GCC if msvc and clang-cl can't be found.
         paths = {
             k: v for k, v in self.PATHS.iteritems()
             if os.path.basename(k) not in ('cl', 'clang-cl')
         }
@@ -974,17 +991,18 @@ class WindowsToolchainTest(BaseToolchain
 
 class Windows64ToolchainTest(WindowsToolchainTest):
     HOST = 'x86_64-pc-mingw32'
 
     # For the purpose of this test, it doesn't matter that the paths are not
     # real Windows paths.
     PATHS = {
         '/usr/bin/cl': VS_2017u8 + VS_PLATFORM_X86_64,
-        '/usr/bin/clang-cl': CLANG_CL_3_9 + CLANG_CL_PLATFORM_X86_64,
+        '/usr/bin/clang-cl': CLANG_CL_8_0 + CLANG_CL_PLATFORM_X86_64,
+        '/usr/bin/clang-cl-3.9': CLANG_CL_3_9 + CLANG_CL_PLATFORM_X86_64,
         '/usr/bin/gcc': DEFAULT_GCC + GCC_PLATFORM_X86_64_WIN,
         '/usr/bin/g++': DEFAULT_GXX + GCC_PLATFORM_X86_64_WIN,
         '/usr/bin/gcc-4.9': GCC_4_9 + GCC_PLATFORM_X86_64_WIN,
         '/usr/bin/g++-4.9': GXX_4_9 + GCC_PLATFORM_X86_64_WIN,
         '/usr/bin/gcc-5': GCC_5 + GCC_PLATFORM_X86_64_WIN,
         '/usr/bin/g++-5': GXX_5 + GCC_PLATFORM_X86_64_WIN,
         '/usr/bin/gcc-6': GCC_6 + GCC_PLATFORM_X86_64_WIN,
         '/usr/bin/g++-6': GXX_6 + GCC_PLATFORM_X86_64_WIN,
@@ -1336,22 +1354,22 @@ class OSXCrossToolchainTest(BaseToolchai
 
 class WindowsCrossToolchainTest(BaseToolchainTest):
     TARGET = 'x86_64-pc-mingw32'
     DEFAULT_CLANG_RESULT = LinuxToolchainTest.DEFAULT_CLANG_RESULT
     DEFAULT_CLANGXX_RESULT = LinuxToolchainTest.DEFAULT_CLANGXX_RESULT
 
     def test_clang_cl_cross(self):
         paths = {
-            '/usr/bin/clang-cl': CLANG_CL_3_9 + CLANG_CL_PLATFORM_X86_64,
+            '/usr/bin/clang-cl': CLANG_CL_8_0 + CLANG_CL_PLATFORM_X86_64,
         }
         paths.update(LinuxToolchainTest.PATHS)
         self.do_toolchain_test(paths, {
-            'c_compiler': WindowsToolchainTest.CLANG_CL_3_9_RESULT,
-            'cxx_compiler': WindowsToolchainTest.CLANGXX_CL_3_9_RESULT,
+            'c_compiler': WindowsToolchainTest.CLANG_CL_8_0_RESULT,
+            'cxx_compiler': WindowsToolchainTest.CLANGXX_CL_8_0_RESULT,
             'host_c_compiler': self.DEFAULT_CLANG_RESULT,
             'host_cxx_compiler': self.DEFAULT_CLANGXX_RESULT,
         })
 
 
 class OpenBSDToolchainTest(BaseToolchainTest):
     HOST = 'x86_64-unknown-openbsd6.1'
     TARGET = 'x86_64-unknown-openbsd6.1'