common/autoconf/build-performance.m4
changeset 28812 6c36bc1ccc0e
parent 26907 da70acacfe57
child 29175 2f9d8f167bd7
equal deleted inserted replaced
28811:65cf1b4087cf 28812:6c36bc1ccc0e
   162   AC_ARG_ENABLE([ccache],
   162   AC_ARG_ENABLE([ccache],
   163       [AS_HELP_STRING([--enable-ccache],
   163       [AS_HELP_STRING([--enable-ccache],
   164       [enable using ccache to speed up recompilations @<:@disabled@:>@])])
   164       [enable using ccache to speed up recompilations @<:@disabled@:>@])])
   165 
   165 
   166   CCACHE=
   166   CCACHE=
       
   167   CCACHE_STATUS=
   167   AC_MSG_CHECKING([is ccache enabled])
   168   AC_MSG_CHECKING([is ccache enabled])
   168   ENABLE_CCACHE=$enable_ccache
       
   169   if test "x$enable_ccache" = xyes; then
   169   if test "x$enable_ccache" = xyes; then
   170     AC_MSG_RESULT([yes])
   170     if test "x$TOOLCHAIN_TYPE" = "xgcc" -o "x$TOOLCHAIN_TYPE" = "xclang"; then
   171     OLD_PATH="$PATH"
   171       AC_MSG_RESULT([yes])
   172     if test "x$TOOLCHAIN_PATH" != x; then
   172       OLD_PATH="$PATH"
   173       PATH=$TOOLCHAIN_PATH:$PATH
   173       if test "x$TOOLCHAIN_PATH" != x; then
   174     fi
   174         PATH=$TOOLCHAIN_PATH:$PATH
   175     BASIC_REQUIRE_PROGS(CCACHE, ccache)
   175       fi
   176     CCACHE_STATUS="enabled"
   176       BASIC_REQUIRE_PROGS(CCACHE, ccache)
   177     PATH="$OLD_PATH"
   177       PATH="$OLD_PATH"
       
   178       CCACHE_VERSION=[`$CCACHE --version | head -n1 | $SED 's/[A-Za-z ]*//'`]
       
   179       CCACHE_STATUS="Active ($CCACHE_VERSION)"
       
   180     else
       
   181       AC_MSG_RESULT([no])
       
   182       AC_MSG_WARN([ccache is not supported with toolchain type $TOOLCHAIN_TYPE])
       
   183     fi
   178   elif test "x$enable_ccache" = xno; then
   184   elif test "x$enable_ccache" = xno; then
   179     AC_MSG_RESULT([no, explicitly disabled])
   185     AC_MSG_RESULT([no, explicitly disabled])
       
   186     CCACHE_STATUS="Disabled"
   180   elif test "x$enable_ccache" = x; then
   187   elif test "x$enable_ccache" = x; then
   181     AC_MSG_RESULT([no])
   188     AC_MSG_RESULT([no])
   182   else
   189   else
   183     AC_MSG_RESULT([unknown])
   190     AC_MSG_RESULT([unknown])
   184     AC_MSG_ERROR([--enable-ccache does not accept any parameters])
   191     AC_MSG_ERROR([--enable-ccache does not accept any parameters])
   204 ])
   211 ])
   205 
   212 
   206 AC_DEFUN([BPERF_SETUP_CCACHE_USAGE],
   213 AC_DEFUN([BPERF_SETUP_CCACHE_USAGE],
   207 [
   214 [
   208   if test "x$CCACHE" != x; then
   215   if test "x$CCACHE" != x; then
   209     # Only use ccache if it is 3.1.4 or later, which supports
   216     if test "x$USE_PRECOMPILED_HEADER" = "x1"; then
   210     # precompiled headers.
   217       HAS_BAD_CCACHE=[`$ECHO $CCACHE_VERSION | \
   211     AC_MSG_CHECKING([if ccache supports precompiled headers])
   218           $GREP -e '^1.*' -e '^2.*' -e '^3\.0.*' -e '^3\.1\.[0123]'`]
   212     HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null`
   219       if test "x$HAS_BAD_CCACHE" != "x"; then
   213     if test "x$HAS_GOOD_CCACHE" = x; then
   220         AC_MSG_ERROR([Precompiled headers requires ccache 3.1.4 or later, found $CCACHE_VERSION])
   214       AC_MSG_RESULT([no, disabling ccache])
   221       fi
   215       CCACHE=
       
   216       CCACHE_STATUS="disabled"
       
   217     else
       
   218       AC_MSG_RESULT([yes])
       
   219       AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers])
   222       AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers])
       
   223       CCACHE_PRECOMP_FLAG="-fpch-preprocess"
   220       PUSHED_FLAGS="$CXXFLAGS"
   224       PUSHED_FLAGS="$CXXFLAGS"
   221       CXXFLAGS="-fpch-preprocess $CXXFLAGS"
   225       CXXFLAGS="$CCACHE_PRECOMP_FLAG $CXXFLAGS"
   222       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no])
   226       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no])
   223       CXXFLAGS="$PUSHED_FLAGS"
   227       CXXFLAGS="$PUSHED_FLAGS"
   224       if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then
   228       if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then
   225         AC_MSG_RESULT([yes])
   229         AC_MSG_RESULT([yes])
       
   230         CFLAGS_CCACHE="$CCACHE_PRECOMP_FLAG"
       
   231         AC_SUBST(CFLAGS_CCACHE)
       
   232         CCACHE_SLOPPINESS=pch_defines,time_macros
   226       else
   233       else
   227         AC_MSG_RESULT([no, disabling ccaching of precompiled headers])
   234         AC_MSG_RESULT([no])
   228         CCACHE=
   235         AC_MSG_ERROR([Cannot use ccache with precompiled headers without compiler support for $CCACHE_PRECOMP_FLAG])
   229         CCACHE_STATUS="disabled"
   236       fi
   230       fi
   237     fi
   231     fi
   238 
   232   fi
   239     CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR \
   233 
   240         CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS CCACHE_BASEDIR=$TOPDIR $CCACHE"
   234   if test "x$CCACHE" != x; then
       
   235     CCACHE_SLOPPINESS=time_macros
       
   236     CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE"
       
   237     CCACHE_FLAGS=-fpch-preprocess
       
   238 
   241 
   239     if test "x$SET_CCACHE_DIR" != x; then
   242     if test "x$SET_CCACHE_DIR" != x; then
   240       mkdir -p $CCACHE_DIR > /dev/null 2>&1
   243       mkdir -p $CCACHE_DIR > /dev/null 2>&1
   241       chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1
   244       chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1
   242     fi
   245     fi