Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Oct 2015 15:32:41 +0200
From:      Juan =?iso-8859-1?b?UmFt824=?= Molina Menor <listjm@club.fr>
To:        freebsd-current@freebsd.org
Subject:   [CFT] Buildworld ccache support
Message-ID:  <56264279.7020504@club.fr>

next in thread | raw e-mail | index | archive | help
Hi!

I’m certainly doing it wrong, because CCACHE does not kick in after 
applying the patch and modifying make.conf. CCACHE stats ('ccache -z' 
followed by 'ccache -s') remain at zero during buildworld while they 
used to reflect the cache miss/hits before.

# cat /etc/make.conf
WITH_CCACHE_BUILD=

  # svn diff /usr/src/share/mk/local.init.mk
Index: /usr/src/share/mk/local.init.mk
===================================================================
--- /usr/src/share/mk/local.init.mk     (revision 289627)
+++ /usr/src/share/mk/local.init.mk     (working copy)
@@ -38,3 +38,37 @@
  HOST_CFLAGS+= -DHOSTPROG
  CFLAGS+= ${HOST_CFLAGS}
  .endif
+
+# Handle ccache after CC is determined.  If CC is at some specific path 
then
+# we must prepend the ccache wrapper.  Otherwise we can just prepend 
PATH with
+# the wrapper location, which is a more safe solution since it avoids 
spaces
+# and compiler type guessing based on filename.
+LOCALBASE?=            /usr/local
+CCACHE_WRAPPER_PATH?=  ${LOCALBASE}/libexec/ccache
+CCACHE_PATH?=          ${LOCALBASE}/bin/ccache
+.if defined(WITH_CCACHE_BUILD) && !defined(NOCCACHE) && \
+    ${CC:M*ccache*} == "" && exists(${CCACHE_PATH})
+# Handle compiler changes properly.  This avoids needing to use the 'world'
+# wrappers.
+CCACHE_COMPILERCHECK?= content
+.export CCACHE_COMPILERCHECK
+.if ${CC:M/*} == ""
+# Can use PATH.
+PATH:= ${CCACHE_WRAPPER_PATH}:${PATH}
+.export PATH
+.else
+# Must prepend CC.
+CC:=           ${CCACHE_PATH} ${CC}
+CXX:=          ${CCACHE_PATH} ${CXX}
+CPP:=          ${CCACHE_PATH} ${CPP}
+.if defined(HOST_CC)
+HOST_CC:=      ${CCACHE_PATH} ${HOST_CC}
+.endif
+.if defined(HOST_CXX)
+HOST_CXX:=     ${CCACHE_PATH} ${HOST_CXX}
+.endif
+.if defined(HOST_CPP)
+HOST_CPP:=     ${CCACHE_PATH} ${HOST_CPP}
+.endif
+.endif
+.endif # WITH_CCACHE_BUILD

If I recover the old make.conf, CCACHE works again for a buildworld.

# cat /etc/make.conf.old
.if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*))
.if !defined(NOCCACHE) && exists(/usr/local/libexec/ccache/world/cc)
CC:=${CC:C,^cc,/usr/local/libexec/ccache/world/cc,1}
CXX:=${CXX:C,^c\+\+,/usr/local/libexec/ccache/world/c++,1}
.endif
.endif

Maybe I misconfigured CCACHE when I first installed it?

Best regards,
Juan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56264279.7020504>