Bug 1142352 - Add a configure test for the gcc version of the host compiler when cross compiling. r=glandium
authorL. David Baron <dbaron@dbaron.org>
Thu, 12 Mar 2015 23:28:55 -0700
changeset 265777 a0f267629f118ac1ad570e0cf6fb8b0d76228bc2
parent 265776 43cbfc770c1e48b098065c342388a067358e7053
child 265778 21a66a6f1d618bac25a60ce2d2cc88950731ed48
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1142352
milestone39.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 1142352 - Add a configure test for the gcc version of the host compiler when cross compiling. r=glandium The duplication of the code higher up is a little bit annoying, but I don't see an easy way to avoid that. It's also still quite far from duplicating everything. I tested locally with a Fennec build that if I bump the requirement from 4.6 to 4.9, I get the expected build error.
build/autoconf/toolchain.m4
--- a/build/autoconf/toolchain.m4
+++ b/build/autoconf/toolchain.m4
@@ -218,24 +218,47 @@ if test "$GNU_CXX"; then
     elif test "$ac_cv_cxx0x_headers_bug" = "yes"; then
         AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
     fi
 fi
 if test -n "$CROSS_COMPILE"; then
     dnl When cross compile, we have no variable telling us what the host compiler is. Figure it out.
     cat > conftest.C <<EOF
 #if defined(__clang__)
-CLANG
+COMPILER CLANG __clang_major__.__clang_minor__.__clang_patchlevel__
 #elif defined(__GNUC__)
-GCC
+COMPILER GCC __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__
 #endif
 EOF
-    host_compiler=`$HOST_CXX -E conftest.C | egrep '(CLANG|GCC)'`
+read dummy host_compiler HOST_CC_VERSION <<EOF
+$($HOST_CC -E conftest.C 2>/dev/null | grep COMPILER)
+EOF
+read dummy host_cxxcompiler HOST_CXX_VERSION <<EOF
+$($HOST_CXX -E conftest.C 2>/dev/null | grep COMPILER)
+EOF
     rm conftest.C
+    if test "$host_compiler" != "$host_cxxcompiler"; then
+        AC_MSG_ERROR([Your C and C++ host compilers are different.  You need to use the same compiler.])
+    fi
     if test -n "$host_compiler"; then
+        if test "$host_compiler" = "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 7 ||
+               test "$HOST_GCC_MAJOR_VERSION" -lt 4; then
+                AC_MSG_ERROR([Only GCC 4.7 or newer supported for host compiler])
+            fi
+        fi
+
         HOST_CXXFLAGS="$HOST_CXXFLAGS -std=gnu++0x"
 
         _SAVE_CXXFLAGS="$CXXFLAGS"
         _SAVE_CPPFLAGS="$CPPFLAGS"
         _SAVE_CXX="$CXX"
         CXXFLAGS="$HOST_CXXFLAGS"
         CPPFLAGS="$HOST_CPPFLAGS"
         CXX="$HOST_CXX"