CCACHE_BUILD: Allow setting CCACHE_BUILD_TYPE=wrapper.

This uses the /usr/local/libexec/ccache/<cc,c++> wrappers rather than
modifying CC to be '/usr/local/bin/ccache cc'.  Some forms of compilation
do not support the 'command' type.

Sponsored by:	Dell EMC Isilon
This commit is contained in:
Bryan Drewery 2017-08-01 16:15:08 +00:00
parent 6f4c1b61b2
commit e2a659ea64

View File

@ -31,6 +31,9 @@ __<bsd.compiler.mk>__:
.include <bsd.opts.mk>
# command = /usr/local/bin/ccache cc ...
# wrapper = /usr/local/libexec/ccache/cc ...
CCACHE_BUILD_TYPE?= command
# Handle ccache after CC is determined, but not if CC/CXX are already
# overridden with a manual setup.
.if ${MK_CCACHE_BUILD:Uno} == "yes" && \
@ -65,19 +68,23 @@ CCACHE_COMPILERCHECK?= content
CCACHE_COMPILERCHECK?= mtime
.endif
.export CCACHE_COMPILERCHECK
# Remove ccache from the PATH to prevent double calls and wasted CPP/LD time.
PATH:= ${PATH:C,:?${CCACHE_WRAPPER_PATH}(/world)?(:$)?,,g}
# Ensure no bogus CCACHE_PATH leaks in which might avoid the in-tree compiler.
.if !empty(CCACHE_PATH)
CCACHE_PATH=
.export CCACHE_PATH
.endif
.if ${CCACHE_BUILD_TYPE} == "command"
# Remove ccache from the PATH to prevent double calls and wasted CPP/LD time.
PATH:= ${PATH:C,:?${CCACHE_WRAPPER_PATH}(/world)?(:$)?,,g}
# Override various toolchain vars.
.for var in CC CXX HOST_CC HOST_CXX
.if defined(${var}) && ${${var}:M${CCACHE_BIN}} == ""
${var}:= ${CCACHE_BIN} ${${var}}
.endif
.endfor
.elif empty(PATH:M*${CCACHE_WRAPPER_PATH}*)
PATH:= ${CCACHE_WRAPPER_PATH}:${PATH}
.endif # ${CCACHE_BUILD_TYPE} == "command"
# GCC does not need the CCACHE_CPP2 hack enabled by default in devel/ccache.
# The port enables it due to ccache passing preprocessed C to clang
# which fails with -Wparentheses-equality, -Wtautological-compare, and