From e053e08717ab26d0e75d7d5ae144be86431e8871 Mon Sep 17 00:00:00 2001 From: Artur Sinila Date: Thu, 6 May 2021 11:31:58 +0300 Subject: [PATCH] xbps-src: add sccache support --- README.md | 25 ++++++++++++++++++++++++- common/build-helper/rust.sh | 4 ++++ common/xbps-src/shutils/chroot.sh | 2 +- etc/defaults.conf | 8 ++++++++ srcpkgs/base-chroot/template | 4 ++-- xbps-src | 10 +++++++++- 6 files changed, 48 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 315e6858bfaf..6874991c08ca 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ See [Contributing](./CONTRIBUTING.md) for a general overview of how to contribut - [Package build options](#build-options) - [Sharing and signing your local repositories](#sharing-and-signing) - [Rebuilding and overwriting existing local packages](#rebuilding) +- [Enabling ccache for caching C and C++ compilation](#ccache) +- [Enabling sccache for caching Rust compilation](#sccache) - [Enabling distcc for distributed compilation](#distcc) - [Distfiles mirrors](#distfiles-mirrors) - [Cross compiling packages for a target architecture](#cross-compiling) @@ -201,6 +203,7 @@ The following directory hierarchy is used with a default configuration file: |- hostdir | |- binpkgs ... | |- ccache ... + | |- sccache ... | |- distcc- ... | |- repocache ... | |- sources ... @@ -218,6 +221,7 @@ The description of these directories is as follows: - `builddir`: to unpack package source tarballs and where packages are built. - `destdir`: to install packages, aka **fake destdir**. - `hostdir/ccache`: to store ccache data if the `XBPS_CCACHE` option is enabled. + - `hostdir/sccache`: to store sccache data if the `XBPS_SCCACHE` option is enabled. - `hostdir/distcc-`: to store distcc data if the `XBPS_DISTCC` option is enabled. - `hostdir/repocache`: to store binary packages from remote repositories. - `hostdir/sources`: to store package sources. @@ -344,6 +348,25 @@ Reinstalling this package in your target `rootdir` can be easily done too: > Please note that the `package expression` must be properly defined to explicitly pick up the package from the desired repository. + + +### Enabling ccache for caching C and C++ compilation + +Add this line to `void-packages/etc/conf` file: + + XBPS_CCACHE=yes + + +### Enabling sccache for caching Rust compilation + +Install `rust-sccache` into `void-packages/masterdir/`: + + xbps-install -r masterdir/ rust-sccache + +Add this line to `void-packages/etc/conf` file: + + XBPS_SCCACHE=yes + ### Enabling distcc for distributed compilation @@ -443,7 +466,7 @@ The default masterdir is created in the current working directory, i.e `void-pac ### Remaking the masterdir -If for some reason you must update xbps-src and the `bootstrap-update` target is not enough, it's possible to recreate a masterdir with two simple commands (please note that `zap` keeps your `ccache/distcc/host` directories intact): +If for some reason you must update xbps-src and the `bootstrap-update` target is not enough, it's possible to recreate a masterdir with two simple commands (please note that `zap` keeps your `ccache/sccache/distcc/host` directories intact): $ ./xbps-src zap $ ./xbps-src binary-bootstrap diff --git a/common/build-helper/rust.sh b/common/build-helper/rust.sh index 431cb5f0fd43..994a66916b26 100644 --- a/common/build-helper/rust.sh +++ b/common/build-helper/rust.sh @@ -4,6 +4,10 @@ export CARGO_BUILD_JOBS="$XBPS_MAKEJOBS" export CARGO_HOME="/host/cargo" +if [ "$XBPS_SCCACHE" = "yes" ]; then + export RUSTC_WRAPPER="sccache" +fi + if [ "$CROSS_BUILD" ]; then # Define equivalent of TOML config in environment # [target.${RUST_TARGET}] diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh index c7ada3151618..735dcfebd12f 100644 --- a/common/xbps-src/shutils/chroot.sh +++ b/common/xbps-src/shutils/chroot.sh @@ -88,7 +88,7 @@ PATH=/void-packages:/usr/bin exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DISTCC_DIR="/host/distcc" \ ${XBPS_ARCH+XBPS_ARCH=$XBPS_ARCH} ${XBPS_CHECK_PKGS+XBPS_CHECK_PKGS=$XBPS_CHECK_PKGS} \ - CCACHE_DIR="/host/ccache" IN_CHROOT=1 LC_COLLATE=C LANG=en_US.UTF-8 TERM=linux HOME="/tmp" \ + CCACHE_DIR="/host/ccache" SCCACHE_DIR="/host/sccache" IN_CHROOT=1 LC_COLLATE=C LANG=en_US.UTF-8 TERM=linux HOME="/tmp" \ PS1="[\u@$XBPS_MASTERDIR \W]$ " /bin/bash +h _EOF diff --git a/etc/defaults.conf b/etc/defaults.conf index 6147954a18af..5ab84a8eacc8 100644 --- a/etc/defaults.conf +++ b/etc/defaults.conf @@ -50,6 +50,14 @@ XBPS_SUCMD="sudo /bin/sh -c" # #XBPS_CCACHE=yes +# [OPTIONAL] +# Enable or disable sccache when building packages. The sccache directory +# is stored in the hostdir, i.e hostdir/sccache. In order to use sccache, +# you should install it by running `xbps-install -r masterdir/ rust-sccache` +# in the root directory of `void-packages` repository +# +#XBPS_SCCACHE=yes + # [OPTIONAL] # Enable or disable distcc when building packages. The distcc directory # is stored in the hostdir, i.e hostdir/distcc. diff --git a/srcpkgs/base-chroot/template b/srcpkgs/base-chroot/template index 78f6d0cc2a1d..5f139acbbbac 100644 --- a/srcpkgs/base-chroot/template +++ b/srcpkgs/base-chroot/template @@ -1,7 +1,7 @@ # Template file for 'base-chroot' pkgname=base-chroot -version=0.66 -revision=3 +version=0.67 +revision=1 bootstrap=yes build_style=meta short_desc="Minimal set of packages required for chroot with xbps-src" diff --git a/xbps-src b/xbps-src index c3cd7e5db10b..d387b7a890d6 100755 --- a/xbps-src +++ b/xbps-src @@ -629,7 +629,7 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \ XBPS_CMPVER_CMD XBPS_FETCH_CMD XBPS_VERSION XBPS_BUILDSTYLEDIR \ XBPS_CPPFLAGS XBPS_CFLAGS XBPS_CXXFLAGS XBPS_FFLAGS XBPS_LDFLAGS \ XBPS_MAKEJOBS XBPS_BUILD_FORCEMODE XBPS_USE_GIT_REVS XBPS_DEBUG_PKGS \ - XBPS_CHECK_PKGS XBPS_CCACHE XBPS_DISTCC XBPS_DISTCC_HOSTS XBPS_SKIP_DEPS \ + XBPS_CHECK_PKGS XBPS_CCACHE XBPS_SCCACHE XBPS_DISTCC XBPS_DISTCC_HOSTS XBPS_SKIP_DEPS \ XBPS_SKIP_REMOTEREPOS XBPS_CROSS_BUILD XBPS_ARG_PKG_OPTIONS XBPS_CONFIG_FILE \ XBPS_KEEP_ALL XBPS_HOSTDIR XBPS_MASTERDIR XBPS_SRC_VERSION \ XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \ @@ -672,6 +672,14 @@ if [ "$XBPS_CCACHE" ]; then mkdir -p $CCACHE_DIR fi +# +# Set up sccache +# +if [ "$XBPS_SCCACHE" ]; then + export SCCACHE_DIR="$XBPS_HOSTDIR/sccache" + mkdir -p $SCCACHE_DIR +fi + # # Set up distcc #