OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
4.0 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../ccache/parse-config
  5. # Copyright (C) 2006 - 2007 The OpenSDE Project
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. if [ "$SDECFG_PKG_CCACHE_USEIT" != 1 ]; then
  16. true # skip
  17. elif [ -z "`type -p ccache`" ]; then
  18. echo_warning 'ccache not available, Compiler Cache disabled.'
  19. elif [ "$pkg" == gcc ]; then
  20. echo_warning 'Package incompatible with Compiler Cache, disabled.'
  21. else
  22. unset ${!CCACHE_*}
  23. # wrap the sytem compiler
  24. ccache_dir=ccache
  25. if atstage toolchain; then
  26. x=`/bin/uname -m | uname2arch`
  27. var_append ccache_dir - $x
  28. fi
  29. var_append ccache_dir - $arch
  30. # do not trash the cache with feature-less built packages
  31. [ $stagelevel -le 2 ] && var_append ccache_dir - $stagelevel
  32. export CCACHE_DIR="$base/build/$ccache_dir/$pkg"
  33. export CCACHE_DONT_STAT_COMPILER=1
  34. export CCACHE_UNIFY=1 # needed to e.g. strip comments
  35. #export CCACHE_LOGFILE="$CCACHE_DIR.log"
  36. # In the chroot sandbox we need to wire the cccache-$arch out by using
  37. # the existing bind mount. We only do this, if we are not doing a
  38. # manual stage9 build ...
  39. if atstage native && [ "$ROCK_THIS_IS_CHROOT" ]; then
  40. mkdir -p $base/loop/build/$ccache_dir
  41. ln -snf ../loop/build/$ccache_dir $base/build/$ccache_dir
  42. fi
  43. # we instruct the flist wrapper to filter out ccache access, to
  44. # further reduce flist post processing time for big packages
  45. var_append FLWRAPPER_FILTERDIR ':' "$CCACHE_DIR"
  46. mkdir -p "$CCACHE_DIR"
  47. if [ "$SDECFG_PKG_CCACHE_CLEANUP" != 0 ]; then
  48. # we need to know if atime tests work or not
  49. echo > $CCACHE_DIR/.timestamp
  50. echo > $CCACHE_DIR/.timestamp-reference
  51. fi
  52. ccache -M ${SDECFG_PKG_CCACHE_MAX:-1000M} > /dev/null
  53. # just using the CC_WRAPPER would not wrap KCC ... - thus we use GCC for C and C++
  54. # and KCC for the kernel builds ...
  55. if ! atstage toolchain; then
  56. var_insert KCC_WRAPPER_OTHERS ":" "ccache"
  57. var_insert GCC_WRAPPER_OTHERS ":" "ccache"
  58. else
  59. var_insert SYSCC_WRAPPER_OTHERS ":" "ccache"
  60. fi
  61. eval "$( ccache -s | gawk '/cache hit/ { hit=$3; }
  62. /cache miss/ { miss=$3; }
  63. END { if (hit+miss == 0) print "x=0.00";
  64. else printf "x=%.2f\n", hit*100 / (hit+miss);
  65. print "ccache_hit=" hit "; ccache_miss=" miss; }' )"
  66. y=$( du -sh "$CCACHE_DIR" | cut -f1 )
  67. echo_status "Compiler Cache enabled: $x% ($y) cache hits so far."
  68. ccache_print_status() {
  69. eval "$( ccache -s | gawk '/cache hit/ { hit=$3-'$ccache_hit'; }
  70. /cache miss/ { miss=$3-'$ccache_miss'; }
  71. END { if (hit+miss == 0) print "x=0.00";
  72. else printf "x=%.2f\n", hit*100 / (hit+miss);
  73. print "ccache_hit=" hit "; ccache_miss=" miss; }' )"
  74. y=$( du -sh "$CCACHE_DIR" | cut -f1 )
  75. echo_status "Compiler Cache Hits while pkg build: $x% (`
  76. `$ccache_hit hits, $ccache_miss misses, $y)"
  77. if [ "$SDECFG_PKG_CCACHE_CLEANUP" != 0 -a -f "$root/var/adm/logs/$stagelevel-$xpkg.log" ]; then
  78. # test if fs supports atime
  79. cat $CCACHE_DIR/.timestamp > /dev/null
  80. if [ "$( find $CCACHE_DIR/.timestamp -anewer $CCACHE_DIR/.timestamp-reference )" ]
  81. then
  82. # remove non-hits from the ccache cache ...
  83. #
  84. find $CCACHE_DIR -type f ! -anewer $CCACHE_DIR/.timestamp-reference -a ! -name '*.stderr' |
  85. while read fn ;do
  86. rm -f $fn{,.stderr} 2>/dev/null
  87. done
  88. echo_status "Compiler Cache reduced to $( du -sh "$CCACHE_DIR" | cut -f1 )."
  89. else
  90. echo_warning "No atime support available, Compiler Cache clean up not possible."
  91. fi
  92. fi
  93. }
  94. hook_add finish 9 ccache_print_status
  95. # last but not least make sure the package does not depend on ccache
  96. var_append flistrfilter "|" ".*bin/ccache$"
  97. fi