# HG changeset patch # User erikj # Date 1423567544 -3600 # Node ID 6c36bc1ccc0e09279851a2a102e57970c594097a # Parent 65cf1b4087cf844d8dac2956e73079aea8b0f013 8062223: Upgrading to ccache 1.3.10 disables the use of ccache Reviewed-by: ihse diff -r 65cf1b4087cf -r 6c36bc1ccc0e README-builds.html --- a/README-builds.html Fri Feb 06 12:46:59 2015 +0100 +++ b/README-builds.html Tue Feb 10 12:25:44 2015 +0100 @@ -1463,14 +1463,13 @@

Building with ccache

-

A simple way to radically speed up compilation of native code - (typically hotspot and native libraries in JDK) is to install - ccache. This will cache and reuse prior compilation results, if the - source code is unchanged. However, ccache versions prior to 3.1.4 - does not work correctly with the precompiled headers used in - OpenJDK. So if your platform supports ccache at 3.1.4 or later, we - highly recommend installing it. This is currently only supported on - linux.

+

The OpenJDK build supports building with ccache + when using gcc or clang. Using ccache can + radically speed up compilation of native code if + you often rebuild the same sources. Your milage + may vary however so we recommend evaluating it for + yourself. To enable it, make sure it's on the path + and configure with --enable-ccache.

Building on local disk

diff -r 65cf1b4087cf -r 6c36bc1ccc0e common/autoconf/build-performance.m4 --- a/common/autoconf/build-performance.m4 Fri Feb 06 12:46:59 2015 +0100 +++ b/common/autoconf/build-performance.m4 Tue Feb 10 12:25:44 2015 +0100 @@ -164,19 +164,26 @@ [enable using ccache to speed up recompilations @<:@disabled@:>@])]) CCACHE= + CCACHE_STATUS= AC_MSG_CHECKING([is ccache enabled]) - ENABLE_CCACHE=$enable_ccache if test "x$enable_ccache" = xyes; then - AC_MSG_RESULT([yes]) - OLD_PATH="$PATH" - if test "x$TOOLCHAIN_PATH" != x; then - PATH=$TOOLCHAIN_PATH:$PATH + if test "x$TOOLCHAIN_TYPE" = "xgcc" -o "x$TOOLCHAIN_TYPE" = "xclang"; then + AC_MSG_RESULT([yes]) + OLD_PATH="$PATH" + if test "x$TOOLCHAIN_PATH" != x; then + PATH=$TOOLCHAIN_PATH:$PATH + fi + BASIC_REQUIRE_PROGS(CCACHE, ccache) + PATH="$OLD_PATH" + CCACHE_VERSION=[`$CCACHE --version | head -n1 | $SED 's/[A-Za-z ]*//'`] + CCACHE_STATUS="Active ($CCACHE_VERSION)" + else + AC_MSG_RESULT([no]) + AC_MSG_WARN([ccache is not supported with toolchain type $TOOLCHAIN_TYPE]) fi - BASIC_REQUIRE_PROGS(CCACHE, ccache) - CCACHE_STATUS="enabled" - PATH="$OLD_PATH" elif test "x$enable_ccache" = xno; then AC_MSG_RESULT([no, explicitly disabled]) + CCACHE_STATUS="Disabled" elif test "x$enable_ccache" = x; then AC_MSG_RESULT([no]) else @@ -206,35 +213,31 @@ AC_DEFUN([BPERF_SETUP_CCACHE_USAGE], [ if test "x$CCACHE" != x; then - # Only use ccache if it is 3.1.4 or later, which supports - # precompiled headers. - AC_MSG_CHECKING([if ccache supports precompiled headers]) - HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null` - if test "x$HAS_GOOD_CCACHE" = x; then - AC_MSG_RESULT([no, disabling ccache]) - CCACHE= - CCACHE_STATUS="disabled" - else - AC_MSG_RESULT([yes]) + if test "x$USE_PRECOMPILED_HEADER" = "x1"; then + HAS_BAD_CCACHE=[`$ECHO $CCACHE_VERSION | \ + $GREP -e '^1.*' -e '^2.*' -e '^3\.0.*' -e '^3\.1\.[0123]'`] + if test "x$HAS_BAD_CCACHE" != "x"; then + AC_MSG_ERROR([Precompiled headers requires ccache 3.1.4 or later, found $CCACHE_VERSION]) + fi AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers]) + CCACHE_PRECOMP_FLAG="-fpch-preprocess" PUSHED_FLAGS="$CXXFLAGS" - CXXFLAGS="-fpch-preprocess $CXXFLAGS" + CXXFLAGS="$CCACHE_PRECOMP_FLAG $CXXFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no]) CXXFLAGS="$PUSHED_FLAGS" if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then AC_MSG_RESULT([yes]) + CFLAGS_CCACHE="$CCACHE_PRECOMP_FLAG" + AC_SUBST(CFLAGS_CCACHE) + CCACHE_SLOPPINESS=pch_defines,time_macros else - AC_MSG_RESULT([no, disabling ccaching of precompiled headers]) - CCACHE= - CCACHE_STATUS="disabled" + AC_MSG_RESULT([no]) + AC_MSG_ERROR([Cannot use ccache with precompiled headers without compiler support for $CCACHE_PRECOMP_FLAG]) fi fi - fi - if test "x$CCACHE" != x; then - CCACHE_SLOPPINESS=time_macros - CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE" - CCACHE_FLAGS=-fpch-preprocess + CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR \ + CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS CCACHE_BASEDIR=$TOPDIR $CCACHE" if test "x$SET_CCACHE_DIR" != x; then mkdir -p $CCACHE_DIR > /dev/null 2>&1 diff -r 65cf1b4087cf -r 6c36bc1ccc0e common/autoconf/generated-configure.sh --- a/common/autoconf/generated-configure.sh Fri Feb 06 12:46:59 2015 +0100 +++ b/common/autoconf/generated-configure.sh Tue Feb 10 12:25:44 2015 +0100 @@ -629,6 +629,7 @@ ac_subst_vars='LTLIBOBJS LIBOBJS +CFLAGS_CCACHE CCACHE USE_PRECOMPILED_HEADER SJAVAC_SERVER_DIR @@ -4334,7 +4335,7 @@ #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1423212925 +DATE_WHEN_GENERATED=1423567509 ############################################################################### # @@ -50882,16 +50883,17 @@ CCACHE= + CCACHE_STATUS= { $as_echo "$as_me:${as_lineno-$LINENO}: checking is ccache enabled" >&5 $as_echo_n "checking is ccache enabled... " >&6; } - ENABLE_CCACHE=$enable_ccache if test "x$enable_ccache" = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + if test "x$TOOLCHAIN_TYPE" = "xgcc" -o "x$TOOLCHAIN_TYPE" = "xclang"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - OLD_PATH="$PATH" - if test "x$TOOLCHAIN_PATH" != x; then - PATH=$TOOLCHAIN_PATH:$PATH - fi + OLD_PATH="$PATH" + if test "x$TOOLCHAIN_PATH" != x; then + PATH=$TOOLCHAIN_PATH:$PATH + fi @@ -51085,11 +51087,19 @@ fi - CCACHE_STATUS="enabled" - PATH="$OLD_PATH" + PATH="$OLD_PATH" + CCACHE_VERSION=`$CCACHE --version | head -n1 | $SED 's/[A-Za-z ]*//'` + CCACHE_STATUS="Active ($CCACHE_VERSION)" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: ccache is not supported with toolchain type $TOOLCHAIN_TYPE" >&5 +$as_echo "$as_me: WARNING: ccache is not supported with toolchain type $TOOLCHAIN_TYPE" >&2;} + fi elif test "x$enable_ccache" = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, explicitly disabled" >&5 $as_echo "no, explicitly disabled" >&6; } + CCACHE_STATUS="Disabled" elif test "x$enable_ccache" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -51120,23 +51130,17 @@ if test "x$CCACHE" != x; then if test "x$CCACHE" != x; then - # Only use ccache if it is 3.1.4 or later, which supports - # precompiled headers. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ccache supports precompiled headers" >&5 -$as_echo_n "checking if ccache supports precompiled headers... " >&6; } - HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.[456789]) 2> /dev/null` - if test "x$HAS_GOOD_CCACHE" = x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, disabling ccache" >&5 -$as_echo "no, disabling ccache" >&6; } - CCACHE= - CCACHE_STATUS="disabled" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } + if test "x$USE_PRECOMPILED_HEADER" = "x1"; then + HAS_BAD_CCACHE=`$ECHO $CCACHE_VERSION | \ + $GREP -e '^1.*' -e '^2.*' -e '^3\.0.*' -e '^3\.1\.[0123]'` + if test "x$HAS_BAD_CCACHE" != "x"; then + as_fn_error $? "Precompiled headers requires ccache 3.1.4 or later, found $CCACHE_VERSION" "$LINENO" 5 + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if C-compiler supports ccache precompiled headers" >&5 $as_echo_n "checking if C-compiler supports ccache precompiled headers... " >&6; } + CCACHE_PRECOMP_FLAG="-fpch-preprocess" PUSHED_FLAGS="$CXXFLAGS" - CXXFLAGS="-fpch-preprocess $CXXFLAGS" + CXXFLAGS="$CCACHE_PRECOMP_FLAG $CXXFLAGS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -51158,19 +51162,18 @@ if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, disabling ccaching of precompiled headers" >&5 -$as_echo "no, disabling ccaching of precompiled headers" >&6; } - CCACHE= - CCACHE_STATUS="disabled" - fi - fi - fi - - if test "x$CCACHE" != x; then - CCACHE_SLOPPINESS=time_macros - CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE" - CCACHE_FLAGS=-fpch-preprocess + CFLAGS_CCACHE="$CCACHE_PRECOMP_FLAG" + + CCACHE_SLOPPINESS=pch_defines,time_macros + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "Cannot use ccache with precompiled headers without compiler support for $CCACHE_PRECOMP_FLAG" "$LINENO" 5 + fi + fi + + CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR \ + CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS CCACHE_BASEDIR=$TOPDIR $CCACHE" if test "x$SET_CCACHE_DIR" != x; then mkdir -p $CCACHE_DIR > /dev/null 2>&1 diff -r 65cf1b4087cf -r 6c36bc1ccc0e common/autoconf/hotspot-spec.gmk.in --- a/common/autoconf/hotspot-spec.gmk.in Fri Feb 06 12:46:59 2015 +0100 +++ b/common/autoconf/hotspot-spec.gmk.in Tue Feb 10 12:25:44 2015 +0100 @@ -109,8 +109,8 @@ MT:=@HOTSPOT_MT@ RC:=@HOTSPOT_RC@ -EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ -EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@ +EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ $(CFLAGS_CCACHE) +EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@ $(CFLAGS_CCACHE) EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@ USE_PRECOMPILED_HEADER=@USE_PRECOMPILED_HEADER@ diff -r 65cf1b4087cf -r 6c36bc1ccc0e common/autoconf/spec.gmk.in --- a/common/autoconf/spec.gmk.in Fri Feb 06 12:46:59 2015 +0100 +++ b/common/autoconf/spec.gmk.in Tue Feb 10 12:25:44 2015 +0100 @@ -326,6 +326,8 @@ CFLAGS_WARNINGS_ARE_ERRORS:=@CFLAGS_WARNINGS_ARE_ERRORS@ +CFLAGS_CCACHE:=@CFLAGS_CCACHE@ + # Tools that potentially need to be cross compilation aware. CC:=@FIXPATH@ @CCACHE@ @CC@ diff -r 65cf1b4087cf -r 6c36bc1ccc0e make/common/NativeCompilation.gmk --- a/make/common/NativeCompilation.gmk Fri Feb 06 12:46:59 2015 +0100 +++ b/make/common/NativeCompilation.gmk Tue Feb 10 12:25:44 2015 +0100 @@ -87,12 +87,12 @@ ifneq (,$$(filter %.c,$2)) # Compile as a C file - $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(