]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
gitlab: Enable improved ccache usage
authorAndrea Bolognani <abologna@redhat.com>
Mon, 30 Mar 2020 16:29:06 +0000 (18:29 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 15 Apr 2020 15:50:49 +0000 (17:50 +0200)
Setting CC="ccache cc" works in most cases, but sometimes it will
break the build: in particular, we have experienced issues in the
past with that approach when using cgo to build our Go bindings.

A more robust approach is to have a directory containing symlinks
from the compiler name to the ccache binary: in that case, ccache
itself will invoke the compiler, and the build system will be none
the wiser.

Since libvirt-ci commit 2563aebb6c5c, container images contain a
suitable symlink directory, so all that's needed to enable the new
approach is to add this directory to $PATH.

Since we're touching this anyway, we make a few more changes:
$CCACHE_DIR is no longer created manually, because ccache will
take care of creating it for us if it doesn't already exist; the
ccache setup is moved out of the job template and into
script_variables, removing unnecessary duplication; a limit is
set on the size of the cache (500 MB, which is twice the amount
used by a fresh build on my Fedora 31 machine).

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
.gitlab-ci.yml

index 3203434b99b600898c5d3fcdf917b878f2fd1470..99e7b510c757068162f1eb7a1a5e276bd3c98dbc 100644 (file)
@@ -8,6 +8,10 @@ stages:
 
 .script_variables: &script_variables |
   export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"
+  export CCACHE_BASEDIR="$(pwd)"
+  export CCACHE_DIR="$CCACHE_BASEDIR/ccache"
+  export CCACHE_MAXSIZE="500M"
+  export PATH="$CCACHE_WRAPPERSDIR:$PATH"
 
 # Common templates
 
@@ -20,10 +24,6 @@ stages:
     key: "$CI_JOB_NAME"
   before_script:
     - *script_variables
-    - mkdir -p ccache
-    - export CC="ccache gcc"
-    - export CCACHE_BASEDIR=${PWD}
-    - export CCACHE_DIR=${PWD}/ccache
   script:
     - mkdir build
     - cd build
@@ -48,10 +48,6 @@ stages:
     key: "$CI_JOB_NAME"
   before_script:
     - *script_variables
-    - mkdir -p ccache
-    - export CC="ccache ${ABI}-gcc"
-    - export CCACHE_BASEDIR=${PWD}
-    - export CCACHE_DIR=${PWD}/ccache
   script:
     - mkdir build
     - cd build