Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2025 05:45:20 GMT
From:      Li-Wen Hsu <lwhsu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 10cb3979a9bd - main - share/mk: Add sccache suport for WITH_CCACHE_BUILD option
Message-ID:  <202506200545.55K5jKnJ035252@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by lwhsu:

URL: https://cgit.FreeBSD.org/src/commit/?id=10cb3979a9bde6c8e441e3ba4aa5fd09963c484f

commit 10cb3979a9bde6c8e441e3ba4aa5fd09963c484f
Author:     SHENGYI HONG <aokblast@FreeBSD.org>
AuthorDate: 2025-06-20 05:37:23 +0000
Commit:     Li-Wen Hsu <lwhsu@FreeBSD.org>
CommitDate: 2025-06-20 05:43:48 +0000

    share/mk: Add sccache suport for WITH_CCACHE_BUILD option
    
    By setting CCACHE_NAME=sccache , sccache can be used as an alternative
    for ccache.
    
    Reviewed by:    emaste, jhb
    Event:          Kitchener-Waterloo Hackathon 202506
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D49417
---
 share/mk/bsd.compiler.mk              | 12 +++++++++++-
 tools/build/options/WITH_CCACHE_BUILD |  7 +++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk
index 2babccf91df1..a877b18d3b9a 100644
--- a/share/mk/bsd.compiler.mk
+++ b/share/mk/bsd.compiler.mk
@@ -66,9 +66,10 @@ CCACHE_BUILD_TYPE?=	command
 # PATH since it is more clear that ccache is used and avoids wasting time
 # for mkdep/linking/asm builds.
 LOCALBASE?=		/usr/local
+CCACHE_NAME?=		ccache
 CCACHE_PKG_PREFIX?=	${LOCALBASE}
 CCACHE_WRAPPER_PATH?=	${CCACHE_PKG_PREFIX}/libexec/ccache
-CCACHE_BIN?=		${CCACHE_PKG_PREFIX}/bin/ccache
+CCACHE_BIN?=		${CCACHE_PKG_PREFIX}/bin/${CCACHE_NAME}
 .if exists(${CCACHE_BIN})
 # Export to ensure sub-makes can filter it out for mkdep/linking and
 # to chain down into kernel build which won't include this file.
@@ -122,7 +123,12 @@ CCACHE_NOCPP2=	1
 .endif
 # Canonicalize CCACHE_DIR for meta mode usage.
 .if !defined(CCACHE_DIR)
+.if !empty(CCACHE_BIN:M*sccache)
+# Get the temp directory and remove beginning and trailing \"
+CCACHE_DIR!=	${CCACHE_BIN} -s | awk '$$2 == "location" && $$3 == "Local" {print substr($$5, 2, length($$5) - 2)}'
+.else
 CCACHE_DIR!=	${CCACHE_BIN} -p | awk '$$2 == "cache_dir" {print $$4}'
+.endif
 .export CCACHE_DIR
 .endif
 .if !empty(CCACHE_DIR) && empty(.MAKE.META.IGNORE_PATHS:M${CCACHE_DIR})
@@ -134,7 +140,11 @@ CCACHE_DIR:=	${CCACHE_DIR:tA}
 # comparisons.
 .MAKE.META.IGNORE_PATHS+= ${CCACHE_BIN}
 ccache-print-options: .PHONY
+.if !empty(CCACHE_BIN:M*sccache)
+	@${CCACHE_BIN} -s
+.else
 	@${CCACHE_BIN} -p
+.endif	# !empty(CCACHE_BIN:M*sccache)
 .endif	# exists(${CCACHE_BIN})
 .endif	# ${MK_CCACHE_BUILD} == "yes"
 
diff --git a/tools/build/options/WITH_CCACHE_BUILD b/tools/build/options/WITH_CCACHE_BUILD
index 9e53769287e5..9a5c2ce1cb80 100644
--- a/tools/build/options/WITH_CCACHE_BUILD
+++ b/tools/build/options/WITH_CCACHE_BUILD
@@ -3,11 +3,18 @@ Use
 for the build.
 No configuration is required except to install the
 .Sy devel/ccache
+or
+.Sy devel/sccache
 package.
 When using with
 .Xr distcc 1 ,
 set
 .Sy CCACHE_PREFIX=/usr/local/bin/distcc .
+When using with sccache
+set
+.Sy CCACHE_NAME=sccache
+in
+.Xr src.conf 5 .
 The default cache directory of
 .Pa $HOME/.ccache
 will be used, which can be overridden by setting



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