# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/ccache/parse-config # Copyright (C) 2004 - 2024 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2. # --- T2-COPYRIGHT-NOTE-END --- if [ "$SDECFG_PKG_CCACHE_USEIT" = 1 -a "`type -p ccache`" ]; then if [ "$pkg" == gcc -a "$SDECFG_MULTILIB" = 1 ]; then : # in GCC multilib builds the ccache hash currently collides (or so) else unset ${!CCACHE_*} ccache_dir=ccache # wrap the sytem compiler atstage toolchain && var_append ccache_dir - ${arch_build%%-*} var_append ccache_dir - $arch # do not trash the cache with feature-less built packages [ $stagelevel -le 2 ] && var_append ccache_dir - $stagelevel export CCACHE_DIR="$base/build/$ccache_dir/$pkg" export CCACHE_DONT_STAT_COMPILER=1 # legacy T2, could be removed in the future export CCACHE_COMPILERCHECK="none" # native since ccache-3.1.5 export CCACHE_UNIFY=1 # needed to e.g. strip comments #export CCACHE_LOGFILE="$CCACHE_DIR.log" # In the chroot sandbox we need to wire the cccache-$arch out by using # the existing bind mount. We only do this, if we are not doing a # manual stage9 build ... if atstage native && [ "$ROCK_THIS_IS_CHROOT" ]; then mkdir -p $base/loop/build/$ccache_dir ln -snf ../loop/build/$ccache_dir $base/build/$ccache_dir fi # we instruct the flist wrapper to filter out ccache access, to # further reduce flist post processing time for big packages var_append FLWRAPPER_FILTERDIR ':' "$CCACHE_DIR" mkdir -p "$CCACHE_DIR" if [ "$SDECFG_PKG_CCACHE_CLEANUP" != 0 ]; then # we need to know if atime tests work or not echo > $CCACHE_DIR/.timestamp echo > $CCACHE_DIR/.timestamp-reference fi ccache -M $SDECFG_PKG_CCACHE_MAX > /dev/null # just using the CC_WRAPPER would not wrap KCC ... - thus we use GCC for C and C++ # and KCC for the kernel builds ... if ! atstage toolchain; then var_insert KCC_WRAPPER_OTHERS ":" "ccache" var_insert GCC_WRAPPER_OTHERS ":" "ccache" else var_insert SYSCC_WRAPPER_OTHERS ":" "ccache" fi eval "$(ccache -s -v | gawk 'BEGIN {hit=0} /[Hh]it/ { hit+=$2; } /[Mm]iss/ { miss=$2; } END { if (hit+miss == 0) print "x=0.00"; else printf "x=%.2f\n", hit*100 / (hit+miss); print "ccache_hit=" hit "; ccache_miss=" miss; }')" echo_status "Compiler Cache enabled: $x% cache hits so far" ccache_print_status_and_cleanup () { eval "$(ccache -s -v | gawk 'BEGIN {hit=0} /[Hh]it/ { hit+=$2; } /[Mm]iss/ { miss=$2; } END { hit-='$ccache_hit'; miss-='$ccache_miss'; if (hit+miss == 0) print "x=0.00"; else printf "x=%.2f\n", hit*100 / (hit+miss); print "ccache_hit=" hit "; ccache_miss=" miss; }')" echo_status "Compiler Cache Hits while pkg build: $x% (` `$ccache_hit hits, $ccache_miss misses)" if [ "$SDECFG_PKG_CCACHE_CLEANUP" != 0 ]; then # test if fs supports atime cat $CCACHE_DIR/.timestamp > /dev/null if [ "$(find $CCACHE_DIR/.timestamp -anewer $CCACHE_DIR/.timestamp-reference)" ] then if [ -f $root/var/adm/logs/$stagelevel-$xpkg.log ]; then # remove non-hits from the ccache cache ... # echo_status "Cleaning up ccache" find $CCACHE_DIR -type f ! -anewer $CCACHE_DIR/.timestamp-reference -a ! -name '*.stderr' | while read fn ;do rm -f $fn{,.stderr} 2>/dev/null done fi else echo_warning "No atime support available, ccache clean up not possible!" fi fi } hook_add finish 9 ccache_print_status_and_cleanup # last but not least make sure the package does not depend on ccache var_append flistrfilter "|" ".*bin/ccache" fi fi