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.

116 lines
4.1 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 'Compiler cache disabled! (ccache not available)'
  19. elif [ "$pkg" == gcc ]; then
  20. echo_warning 'Compiler cache disabled! (package incompatible)'
  21. elif [ "$SDECFG_DEBUG" == 1 ]; then
  22. echo_warning 'Compiler cache disabled! (package build with debug symbols)'
  23. else
  24. unset ${!CCACHE_*}
  25. # wrap the sytem compiler
  26. ccache_dir=ccache
  27. if atstage toolchain; then
  28. x=`/bin/uname -m | uname2arch`
  29. var_append ccache_dir - $x
  30. fi
  31. var_append ccache_dir - $arch
  32. # do not trash the cache with feature-less built packages
  33. [ $stagelevel -le 2 ] && var_append ccache_dir - $stagelevel
  34. export CCACHE_DIR="$base/build/$ccache_dir/$pkg"
  35. export CCACHE_DONT_STAT_COMPILER=1
  36. export CCACHE_UNIFY=1 # needed to e.g. strip comments
  37. #export CCACHE_LOGFILE="$CCACHE_DIR.log"
  38. # In the chroot sandbox we need to wire the cccache-$arch out by using
  39. # the existing bind mount. We only do this, if we are not doing a
  40. # manual stage9 build ...
  41. if atstage native && [ "$ROCK_THIS_IS_CHROOT" ]; then
  42. mkdir -p $base/loop/build/$ccache_dir
  43. ln -snf ../loop/build/$ccache_dir $base/build/$ccache_dir
  44. fi
  45. # we instruct the flist wrapper to filter out ccache access, to
  46. # further reduce flist post processing time for big packages
  47. var_append FLWRAPPER_FILTERDIR ':' "$CCACHE_DIR"
  48. mkdir -p "$CCACHE_DIR"
  49. if [ "$SDECFG_PKG_CCACHE_CLEANUP" != 0 ]; then
  50. # we need to know if atime tests work or not
  51. echo > $CCACHE_DIR/.timestamp
  52. echo > $CCACHE_DIR/.timestamp-reference
  53. fi
  54. ccache -M ${SDECFG_PKG_CCACHE_MAX:-1000M} > /dev/null
  55. # just using the CC_WRAPPER would not wrap KCC ... - thus we use GCC for C and C++
  56. # and KCC for the kernel builds ...
  57. if ! atstage toolchain; then
  58. var_insert KCC_WRAPPER_OTHERS ":" "ccache"
  59. var_insert GCC_WRAPPER_OTHERS ":" "ccache"
  60. else
  61. var_insert SYSCC_WRAPPER_OTHERS ":" "ccache"
  62. fi
  63. eval "$( ccache -s | gawk '/cache hit/ { hit=$3; }
  64. /cache miss/ { miss=$3; }
  65. END { if (hit+miss == 0) print "x=0.00";
  66. else printf "x=%.2f\n", hit*100 / (hit+miss);
  67. print "ccache_hit=" hit "; ccache_miss=" miss; }' )"
  68. y=$( du -sh "$CCACHE_DIR" | cut -f1 )
  69. echo_status "Compiler Cache enabled: $x% ($y) cache hits so far"
  70. ccache_print_status() {
  71. eval "$( ccache -s | gawk '/cache hit/ { hit=$3-'$ccache_hit'; }
  72. /cache miss/ { miss=$3-'$ccache_miss'; }
  73. END { if (hit+miss == 0) print "x=0.00";
  74. else printf "x=%.2f\n", hit*100 / (hit+miss);
  75. print "ccache_hit=" hit "; ccache_miss=" miss; }' )"
  76. y=$( du -sh "$CCACHE_DIR" | cut -f1 )
  77. echo_status "Compiler Cache Hits while pkg build: $x% (`
  78. `$ccache_hit hits, $ccache_miss misses, $y)"
  79. if [ "$SDECFG_PKG_CCACHE_CLEANUP" != 0 -a -f "$root/var/adm/logs/$stagelevel-$xpkg.log" ]; then
  80. # test if fs supports atime
  81. cat $CCACHE_DIR/.timestamp > /dev/null
  82. if [ "$( find $CCACHE_DIR/.timestamp -anewer $CCACHE_DIR/.timestamp-reference )" ]
  83. then
  84. # remove non-hits from the ccache cache ...
  85. #
  86. find $CCACHE_DIR -type f ! -anewer $CCACHE_DIR/.timestamp-reference -a ! -name '*.stderr' |
  87. while read fn ;do
  88. rm -f $fn{,.stderr} 2>/dev/null
  89. done
  90. echo_status "Compiler Cache reduced to $( du -sh "$CCACHE_DIR" | cut -f1 )."
  91. else
  92. echo_warning "No atime support available, Compiler Cache clean up not possible."
  93. fi
  94. fi
  95. }
  96. hook_add finish 9 ccache_print_status
  97. # last but not least make sure the package does not depend on ccache
  98. var_append flistrfilter "|" ".*bin/ccache$"
  99. fi