On Thu, Nov 09, 2023 at 07:26:41PM +0100, Caspar Schutijser wrote: > On Thu, Nov 09, 2023 at 05:54:33PM +0100, Caspar Schutijser wrote: > > Hi all, > > > > Below is a diff for bsd.port.mk that allows us to set USE_SCCACHE=Yes > > in /etc/mk.conf to use sccache. Manual page updates are included, > > which I copied and adapted from the ccache bits. > > > > Note that with the diff below, sccache is only used for Rust code, > > not for C/C++ (which sccache also supports). So at least at this > > moment, USE_CCACHE=Yes and USE_SCCACHE=Yes don't bite each other > > (ccache will cache C/C++ compilation results, sccache will cache > > Rust compilation results). This may change later if we want to use > > sccache for C/C++ too, which at the moment does not work yet. > > > > Another thing to note is that sccache uses a client-server model; > > quote from the README: > > > > > sccache works using a client-server model, where the server runs > > > locally on the same machine as the client. The client-server model > > > allows the server to be more efficient by keeping some state in > > > memory. The sccache command will spawn a server process if one is > > > not already running, or you can run sccache --start-server to start > > > the background server process without performing any compilation. > > > > > > You can run sccache --stop-server to terminate the server. It will > > > also terminate after (by default) 10 minutes of inactivity. > > > > So don't be surprised if a sccache process is still running when > > you hit ^C on the compilation process. > > > > I have used this now for quite some time and I didn't find any > > problems so far. Comments or OKs? > > > > First follows the diff for bsd.port.mk, and after that the diff for > > its manual page. > > Here is an updated diff. kn@ made good point: a "normal" user may > use sccache too, but then that user would end up using _pbuild's > instance of sccache because sccache communicates over TCP and by > default uses port 4226 (or the other way around, whichever starts the > sccache server first). I picked 44226 as the port number that we'll > use for bsd.port.mk. I don't think we need to document this. > Unfortunately there's no way to communicate over a socket, which > I would have preferred over using TCP for this.
That makes sense, thanks. > > Comments or OKs on this version? OK kn, but I'd also add blank lines around the ccache and sccache blocks. > > Caspar > > > Index: bsd.port.mk > =================================================================== > RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v > retrieving revision 1.1630 > diff -u -p -r1.1630 bsd.port.mk > --- bsd.port.mk 26 Oct 2023 19:26:56 -0000 1.1630 > +++ bsd.port.mk 9 Nov 2023 18:25:52 -0000 here between MAKE_FLAGS += ... NO_CCACHE ?= no ... > @@ -228,6 +228,7 @@ PARALLEL_MAKE_FLAGS ?= -j${MAKE_JOBS} > TRY_BROKEN ?= No > > USE_CCACHE ?= No > +USE_SCCACHE ?= No > > WARNINGS ?= no > > @@ -446,6 +447,17 @@ CONFIGURE_ENV += CCACHE_DIR=${CCACHE_DIR > COMPILER_WRAPPER += env CCACHE_DIR=${CCACHE_DIR} ${CCACHE_ENV} ccache > . if !exists(${LOCALBASE}/bin/ccache) > ERRORS += "Fatal: USE_CCACHE is set, but ccache is not installed." > +. endif > +.endif and here. > +NO_SCCACHE ?= No > +SCCACHE_ENV ?= > +.if ${USE_SCCACHE:L} == "yes" && ${NO_SCCACHE:L} == "no" && ${NO_BUILD:L} == > "no" > +SCCACHE_DIR ?= ${WRKOBJDIR_${PKGPATH}}/.sccache > +MAKE_ENV += SCCACHE_SERVER_PORT=44226 SCCACHE_DIR=${SCCACHE_DIR} > ${SCCACHE_ENV} > +MAKE_ENV += RUSTC_WRAPPER=${LOCALBASE}/bin/sccache > +CONFIGURE_ENV += SCCACHE_SERVER_PORT=44226 SCCACHE_DIR=${SCCACHE_DIR} > +. if !exists(${LOCALBASE}/bin/sccache) > +ERRORS += "Fatal: USE_SCCACHE is set, but sccache is not installed." > . endif > .endif > >