Bug 895915 - Enforce host gcc/clang support for C++11. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 30 Jul 2013 08:57:28 +0900
changeset 152761 f92a6dcf7361edd3ef7ea7d18c82cf2140bc81cc
parent 152760 9251bba8a9b2d99137551659c214ac17b5dee1cc
child 152762 7506c6ee2e8b25f5893dc23e1b392ec5828ba545
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs895915
milestone25.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 895915 - Enforce host gcc/clang support for C++11. r=gps
build/autoconf/toolchain.m4
configure.in
js/src/build/autoconf/toolchain.m4
js/src/configure.in
--- a/build/autoconf/toolchain.m4
+++ b/build/autoconf/toolchain.m4
@@ -59,8 +59,164 @@ if test "`$CC -v 2>&1 | egrep -c '(clang
    CLANG_CC=1
 fi
 
 if test "`$CXX -v 2>&1 | egrep -c '(clang version|Apple.*clang)'`" != "0"; then
    CLANG_CXX=1
 fi
 AC_SUBST(CLANG_CXX)
 ])
+
+AC_DEFUN([MOZ_CROSS_COMPILER],
+[
+echo "cross compiling from $host to $target"
+
+_SAVE_CC="$CC"
+_SAVE_CFLAGS="$CFLAGS"
+_SAVE_LDFLAGS="$LDFLAGS"
+
+AC_MSG_CHECKING([for host c compiler])
+AC_CHECK_PROGS(HOST_CC, cc gcc clang cl, "")
+if test -z "$HOST_CC"; then
+    AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
+fi
+AC_MSG_RESULT([$HOST_CC])
+AC_MSG_CHECKING([for host c++ compiler])
+AC_CHECK_PROGS(HOST_CXX, c++ g++ clang++ cl, "")
+if test -z "$HOST_CXX"; then
+    AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
+fi
+AC_MSG_RESULT([$HOST_CXX])
+
+if test -z "$HOST_CFLAGS"; then
+    HOST_CFLAGS="$CFLAGS"
+fi
+if test -z "$HOST_CXXFLAGS"; then
+    HOST_CXXFLAGS="$CXXFLAGS"
+fi
+if test -z "$HOST_LDFLAGS"; then
+    HOST_LDFLAGS="$LDFLAGS"
+fi
+if test -z "$HOST_AR_FLAGS"; then
+    HOST_AR_FLAGS="$AR_FLAGS"
+fi
+AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
+AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
+CC="$HOST_CC"
+CFLAGS="$HOST_CFLAGS"
+LDFLAGS="$HOST_LDFLAGS"
+
+AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
+AC_TRY_COMPILE([], [return(0);],
+    [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
+    AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
+
+CC="$HOST_CXX"
+CFLAGS="$HOST_CXXFLAGS"
+AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
+AC_TRY_COMPILE([], [return(0);],
+    [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
+    AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
+
+CC=$_SAVE_CC
+CFLAGS=$_SAVE_CFLAGS
+LDFLAGS=$_SAVE_LDFLAGS
+
+AC_CHECK_PROGS(CC, "${target_alias}-gcc" "${target}-gcc", :)
+unset ac_cv_prog_CC
+AC_PROG_CC
+AC_CHECK_PROGS(CXX, "${target_alias}-g++" "${target}-g++", :)
+unset ac_cv_prog_CXX
+AC_PROG_CXX
+
+AC_CHECK_PROGS(RANLIB, "${target_alias}-ranlib" "${target}-ranlib", :)
+AC_CHECK_PROGS(AR, "${target_alias}-ar" "${target}-ar", :)
+MOZ_PATH_PROGS(AS, "${target_alias}-as" "${target}-as", :)
+AC_CHECK_PROGS(LD, "${target_alias}-ld" "${target}-ld", :)
+AC_CHECK_PROGS(STRIP, "${target_alias}-strip" "${target}-strip", :)
+AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", :)
+AC_DEFINE(CROSS_COMPILE)
+
+dnl If we cross compile for ppc on Mac OS X x86, cross_compiling will
+dnl dnl have erroneously been set to "no", because the x86 build host is
+dnl dnl able to run ppc code in a translated environment, making a cross
+dnl dnl compiler appear native.  So we override that here.
+cross_compiling=yes
+])
+
+AC_DEFUN([MOZ_CXX11],
+[
+dnl Check whether gcc's c++0x mode works
+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
+    CXXFLAGS="$CXXFLAGS -std=gnu++0x"
+
+    AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
+        ac_cv_cxx0x_headers_bug,
+        [AC_TRY_COMPILE([#include <memory>], [],
+                        ac_cv_cxx0x_headers_bug="no",
+                        ac_cv_cxx0x_headers_bug="yes")])
+
+    if test "$CLANG_CXX" -a "$ac_cv_cxx0x_headers_bug" = "yes"; then
+        CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers"
+        AC_CACHE_CHECK(whether workaround for gcc c++0x headers conflict with clang works,
+            ac_cv_cxx0x_clang_workaround,
+            [AC_TRY_COMPILE([#include <memory>], [],
+                            ac_cv_cxx0x_clang_workaround="yes",
+                            ac_cv_cxx0x_clang_workaround="no")])
+
+        if test "ac_cv_cxx0x_clang_workaround" = "no"; then
+            AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
+        fi
+    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
+#elif defined(__GNUC__)
+GCC
+#endif
+EOF
+    host_compiler=`$HOST_CXX -E conftest.C | egrep '(CLANG|GCC)'`
+    rm conftest.C
+    if test -n "$host_compiler"; then
+        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"
+        AC_CACHE_CHECK(for host gcc c++0x headers bug without rtti,
+            ac_cv_host_cxx0x_headers_bug,
+            [AC_TRY_COMPILE([#include <memory>], [],
+                            ac_cv_host_cxx0x_headers_bug="no",
+                            ac_cv_host_cxx0x_headers_bug="yes")])
+
+        if test "$host_compiler" = CLANG -a "$ac_cv_host_cxx0x_headers_bug" = "yes"; then
+            CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers"
+            AC_CACHE_CHECK(whether workaround for host gcc c++0x headers conflict with host clang works,
+                ac_cv_host_cxx0x_clang_workaround,
+                [AC_TRY_COMPILE([#include <memory>], [],
+                                ac_cv_host_cxx0x_clang_workaround="yes",
+                                ac_cv_host_cxx0x_clang_workaround="no")])
+
+            if test "ac_cv_host_cxx0x_clang_workaround" = "no"; then
+                AC_MSG_ERROR([Your host toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
+            fi
+            HOST_CXXFLAGS="$CXXFLAGS"
+        elif test "$ac_cv_host_cxx0x_headers_bug" = "yes"; then
+            AC_MSG_ERROR([Your host toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
+        fi
+        CXXFLAGS="$_SAVE_CXXFLAGS"
+        CPPFLAGS="$_SAVE_CPPFLAGS"
+        CXX="$_SAVE_CXX"
+    fi
+fi
+AC_LANG_C
+])
--- a/configure.in
+++ b/configure.in
@@ -280,85 +280,17 @@ dnl to use the cross-compile setup for n
 dnl ========================================================
 
 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
 AR_FLAGS='cr $@'
 
 if test "$COMPILE_ENVIRONMENT"; then
 
 if test -n "$CROSS_COMPILE" -a "$target" != "$host"; then
-    echo "cross compiling from $host to $target"
-    cross_compiling=yes
-
-    _SAVE_CC="$CC"
-    _SAVE_CFLAGS="$CFLAGS"
-    _SAVE_LDFLAGS="$LDFLAGS"
-
-    AC_MSG_CHECKING([for host c compiler])
-    AC_CHECK_PROGS(HOST_CC, $HOST_CC cc gcc /usr/ucb/cc cl icc, "")
-    if test -z "$HOST_CC"; then
-        AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
-    fi
-    AC_MSG_RESULT([$HOST_CC])
-    AC_MSG_CHECKING([for host c++ compiler])
-    AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
-    if test -z "$HOST_CXX"; then
-        AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
-    fi
-    AC_MSG_RESULT([$HOST_CXX])
-
-    if test -z "$HOST_CFLAGS"; then
-        HOST_CFLAGS="$CFLAGS"
-    fi
-    if test -z "$HOST_CXXFLAGS"; then
-        HOST_CXXFLAGS="$CXXFLAGS"
-    fi
-    if test -z "$HOST_LDFLAGS"; then
-        HOST_LDFLAGS="$LDFLAGS"
-    fi
-    if test -z "$HOST_AR_FLAGS"; then
-        HOST_AR_FLAGS="$AR_FLAGS"
-    fi
-    AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
-    AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
-    CC="$HOST_CC"
-    CFLAGS="$HOST_CFLAGS"
-    LDFLAGS="$HOST_LDFLAGS"
-
-    AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
-    AC_TRY_COMPILE([], [return(0);],
-	[ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
-	AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
-
-    CC="$HOST_CXX"
-    CFLAGS="$HOST_CXXFLAGS"
-
-    AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
-    AC_TRY_COMPILE([], [return(0);],
-	[ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
-	AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
-
-    CC=$_SAVE_CC
-    CFLAGS=$_SAVE_CFLAGS
-    LDFLAGS=$_SAVE_LDFLAGS
-
-    AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
-    unset ac_cv_prog_CC
-    AC_PROG_CC
-    AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
-    unset ac_cv_prog_CXX
-    AC_PROG_CXX
-
-    AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
-    AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
-    MOZ_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
-    AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
-    AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
-    AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
-    AC_DEFINE(CROSS_COMPILE)
+    MOZ_CROSS_COMPILER
 else
     AC_PROG_CC
     case "$target" in
     *-mingw*)
       # Work around the conftest.exe access problem on Windows
       sleep 2
     esac
     AC_PROG_CXX
@@ -2734,44 +2666,20 @@ AC_CACHE_VAL(ac_cv_have_uname_us_domainn
 
 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
     AC_MSG_RESULT(yes)
 else
     AC_MSG_RESULT(no)
 fi
 
-dnl Check whether gcc's c++0x mode works
+MOZ_CXX11
+
 AC_LANG_CPLUSPLUS
 
-if test "$GNU_CXX"; then
-    CXXFLAGS="$CXXFLAGS -std=gnu++0x"
-
-    AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
-        ac_cv_cxx0x_headers_bug,
-        [AC_TRY_COMPILE([#include <memory>], [],
-                        ac_cv_cxx0x_headers_bug="no",
-                        ac_cv_cxx0x_headers_bug="yes")])
-
-    if test "$CLANG_CXX" -a "$ac_cv_cxx0x_headers_bug" = "yes"; then
-        CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers"
-        AC_CACHE_CHECK(whether workaround for gcc c++0x headers conflict with clang works,
-            ac_cv_cxx0x_clang_workaround,
-            [AC_TRY_COMPILE([#include <memory>], [],
-                            ac_cv_cxx0x_clang_workaround="yes",
-                            ac_cv_cxx0x_clang_workaround="no")])
-
-        if test "ac_cv_cxx0x_clang_workaround" = "no"; then
-            AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
-        fi
-    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
-
 dnl Check for usable char16_t (2 bytes, unsigned)
 dnl (we might not need the unsignedness check anymore)
 AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
     ac_cv_have_usable_char16_t,
     [AC_TRY_COMPILE([$configure_static_assert_macros],
                     [CONFIGURE_STATIC_ASSERT(sizeof(char16_t) == 2);
                      CONFIGURE_STATIC_ASSERT(char16_t(-1) > char16_t(0));
                      CONFIGURE_STATIC_ASSERT(sizeof((u"hello")[0]) == 2);
--- a/js/src/build/autoconf/toolchain.m4
+++ b/js/src/build/autoconf/toolchain.m4
@@ -59,8 +59,162 @@ if test "`$CC -v 2>&1 | egrep -c '(clang
    CLANG_CC=1
 fi
 
 if test "`$CXX -v 2>&1 | egrep -c '(clang version|Apple.*clang)'`" != "0"; then
    CLANG_CXX=1
 fi
 AC_SUBST(CLANG_CXX)
 ])
+
+AC_DEFUN([MOZ_CROSS_COMPILER],
+[
+echo "cross compiling from $host to $target"
+
+_SAVE_CC="$CC"
+_SAVE_CFLAGS="$CFLAGS"
+_SAVE_LDFLAGS="$LDFLAGS"
+
+AC_MSG_CHECKING([for host c compiler])
+AC_CHECK_PROGS(HOST_CC, cc gcc clang cl, "")
+if test -z "$HOST_CC"; then
+    AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
+fi
+AC_MSG_RESULT([$HOST_CC])
+AC_MSG_CHECKING([for host c++ compiler])
+AC_CHECK_PROGS(HOST_CXX, c++ g++ clang++ cl, "")
+if test -z "$HOST_CXX"; then
+    AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
+fi
+AC_MSG_RESULT([$HOST_CXX])
+
+if test -z "$HOST_CFLAGS"; then
+    HOST_CFLAGS="$CFLAGS"
+fi
+if test -z "$HOST_CXXFLAGS"; then
+    HOST_CXXFLAGS="$CXXFLAGS"
+fi
+if test -z "$HOST_LDFLAGS"; then
+    HOST_LDFLAGS="$LDFLAGS"
+fi
+if test -z "$HOST_AR_FLAGS"; then
+    HOST_AR_FLAGS="$AR_FLAGS"
+fi
+AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
+AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
+CC="$HOST_CC"
+CFLAGS="$HOST_CFLAGS"
+LDFLAGS="$HOST_LDFLAGS"
+
+AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
+AC_TRY_COMPILE([], [return(0);],
+    [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
+    AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
+
+CC="$HOST_CXX"
+CFLAGS="$HOST_CXXFLAGS"
+AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
+AC_TRY_COMPILE([], [return(0);],
+    [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
+    AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
+
+CC=$_SAVE_CC
+CFLAGS=$_SAVE_CFLAGS
+LDFLAGS=$_SAVE_LDFLAGS
+
+AC_CHECK_PROGS(CC, "${target_alias}-gcc" "${target}-gcc", :)
+unset ac_cv_prog_CC
+AC_PROG_CC
+AC_CHECK_PROGS(CXX, "${target_alias}-g++" "${target}-g++", :)
+unset ac_cv_prog_CXX
+AC_PROG_CXX
+
+AC_CHECK_PROGS(RANLIB, "${target_alias}-ranlib" "${target}-ranlib", :)
+AC_CHECK_PROGS(AR, "${target_alias}-ar" "${target}-ar", :)
+MOZ_PATH_PROGS(AS, "${target_alias}-as" "${target}-as", :)
+AC_CHECK_PROGS(LD, "${target_alias}-ld" "${target}-ld", :)
+AC_CHECK_PROGS(STRIP, "${target_alias}-strip" "${target}-strip", :)
+AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", :)
+AC_DEFINE(CROSS_COMPILE)
+
+dnl If we cross compile for ppc on Mac OS X x86, cross_compiling will
+dnl dnl have erroneously been set to "no", because the x86 build host is
+dnl dnl able to run ppc code in a translated environment, making a cross
+dnl dnl compiler appear native.  So we override that here.
+cross_compiling=yes
+])
+
+AC_DEFUN([MOZ_CXX11],
+[
+dnl Check whether gcc's c++0x mode works
+AC_LANG_CPLUSPLUS
+if test "$GNU_CXX"; then
+    CXXFLAGS="$CXXFLAGS -std=gnu++0x"
+
+    AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
+        ac_cv_cxx0x_headers_bug,
+        [AC_TRY_COMPILE([#include <memory>], [],
+                        ac_cv_cxx0x_headers_bug="no",
+                        ac_cv_cxx0x_headers_bug="yes")])
+
+    if test "$CLANG_CXX" -a "$ac_cv_cxx0x_headers_bug" = "yes"; then
+        CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers"
+        AC_CACHE_CHECK(whether workaround for gcc c++0x headers conflict with clang works,
+            ac_cv_cxx0x_clang_workaround,
+            [AC_TRY_COMPILE([#include <memory>], [],
+                            ac_cv_cxx0x_clang_workaround="yes",
+                            ac_cv_cxx0x_clang_workaround="no")])
+
+        if test "ac_cv_cxx0x_clang_workaround" = "no"; then
+            AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
+        fi
+    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
+#elif defined(__GNUC__)
+GCC
+#endif
+EOF
+    host_compiler=`$HOST_CXX -E conftest.C | egrep '(CLANG|GCC)'`
+    rm conftest.C
+    if test -n "$host_compiler"; then
+        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"
+        AC_CACHE_CHECK(for host gcc c++0x headers bug without rtti,
+            ac_cv_host_cxx0x_headers_bug,
+            [AC_TRY_COMPILE([#include <memory>], [],
+                            ac_cv_host_cxx0x_headers_bug="no",
+                            ac_cv_host_cxx0x_headers_bug="yes")])
+
+        if test "$host_compiler" = CLANG -a "$ac_cv_host_cxx0x_headers_bug" = "yes"; then
+            CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers"
+            AC_CACHE_CHECK(whether workaround for host gcc c++0x headers conflict with host clang works,
+                ac_cv_host_cxx0x_clang_workaround,
+                [AC_TRY_COMPILE([#include <memory>], [],
+                                ac_cv_host_cxx0x_clang_workaround="yes",
+                                ac_cv_host_cxx0x_clang_workaround="no")])
+
+            if test "ac_cv_host_cxx0x_clang_workaround" = "no"; then
+                AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
+            fi
+            HOST_CXXFLAGS="$CXXFLAGS"
+        elif test "$ac_cv_host_cxx0x_headers_bug" = "yes"; then
+            AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
+        fi
+	CXXFLAGS="$_SAVE_CXXFLAGS"
+	CPPFLAGS="$_SAVE_CPPFLAGS"
+	CXX="$_SAVE_CXX"
+    fi
+fi
+AC_LANG_C
+])
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -277,90 +277,17 @@ if test "$COMPILE_ENVIRONMENT"; then
 #   too far gone to back out now. See Bug 475488:
 #     - When we say $target, we mean $host, that is, the system on which
 #       Mozilla will be run.
 #     - When we say $host, we mean $build, that is, the system on which Mozilla
 #       is built.
 #     - $target (in its correct usage) is for compilers who generate code for a
 #       different platform than $host, so it would not be used by Mozilla.
 if test "$target" != "$host"; then
-    echo "cross compiling from $host to $target"
-
-    _SAVE_CC="$CC"
-    _SAVE_CFLAGS="$CFLAGS"
-    _SAVE_LDFLAGS="$LDFLAGS"
-
-    AC_MSG_CHECKING([for host c compiler])
-    AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc cl icc, "")
-    if test -z "$HOST_CC"; then
-        AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
-    fi
-    AC_MSG_RESULT([$HOST_CC])
-    AC_MSG_CHECKING([for host c++ compiler])
-    AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
-    if test -z "$HOST_CXX"; then
-        AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
-    fi
-    AC_MSG_RESULT([$HOST_CXX])
-
-    if test -z "$HOST_CFLAGS"; then
-        HOST_CFLAGS="$CFLAGS"
-    fi
-    if test -z "$HOST_CXXFLAGS"; then
-        HOST_CXXFLAGS="$CXXFLAGS"
-    fi
-    if test -z "$HOST_LDFLAGS"; then
-        HOST_LDFLAGS="$LDFLAGS"
-    fi
-    if test -z "$HOST_AR_FLAGS"; then
-        HOST_AR_FLAGS="$AR_FLAGS"
-    fi
-    AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
-    AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
-    CC="$HOST_CC"
-    CFLAGS="$HOST_CFLAGS"
-    LDFLAGS="$HOST_LDFLAGS"
-
-    AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
-    AC_TRY_COMPILE([], [return(0);],
-	[ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
-	AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
-
-    CC="$HOST_CXX"
-    CFLAGS="$HOST_CXXFLAGS"
-
-    AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
-    AC_TRY_COMPILE([], [return(0);],
-	[ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
-	AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
-
-    CC=$_SAVE_CC
-    CFLAGS=$_SAVE_CFLAGS
-    LDFLAGS=$_SAVE_LDFLAGS
-
-    AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
-    unset ac_cv_prog_CC
-    AC_PROG_CC
-    AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
-    unset ac_cv_prog_CXX
-    AC_PROG_CXX
-
-    AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
-    AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
-    MOZ_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
-    AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
-    AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
-    AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
-    AC_DEFINE(CROSS_COMPILE)
-
-    dnl If we cross compile for ppc on Mac OS X x86, cross_compiling will
-    dnl have erroneously been set to "no", because the x86 build host is
-    dnl able to run ppc code in a translated environment, making a cross
-    dnl compiler appear native.  So we override that here.
-    cross_compiling=yes
+    MOZ_CROSS_COMPILER
 else
     AC_PROG_CC
     AC_PROG_CXX
     AC_PROG_RANLIB
     MOZ_PATH_PROGS(AS, $AS as, $CC)
     AC_CHECK_PROGS(AR, ar, :)
     AC_CHECK_PROGS(LD, ld, :)
     AC_CHECK_PROGS(STRIP, strip, :)
@@ -2342,45 +2269,17 @@ AC_CACHE_VAL(ac_cv_have_uname_us_domainn
 
 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
     AC_MSG_RESULT(yes)
 else
     AC_MSG_RESULT(no)
 fi
 
-dnl Check whether gcc's c++0x mode works
-AC_LANG_CPLUSPLUS
-
-if test "$GNU_CXX"; then
-    CXXFLAGS="$CXXFLAGS -std=gnu++0x"
-
-    AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
-        ac_cv_cxx0x_headers_bug,
-        [AC_TRY_COMPILE([#include <memory>], [],
-                        ac_cv_cxx0x_headers_bug="no",
-                        ac_cv_cxx0x_headers_bug="yes")])
-
-    if test "$CLANG_CXX" -a "$ac_cv_cxx0x_headers_bug" = "yes"; then
-        CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers"
-        AC_CACHE_CHECK(whether workaround for gcc c++0x headers conflict with clang works,
-            ac_cv_cxx0x_clang_workaround,
-            [AC_TRY_COMPILE([#include <memory>], [],
-                            ac_cv_cxx0x_clang_workaround="yes",
-                            ac_cv_cxx0x_clang_workaround="no")])
-
-        if test "ac_cv_cxx0x_clang_workaround" = "no"; then
-            AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
-        fi
-    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
-
-AC_LANG_C
+MOZ_CXX11
 
 dnl Check for .hidden assembler directive and visibility attribute.
 dnl Borrowed from glibc configure.in
 dnl ===============================================================
 if test "$GNU_CC"; then
   AC_CACHE_CHECK(for visibility(hidden) attribute,
                  ac_cv_visibility_hidden,
                  [cat > conftest.c <<EOF