diff --git a/aclocal.m4 b/aclocal.m4 index b656bc7d348..c1e6c07bd7f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -3,6 +3,8 @@ dnl Local autoconf macros used with mozilla dnl The contents of this file are under the Public Domain. dnl +builtin(include, build/autoconf/toolchain.m4)dnl +builtin(include, build/autoconf/ccache.m4)dnl builtin(include, build/autoconf/nspr.m4)dnl builtin(include, build/autoconf/nss.m4)dnl builtin(include, build/autoconf/pkg.m4)dnl diff --git a/build/autoconf/ccache.m4 b/build/autoconf/ccache.m4 new file mode 100644 index 00000000000..5e24691955b --- /dev/null +++ b/build/autoconf/ccache.m4 @@ -0,0 +1,36 @@ +dnl This Source Code Form is subject to the terms of the Mozilla Public +dnl License, v. 2.0. If a copy of the MPL was not distributed with this +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. + +dnl ====================================================== +dnl = Enable compiling with ccache +dnl ====================================================== +AC_DEFUN([MOZ_CHECK_CCACHE], +[ +MOZ_ARG_WITH_STRING(ccache, +[ --with-ccache[=path/to/ccache] + Enable compiling with ccache], + CCACHE=$withval, CCACHE="no") + +if test "$CCACHE" != "no"; then + if test -z "$CCACHE" -o "$CCACHE" = "yes"; then + CCACHE= + else + if test ! -e "$CCACHE"; then + AC_MSG_ERROR([$CCACHE not found]) + fi + fi + MOZ_PATH_PROGS(CCACHE, $CCACHE ccache) + if test -z "$CCACHE" -o "$CCACHE" = ":"; then + AC_MSG_ERROR([ccache not found]) + elif test -x "$CCACHE"; then + CC="$CCACHE $CC" + CXX="$CCACHE $CXX" + MOZ_USING_CCACHE=1 + else + AC_MSG_ERROR([$CCACHE is not executable]) + fi +fi + +AC_SUBST(MOZ_USING_CCACHE) +]) diff --git a/build/autoconf/toolchain.m4 b/build/autoconf/toolchain.m4 new file mode 100644 index 00000000000..a9498a80fd3 --- /dev/null +++ b/build/autoconf/toolchain.m4 @@ -0,0 +1,62 @@ +dnl This Source Code Form is subject to the terms of the Mozilla Public +dnl License, v. 2.0. If a copy of the MPL was not distributed with this +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. + +AC_DEFUN([MOZ_TOOL_VARIABLES], +[ +GNU_AS= +GNU_LD= +GNU_CC= +GNU_CXX= +CC_VERSION='N/A' +CXX_VERSION='N/A' +if test "$GCC" = "yes"; then + GNU_CC=1 + CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` +fi +if test "$GXX" = "yes"; then + GNU_CXX=1 + CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'` +fi +if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then + GNU_AS=1 +fi +rm -f conftest.out +if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then + GNU_LD=1 +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 + +INTEL_CC= +INTEL_CXX= +if test "$GCC" = yes; then + if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then + INTEL_CC=1 + fi +fi + +if test "$GXX" = yes; then + if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then + INTEL_CXX=1 + fi +fi + +CLANG_CC= +CLANG_CXX= +if test "$GCC" = yes; then + if test "`$CC -v 2>&1 | grep -c 'clang version'`" != "0"; then + CLANG_CC=1 + fi +fi + +if test "$GXX" = yes; then + if test "`$CXX -v 2>&1 | grep -c 'clang version'`" != "0"; then + CLANG_CXX=1 + fi +fi +AC_SUBST(CLANG_CXX) +]) diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index 3c18f9f3ca9..8eac4085a8e 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -84,6 +84,8 @@ MOZ_ETW = @MOZ_ETW@ MOZ_TRACE_JSCALLS = @MOZ_TRACE_JSCALLS@ DEHYDRA_PATH = @DEHYDRA_PATH@ +MOZ_USING_CCACHE = @MOZ_USING_CCACHE@ +CLANG_CXX = @CLANG_CXX@ MOZ_LINKER = @MOZ_LINKER@ MOZ_OLD_LINKER = @MOZ_OLD_LINKER@ MOZ_ENABLE_SZIP = @MOZ_ENABLE_SZIP@ diff --git a/config/config.mk b/config/config.mk index af01015dbdc..451a63e3964 100644 --- a/config/config.mk +++ b/config/config.mk @@ -562,6 +562,13 @@ ifdef MACOSX_DEPLOYMENT_TARGET export MACOSX_DEPLOYMENT_TARGET PBBUILD_SETTINGS += MACOSX_DEPLOYMENT_TARGET="$(MACOSX_DEPLOYMENT_TARGET)" endif # MACOSX_DEPLOYMENT_TARGET + +ifdef MOZ_USING_CCACHE +ifdef CLANG_CXX +export CCACHE_CPP2=1 +endif +endif + ifdef MOZ_OPTIMIZE ifeq (2,$(MOZ_OPTIMIZE)) # Only override project defaults if the config specified explicit settings diff --git a/configure.in b/configure.in index 5a6ae4a9e84..bef1cbd513b 100644 --- a/configure.in +++ b/configure.in @@ -363,60 +363,7 @@ else fi fi -GNU_AS= -GNU_LD= -GNU_CC= -GNU_CXX= -CC_VERSION='N/A' -CXX_VERSION='N/A' -if test "$GCC" = "yes"; then - GNU_CC=1 - CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` -fi -if test "$GXX" = "yes"; then - GNU_CXX=1 - CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'` -fi -if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then - GNU_AS=1 -fi -rm -f conftest.out -if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then - GNU_LD=1 -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 - -INTEL_CC= -INTEL_CXX= -if test "$GCC" = yes; then - if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then - INTEL_CC=1 - fi -fi - -if test "$GXX" = yes; then - if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then - INTEL_CXX=1 - fi -fi - -CLANG_CC= -CLANG_CXX= -if test "$GCC" = yes; then - if test "`$CC -v 2>&1 | grep -c 'clang version'`" != "0"; then - CLANG_CC=1 - fi -fi - -if test "$GXX" = yes; then - if test "`$CXX -v 2>&1 | grep -c 'clang version'`" != "0"; then - CLANG_CXX=1 - fi -fi +MOZ_TOOL_VARIABLES dnl ======================================================== dnl Special win32 checks @@ -7167,32 +7114,7 @@ if test -n "$JS_CRASH_DIAGNOSTICS"; then AC_DEFINE(JS_CRASH_DIAGNOSTICS) fi -dnl ====================================================== -dnl = Enable compiling with ccache -dnl ====================================================== -MOZ_ARG_WITH_STRING(ccache, -[ --with-ccache[=path/to/ccache] - Enable compiling with ccache], - CCACHE=$withval, CCACHE="no") - -if test "$CCACHE" != "no"; then - if test -z "$CCACHE" -o "$CCACHE" = "yes"; then - CCACHE= - else - if test ! -e "$CCACHE"; then - AC_MSG_ERROR([$CCACHE not found]) - fi - fi - MOZ_PATH_PROGS(CCACHE, $CCACHE ccache) - if test -z "$CCACHE" -o "$CCACHE" = ":"; then - AC_MSG_ERROR([ccache not found]) - elif test -x "$CCACHE"; then - CC="$CCACHE $CC" - CXX="$CCACHE $CXX" - else - AC_MSG_ERROR([$CCACHE is not executable]) - fi -fi +MOZ_CHECK_CCACHE dnl ======================================================== dnl = Enable static checking using gcc-dehydra diff --git a/js/src/aclocal.m4 b/js/src/aclocal.m4 index 857649e0b33..63162189172 100644 --- a/js/src/aclocal.m4 +++ b/js/src/aclocal.m4 @@ -3,6 +3,8 @@ dnl Local autoconf macros used with mozilla dnl The contents of this file are under the Public Domain. dnl +builtin(include, build/autoconf/toolchain.m4)dnl +builtin(include, build/autoconf/ccache.m4)dnl builtin(include, build/autoconf/pkg.m4)dnl builtin(include, build/autoconf/nspr.m4)dnl builtin(include, build/autoconf/altoptions.m4)dnl diff --git a/js/src/build/autoconf/ccache.m4 b/js/src/build/autoconf/ccache.m4 new file mode 100644 index 00000000000..5e24691955b --- /dev/null +++ b/js/src/build/autoconf/ccache.m4 @@ -0,0 +1,36 @@ +dnl This Source Code Form is subject to the terms of the Mozilla Public +dnl License, v. 2.0. If a copy of the MPL was not distributed with this +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. + +dnl ====================================================== +dnl = Enable compiling with ccache +dnl ====================================================== +AC_DEFUN([MOZ_CHECK_CCACHE], +[ +MOZ_ARG_WITH_STRING(ccache, +[ --with-ccache[=path/to/ccache] + Enable compiling with ccache], + CCACHE=$withval, CCACHE="no") + +if test "$CCACHE" != "no"; then + if test -z "$CCACHE" -o "$CCACHE" = "yes"; then + CCACHE= + else + if test ! -e "$CCACHE"; then + AC_MSG_ERROR([$CCACHE not found]) + fi + fi + MOZ_PATH_PROGS(CCACHE, $CCACHE ccache) + if test -z "$CCACHE" -o "$CCACHE" = ":"; then + AC_MSG_ERROR([ccache not found]) + elif test -x "$CCACHE"; then + CC="$CCACHE $CC" + CXX="$CCACHE $CXX" + MOZ_USING_CCACHE=1 + else + AC_MSG_ERROR([$CCACHE is not executable]) + fi +fi + +AC_SUBST(MOZ_USING_CCACHE) +]) diff --git a/js/src/build/autoconf/toolchain.m4 b/js/src/build/autoconf/toolchain.m4 new file mode 100644 index 00000000000..a9498a80fd3 --- /dev/null +++ b/js/src/build/autoconf/toolchain.m4 @@ -0,0 +1,62 @@ +dnl This Source Code Form is subject to the terms of the Mozilla Public +dnl License, v. 2.0. If a copy of the MPL was not distributed with this +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. + +AC_DEFUN([MOZ_TOOL_VARIABLES], +[ +GNU_AS= +GNU_LD= +GNU_CC= +GNU_CXX= +CC_VERSION='N/A' +CXX_VERSION='N/A' +if test "$GCC" = "yes"; then + GNU_CC=1 + CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` +fi +if test "$GXX" = "yes"; then + GNU_CXX=1 + CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'` +fi +if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then + GNU_AS=1 +fi +rm -f conftest.out +if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then + GNU_LD=1 +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 + +INTEL_CC= +INTEL_CXX= +if test "$GCC" = yes; then + if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then + INTEL_CC=1 + fi +fi + +if test "$GXX" = yes; then + if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then + INTEL_CXX=1 + fi +fi + +CLANG_CC= +CLANG_CXX= +if test "$GCC" = yes; then + if test "`$CC -v 2>&1 | grep -c 'clang version'`" != "0"; then + CLANG_CC=1 + fi +fi + +if test "$GXX" = yes; then + if test "`$CXX -v 2>&1 | grep -c 'clang version'`" != "0"; then + CLANG_CXX=1 + fi +fi +AC_SUBST(CLANG_CXX) +]) diff --git a/js/src/config/autoconf.mk.in b/js/src/config/autoconf.mk.in index 431d89f11a2..808f3dcf3d6 100644 --- a/js/src/config/autoconf.mk.in +++ b/js/src/config/autoconf.mk.in @@ -49,6 +49,8 @@ MOZ_ETW = @MOZ_ETW@ JS_HAS_CTYPES = @JS_HAS_CTYPES@ DEHYDRA_PATH = @DEHYDRA_PATH@ +MOZ_USING_CCACHE = @MOZ_USING_CCACHE@ +CLANG_CXX = @CLANG_CXX@ NS_TRACE_MALLOC = @NS_TRACE_MALLOC@ INCREMENTAL_LINKER = @INCREMENTAL_LINKER@ MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@ diff --git a/js/src/config/config.mk b/js/src/config/config.mk index af01015dbdc..451a63e3964 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -562,6 +562,13 @@ ifdef MACOSX_DEPLOYMENT_TARGET export MACOSX_DEPLOYMENT_TARGET PBBUILD_SETTINGS += MACOSX_DEPLOYMENT_TARGET="$(MACOSX_DEPLOYMENT_TARGET)" endif # MACOSX_DEPLOYMENT_TARGET + +ifdef MOZ_USING_CCACHE +ifdef CLANG_CXX +export CCACHE_CPP2=1 +endif +endif + ifdef MOZ_OPTIMIZE ifeq (2,$(MOZ_OPTIMIZE)) # Only override project defaults if the config specified explicit settings diff --git a/js/src/configure.in b/js/src/configure.in index 83a68f711e4..2689e8b133c 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -340,60 +340,7 @@ else fi fi -GNU_AS= -GNU_LD= -GNU_CC= -GNU_CXX= -CC_VERSION='N/A' -CXX_VERSION='N/A' -if test "$GCC" = "yes"; then - GNU_CC=1 - CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` -fi -if test "$GXX" = "yes"; then - GNU_CXX=1 - CXX_VERSION=`$CXX -v 2>&1 | grep 'gcc version'` -fi -if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then - GNU_AS=1 -fi -rm -f conftest.out -if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then - GNU_LD=1 -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 - -INTEL_CC= -INTEL_CXX= -if test "$GCC" = yes; then - if test "`$CC -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then - INTEL_CC=1 - fi -fi - -if test "$GXX" = yes; then - if test "`$CXX -help 2>&1 | grep -c 'Intel(R) C++ Compiler'`" != "0"; then - INTEL_CXX=1 - fi -fi - -CLANG_CC= -CLANG_CXX= -if test "$GCC" = yes; then - if test "`$CC -v 2>&1 | grep -c 'clang version'`" != "0"; then - CLANG_CC=1 - fi -fi - -if test "$GXX" = yes; then - if test "`$CXX -v 2>&1 | grep -c 'clang version'`" != "0"; then - CLANG_CXX=1 - fi -fi +MOZ_TOOL_VARIABLES dnl Special win32 checks dnl ======================================================== @@ -3876,32 +3823,7 @@ if test -n "$JS_OOM_DO_BACKTRACES"; then AC_DEFINE(JS_OOM_DO_BACKTRACES) fi -dnl ====================================================== -dnl = Enable compiling with ccache -dnl ====================================================== -MOZ_ARG_WITH_STRING(ccache, -[ --with-ccache[=path/to/ccache] - Enable compiling with ccache], - CCACHE=$withval, CCACHE="no") - -if test "$CCACHE" != "no"; then - if test -z "$CCACHE" -o "$CCACHE" = "yes"; then - CCACHE= - else - if test ! -e "$CCACHE"; then - AC_MSG_ERROR([$CCACHE not found]) - fi - fi - MOZ_PATH_PROGS(CCACHE, $CCACHE ccache) - if test -z "$CCACHE" -o "$CCACHE" = ":"; then - AC_MSG_ERROR([ccache not found]) - elif test -x "$CCACHE"; then - CC="$CCACHE $CC" - CXX="$CCACHE $CXX" - else - AC_MSG_ERROR([$CCACHE is not executable]) - fi -fi +MOZ_CHECK_CCACHE dnl ======================================================== dnl = Enable static checking using gcc-dehydra