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.

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