Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Jul 2026 07:39:21 +0000
From:      Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Cc:        SHENGYI HONG <aokblast@FreeBSD.org>
Subject:   git: cd2c1451dc17 - stable/14 - share/mk: Add sccache suport for WITH_CCACHE_BUILD option
Message-ID:  <6a549629.25ba8.23a2aced@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by des:

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

commit cd2c1451dc17520fc2cb8939fa8d8b1d3f9508e8
Author:     SHENGYI HONG <aokblast@FreeBSD.org>
AuthorDate: 2025-06-20 05:37:23 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-07-13 07:29:11 +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
    
    (cherry picked from commit 10cb3979a9bde6c8e441e3ba4aa5fd09963c484f)
---
 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 fd236b2e6b8f..b6a9a3586cc9 100644
--- a/share/mk/bsd.compiler.mk
+++ b/share/mk/bsd.compiler.mk
@@ -64,9 +64,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.
@@ -120,7 +121,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})
@@ -132,7 +138,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


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a549629.25ba8.23a2aced>