Bug 1286204 - Require at least clang 3.6. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 08 Jul 2016 16:38:55 +0900
changeset 305456 649120d26209ce3787aff18222f387ce73127694
parent 305455 484a3b7cb17b08931956af88707e1425727d3b5e
child 305457 8e994cb3fb30be363fe83ecfb09b86165035c919
push id30463
push usercbook@mozilla.com
push dateTue, 19 Jul 2016 14:02:45 +0000
treeherdermozilla-central@37cc0da01187 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1286204
milestone50.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 1286204 - Require at least clang 3.6. r=froydnj
build/moz.configure/toolchain.configure
python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -227,17 +227,17 @@ def get_compiler_info(compiler, language
         %COMPILER clang-cl
         %VERSION _MSC_FULL_VER
         #else
         %COMPILER msvc
         %VERSION _MSC_FULL_VER
         #endif
         #elif defined(__clang__)
         %COMPILER clang
-        #  if !__cplusplus || __cpp_static_assert
+        #  if !__cplusplus || __has_feature(cxx_alignof)
         %VERSION __clang_major__.__clang_minor__.__clang_patchlevel__
         #  endif
         #elif defined(__GNUC__)
         %COMPILER gcc
         %VERSION __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__
         #endif
 
         #if __cplusplus
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -97,17 +97,17 @@ def CLANGXX(version):
             SUPPORTS_GNUXX11)
 
 
 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': {
-        '__cpp_static_assert': '200410',
+        '__has_feature(cxx_alignof)': '1',
     },
 }
 
 
 @memoize
 def VS(version):
     version = Version(version)
     return FakeCompiler({
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
@@ -21,37 +21,44 @@ from mozunit import (
 from mozbuild.preprocessor import Preprocessor
 from mozbuild.util import ReadOnlyNamespace
 from mozpack import path as mozpath
 
 
 class CompilerPreprocessor(Preprocessor):
     VARSUBST = re.compile('(?P<VAR>\w+)', re.U)
     NON_WHITESPACE = re.compile('\S')
+    HAS_FEATURE = re.compile('(__has_feature)\(([^\)]*)\)')
 
     def __init__(self, *args, **kwargs):
         Preprocessor.__init__(self, *args, **kwargs)
         self.do_filter('c_substitution')
         self.setMarker('#\s*')
 
-    def do_if(self, *args, **kwargs):
+    def do_if(self, expression, **kwargs):
         # The C preprocessor handles numbers following C rules, which is a
         # different handling than what our Preprocessor does out of the box.
         # Hack around it enough that the configure tests work properly.
         context = self.context
         def normalize_numbers(value):
             if isinstance(value, types.StringTypes):
                 if value[-1:] == 'L' and value[:-1].isdigit():
                     value = int(value[:-1])
             return value
+        # Our Preprocessor doesn't handle macros with parameters, so we hack
+        # around that for __has_feature()-like things.
+        def normalize_has_feature(expr):
+            return self.HAS_FEATURE.sub(r'\1\2', expr)
         self.context = self.Context(
-            (k, normalize_numbers(v)) for k, v in context.iteritems()
+            (normalize_has_feature(k), normalize_numbers(v))
+            for k, v in context.iteritems()
         )
         try:
-            return Preprocessor.do_if(self, *args, **kwargs)
+            return Preprocessor.do_if(self, normalize_has_feature(expression),
+                                      **kwargs)
         finally:
             self.context = context
 
     class Context(dict):
         def __missing__(self, key):
             return None
 
     def filter_c_substitution(self, line):