Add ccache support (#3761)

If the user sets "ccache: true" in spack's config.yaml, Spack will use an available
ccache executable when compiling c/c++ code. This feature is disabled by default
(i.e. "ccache: false") and the documentation is updated with how to enable
ccache support
This commit is contained in:
Christoph Junghans
2018-07-09 15:06:10 -06:00
committed by scheibelp
parent 8770957b7a
commit 8bc3f7d726
5 changed files with 41 additions and 1 deletions

10
lib/spack/env/cc vendored
View File

@@ -342,7 +342,15 @@ case "$mode" in
args=("${args[@]}" ${SPACK_LDLIBS[@]}) ;;
esac
full_command=("$command" "${args[@]}")
#ccache only supports C languages, so filtering out Fortran
if [[ ( ${lang_flags} = "C" || ${lang_flags} = "CXX" ) && ${SPACK_CCACHE_BINARY} ]]; then
full_command=("${SPACK_CCACHE_BINARY}" "$command" "${args[@]}")
# #3761#issuecomment-294352232
# workaround for stage being a temp folder
export CCACHE_NOHASHDIR=yes
else
full_command=("$command" "${args[@]}")
fi
# In test command mode, write out full command for Spack tests.
if [[ $SPACK_TEST_COMMAND == dump-args ]]; then