Bug 1265627 - Move compiler version checks to moz.configure. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 19 Apr 2016 15:09:10 +0900
changeset 331814 a7802ffcbc4be2b31786f18d41af27d464f4724d
parent 331813 3743c8668bed865368a6bbc7d3721379c1b018e8
child 331815 39a20595ffa21407fe61b955f264b359dc27a70a
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1265627
milestone48.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 1265627 - Move compiler version checks to moz.configure. r=ted
build/autoconf/toolchain.m4
build/moz.configure/toolchain.configure
js/src/old-configure.in
old-configure.in
--- a/build/autoconf/toolchain.m4
+++ b/build/autoconf/toolchain.m4
@@ -62,23 +62,16 @@ fi
 if test "$GNU_CC"; then
     if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
         GCC_USE_GNU_LD=1
     fi
 fi
 
 AC_SUBST(CLANG_CXX)
 AC_SUBST(CLANG_CL)
-
-if test -n "$GNU_CC" -a -z "$CLANG_CC" ; then
-    if test "$GCC_MAJOR_VERSION" -eq 4 -a "$GCC_MINOR_VERSION" -lt 8 ||
-       test "$GCC_MAJOR_VERSION" -lt 4; then
-        AC_MSG_ERROR([Only GCC 4.8 or newer supported])
-    fi
-fi
 ])
 
 AC_DEFUN([MOZ_CROSS_COMPILER],
 [
 echo "cross compiling from $host to $target"
 
 _SAVE_CC="$CC"
 _SAVE_CFLAGS="$CFLAGS"
@@ -135,30 +128,16 @@ PATH=$_SAVE_PATH
 ])
 
 AC_DEFUN([MOZ_CXX11],
 [
 dnl Updates to the test below should be duplicated further below for the
 dnl cross-compiling case.
 AC_LANG_CPLUSPLUS
 if test "$GNU_CXX"; then
-    if test -n "$CLANG_CC"; then
-        dnl We'd normally just check for the version from CC_VERSION (fed
-        dnl from __clang_major__ and __clang_minor__), but the clang that
-        dnl comes with Xcode has a completely different version scheme
-        dnl despite exposing the version with the same defines.
-        dnl So instead of a version check, do a feature check. Normally,
-        dnl we'd use __has_feature, but there are unfortunately no C++11
-        dnl differences in clang 3.4. However, it supports the 2013-08-28
-        dnl draft of the ISO WG21 SG10 feature test macro recommendations.
-        AC_TRY_COMPILE([], [#if !__cpp_static_assert
-                            #error ISO WG21 SG10 feature test macros unsupported
-                            #endif],,AC_MSG_ERROR([Only clang/llvm 3.4 or newer supported]))
-    fi
-
     AC_CACHE_CHECK([whether 64-bits std::atomic requires -latomic],
         ac_cv_needs_atomic,
         AC_TRY_LINK(
             [#include <cstdint>
              #include <atomic>],
             [ std::atomic<uint64_t> foo; foo = 1; ],
             ac_cv_needs_atomic=no,
             _SAVE_LIBS="$LIBS"
@@ -186,33 +165,12 @@ if test -n "$CROSS_COMPILE"; then
     if test "$HOST_CC_TYPE" = "gcc" ; then
 	changequote(<<,>>)
 	HOST_GCC_VERSION_FULL="$HOST_CXX_VERSION"
 	HOST_GCC_VERSION=`echo "$HOST_GCC_VERSION_FULL" | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/<<$>>1/;'`
 
 	HOST_GCC_MAJOR_VERSION=`echo ${HOST_GCC_VERSION} | $AWK -F\. '{ print <<$>>1 }'`
 	HOST_GCC_MINOR_VERSION=`echo ${HOST_GCC_VERSION} | $AWK -F\. '{ print <<$>>2 }'`
 	changequote([,])
-
-	if test "$HOST_GCC_MAJOR_VERSION" -eq 4 -a "$HOST_GCC_MINOR_VERSION" -lt 8 ||
-	   test "$HOST_GCC_MAJOR_VERSION" -lt 4; then
-	    AC_MSG_ERROR([Only GCC 4.8 or newer supported for host compiler])
-	fi
     fi
-
-    _SAVE_CXXFLAGS="$CXXFLAGS"
-    _SAVE_CPPFLAGS="$CPPFLAGS"
-    _SAVE_CXX="$CXX"
-    CXXFLAGS="$HOST_CXXFLAGS"
-    CPPFLAGS="$HOST_CPPFLAGS"
-    CXX="$HOST_CXX"
-    if test "$HOST_CC_TYPE" = clang; then
-	AC_TRY_COMPILE([], [#if !__cpp_static_assert
-			    #error ISO WG21 SG10 feature test macros unsupported
-			    #endif],,AC_MSG_ERROR([Only clang/llvm 3.4 or newer supported]))
-    fi
-
-    CXXFLAGS="$_SAVE_CXXFLAGS"
-    CPPFLAGS="$_SAVE_CPPFLAGS"
-    CXX="$_SAVE_CXX"
 fi
 AC_LANG_C
 ])
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -199,28 +199,42 @@ def get_compiler_info(compiler, language
     - the compiler type (msvc, clang-cl, clang or gcc)
     - the compiler version
     - the compiler supported language
     - the compiler supported language version
     '''
     # Note: MSVC doesn't expose __STDC_VERSION__. It does expose __STDC__,
     # but only when given the -Za option, which disables compiler
     # extensions.
+    # Note: We'd normally do a version check for clang, but versions of clang
+    # in Xcode have a completely different versioning scheme despite exposing
+    # the version with the same defines.
+    # So instead, we make things such that the version is missing when the
+    # clang used is below the minimum supported version (currently clang 3.4).
+    # Normally, we'd use __has_feature, but there are unfortunately no C++11
+    # differences in clang 3.4. However, it supports the 2013-08-28 draft of
+    # the ISO WG21 SG10 feature test macro recommendations, and thus exposes
+    # new __cpp_* macros that older clang versions didn't.
+    # We then only include the version information when the C++ compiler
+    # matches the feature check, so that an unsupported version of clang would
+    # have no version number.
     check = dedent('''\
         #if defined(_MSC_VER)
         #if defined(__clang__)
         %COMPILER clang-cl
         %VERSION _MSC_VER
         #else
         %COMPILER msvc
         %VERSION _MSC_FULL_VER
         #endif
         #elif defined(__clang__)
         %COMPILER clang
+        #  if !__cplusplus || __cpp_static_assert
         %VERSION __clang_major__.__clang_minor__.__clang_patchlevel__
+        #  endif
         #elif defined(__GNUC__)
         %COMPILER gcc
         %VERSION __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__
         #endif
 
         #if __cplusplus
         %cplusplus __cplusplus
         #elif __STDC_VERSION__
@@ -249,17 +263,17 @@ def get_compiler_info(compiler, language
         raise FatalCheckError(
             'Unknown compiler or compiler not supported.')
 
     cplusplus = int(data.get('cplusplus', '0L').rstrip('L'))
     stdc_version = int(data.get('STDC_VERSION', '0L').rstrip('L'))
 
     return namespace(
         type=CompilerType(type),
-        version=data['VERSION'],
+        version=data.get('VERSION'),
         language='C++' if cplusplus else 'C',
         language_version=cplusplus if cplusplus else stdc_version,
     )
 
 
 @imports(_from='mozbuild.shellutil', _import='quote')
 def check_compiler(compiler, language):
     info = get_compiler_info(compiler, language)
@@ -467,16 +481,43 @@ def compiler(language, host_or_target, c
             flags += more_flags
             type, version, more_flags = check_compiler(
                 wrapper + [compiler] + flags, language)
 
         if more_flags:
             raise FatalCheckError(
                 'Unknown compiler or compiler not supported.')
 
+        # 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 type == 'gcc' and Version(version) < '4.8.0':
+            raise FatalCheckError(
+                'Only GCC 4.8 or newer is supported (found version %s).'
+                % version)
+
+        # If you want to bump the version check here search for
+        # __cpp_static_assert above, and see the associated comment.
+        if type == 'clang' and not version:
+            raise FatalCheckError(
+                'Only clang/llvm 3.4 or newer is supported.')
+
+        if type == 'msvc':
+            if version < '180030723' or (version > '19' and
+                                         version < '190023506'):
+                raise FatalCheckError(
+                    'This version (%s) of the MSVC compiler is not '
+                    'supported.\n'
+                    'You must install Visual C++ 2013 Update 3, Visual '
+                    'C++ 2015 Update 1, or newer in order to build.\n'
+                    'See https://developer.mozilla.org/en/'
+                    'Windows_Build_Prerequisites' % version)
+
         return namespace(
             wrapper=wrapper,
             compiler=compiler,
             flags=flags,
             type=type,
             version=version,
         )
 
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -257,18 +257,16 @@ case "$target" in
             CXXFLAGS="$CXXFLAGS -wd5027"
 
             # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
             CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
 
             # Disable C++11 thread-safe statics due to crashes on XP (bug 1204752)
             # See https://connect.microsoft.com/VisualStudio/feedback/details/1789709/visual-c-2015-runtime-broken-on-windows-server-2003-c-11-magic-statics
             CXXFLAGS="$CXXFLAGS -Zc:threadSafeInit-"
-        else
-            AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
         fi
         AC_SUBST(MSVC_C_RUNTIME_DLL)
         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
 
         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
         dnl not something else like "magnetic tape manipulation utility".
         MSMT_TOOL=`${MT-mt} 2>&1|grep 'Microsoft (R) Manifest Tool'`
         if test -z "$MSMT_TOOL"; then
--- a/old-configure.in
+++ b/old-configure.in
@@ -399,20 +399,16 @@ case "$target" in
             CXXFLAGS="$CXXFLAGS -wd4091"
 
             if test -n "$WIN_UCRT_REDIST_DIR"; then
               if test ! -d "$WIN_UCRT_REDIST_DIR"; then
                 AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
               fi
               WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && pwd -W`
             fi
-        else
-            AC_MSG_ERROR([This version (${_CC_MAJOR_VERSION}.${_CC_MINOR_VERSION}.${_CC_BUILD_VERSION}) of the MSVC compiler is unsupported.
-You must install Visual C++ 2013 Update 3, Visual C++ 2015 Update 1, or newer in order to build.
-See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
         fi
         AC_SUBST(MSVS_VERSION)
         AC_SUBST(MSVC_HAS_DIA_SDK)
         AC_SUBST(MSVC_C_RUNTIME_DLL)
         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
 
         AC_DEFINE(HAVE_SEH_EXCEPTIONS)