diff mbox series

ccache: move environment variables to the configuration file

Message ID 20250716094954.866783-1-ross.burton@arm.com
State New
Headers show
Series ccache: move environment variables to the configuration file | expand

Commit Message

Ross Burton July 16, 2025, 9:49 a.m. UTC
Move some environment variables to the configuration file, so there's
less happening in the class.

Some changes were made as part of the move:
- max_size was removed so that the per-recipe caches don't grown without
  limit. The default cache is 5GB.
- compiler_check was extended to check both the specs and the version,
  so that a version change that doesn't affect the specs will still mean
  a recompile.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/classes/ccache.bbclass | 13 -------------
 meta/conf/ccache.conf       | 15 +++++++++++++--
 2 files changed, 13 insertions(+), 15 deletions(-)

Comments

Khem Raj July 17, 2025, 1:23 a.m. UTC | #1
On Wed, Jul 16, 2025 at 2:50 AM Ross Burton via lists.openembedded.org
<ross.burton=arm.com@lists.openembedded.org> wrote:
>
> Move some environment variables to the configuration file, so there's
> less happening in the class.
>
> Some changes were made as part of the move:
> - max_size was removed so that the per-recipe caches don't grown without
>   limit. The default cache is 5GB.
> - compiler_check was extended to check both the specs and the version,
>   so that a version change that doesn't affect the specs will still mean
>   a recompile.
>
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
>  meta/classes/ccache.bbclass | 13 -------------
>  meta/conf/ccache.conf       | 15 +++++++++++++--
>  2 files changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/meta/classes/ccache.bbclass b/meta/classes/ccache.bbclass
> index 2d6a3ea7229..5ce23e50f34 100644
> --- a/meta/classes/ccache.bbclass
> +++ b/meta/classes/ccache.bbclass
> @@ -42,23 +42,10 @@ CCACHE_NATIVE_RECIPES_ALLOWED ?= ""
>  # in different builds.
>  export CCACHE_BASEDIR ?= "${TMPDIR}"
>
> -# Used for sharing cache files after compiler is rebuilt
> -export CCACHE_COMPILERCHECK ?= "%compiler% -dumpspecs"
> -
>  export CCACHE_CONFIGPATH ?= "${COREBASE}/meta/conf/ccache.conf"
>
>  export CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${MULTIMACH_TARGET_SYS}/${PN}"
>
> -# Fixed errors:
> -# ccache: error: Failed to create directory /run/user/0/ccache-tmp: Permission denied
> -export CCACHE_TEMPDIR ?= "${CCACHE_DIR}/tmp"
> -
> -# We need to stop ccache considering the current directory or the
> -# debug-prefix-map target directory to be significant when calculating
> -# its hash. Without this the cache would be invalidated every time
> -# ${PV} or ${PR} change.
> -export CCACHE_NOHASHDIR ?= "1"
> -
>  python() {
>      """
>      Enable ccache for the recipe
> diff --git a/meta/conf/ccache.conf b/meta/conf/ccache.conf
> index 499e5327b8c..ea658708a1f 100644
> --- a/meta/conf/ccache.conf
> +++ b/meta/conf/ccache.conf
> @@ -1,7 +1,18 @@
> -max_size = 0
> -
>  # Avoid spurious cache misses caused by recipe sysroot creation: Creating a
>  # recipe sysroot hardlinks all dependent files into place. Hardlinking updates
>  # the file's ctime which in turn interferes with ccache's include_file_ctime
>  # check.
>  sloppiness = include_file_ctime
> +
> +# Only rebuild if the compiler version or specs have changed, as we rebuild
> +# compilers more than is usual.
> +compiler_check = %compiler% -dumpversion; %compiler% -dumpspecs

-dumpspecs is very gcc centric option and clang does not support it,
previously we overwrote CCACHE_COMPILERCHECK
in clang bbclass to something like %compiler% -v, how do we get
that parity with this approach ?

> +
> +# We need to stop ccache considering the current directory or the
> +# debug-prefix-map target directory to be significant when calculating
> +# its hash. Without this the cache would be invalidated every time
> +# ${PV} or ${PR} change.
> +hash_dir = false
> +
> +# If ccache runs under pseudo it will try to create files in /run/user/0/ccahe-tmp
> +temporary_dir = $CCACHE_DIR/tmp
> --
> 2.43.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#220443): https://lists.openembedded.org/g/openembedded-core/message/220443
> Mute This Topic: https://lists.openembedded.org/mt/114182159/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Ross Burton July 17, 2025, 12:14 p.m. UTC | #2
On 17 Jul 2025, at 02:23, Khem Raj <raj.khem@gmail.com> wrote:
>> +# Only rebuild if the compiler version or specs have changed, as we rebuild
>> +# compilers more than is usual.
>> +compiler_check = %compiler% -dumpversion; %compiler% -dumpspecs
> 
> -dumpspecs is very gcc centric option and clang does not support it,
> previously we overwrote CCACHE_COMPILERCHECK
> in clang bbclass to something like %compiler% -v, how do we get
> that parity with this approach ?

Ah.  I’ll drop that change for now.

Maybe we should just check the version and leave it at that?

Ross
Khem Raj July 17, 2025, 4:49 p.m. UTC | #3
On Thu, Jul 17, 2025 at 5:14 AM Ross Burton <Ross.Burton@arm.com> wrote:
>
> On 17 Jul 2025, at 02:23, Khem Raj <raj.khem@gmail.com> wrote:
> >> +# Only rebuild if the compiler version or specs have changed, as we rebuild
> >> +# compilers more than is usual.
> >> +compiler_check = %compiler% -dumpversion; %compiler% -dumpspecs
> >
> > -dumpspecs is very gcc centric option and clang does not support it,
> > previously we overwrote CCACHE_COMPILERCHECK
> > in clang bbclass to something like %compiler% -v, how do we get
> > that parity with this approach ?
>
> Ah.  I’ll drop that change for now.
>
> Maybe we should just check the version and leave it at that?

My hunch is that using
CCACHE_COMPILERCHECK=content
should be good and it will be faster than trying to find the version of compiler
because it will do gcc -v or clang -v for every compiler invocation which could
more expensive than doing a checksum on compiler binary content.

>
> Ross
diff mbox series

Patch

diff --git a/meta/classes/ccache.bbclass b/meta/classes/ccache.bbclass
index 2d6a3ea7229..5ce23e50f34 100644
--- a/meta/classes/ccache.bbclass
+++ b/meta/classes/ccache.bbclass
@@ -42,23 +42,10 @@  CCACHE_NATIVE_RECIPES_ALLOWED ?= ""
 # in different builds.
 export CCACHE_BASEDIR ?= "${TMPDIR}"
 
-# Used for sharing cache files after compiler is rebuilt
-export CCACHE_COMPILERCHECK ?= "%compiler% -dumpspecs"
-
 export CCACHE_CONFIGPATH ?= "${COREBASE}/meta/conf/ccache.conf"
 
 export CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${MULTIMACH_TARGET_SYS}/${PN}"
 
-# Fixed errors:
-# ccache: error: Failed to create directory /run/user/0/ccache-tmp: Permission denied
-export CCACHE_TEMPDIR ?= "${CCACHE_DIR}/tmp"
-
-# We need to stop ccache considering the current directory or the
-# debug-prefix-map target directory to be significant when calculating
-# its hash. Without this the cache would be invalidated every time
-# ${PV} or ${PR} change.
-export CCACHE_NOHASHDIR ?= "1"
-
 python() {
     """
     Enable ccache for the recipe
diff --git a/meta/conf/ccache.conf b/meta/conf/ccache.conf
index 499e5327b8c..ea658708a1f 100644
--- a/meta/conf/ccache.conf
+++ b/meta/conf/ccache.conf
@@ -1,7 +1,18 @@ 
-max_size = 0
-
 # Avoid spurious cache misses caused by recipe sysroot creation: Creating a
 # recipe sysroot hardlinks all dependent files into place. Hardlinking updates
 # the file's ctime which in turn interferes with ccache's include_file_ctime
 # check.
 sloppiness = include_file_ctime
+
+# Only rebuild if the compiler version or specs have changed, as we rebuild
+# compilers more than is usual.
+compiler_check = %compiler% -dumpversion; %compiler% -dumpspecs
+
+# We need to stop ccache considering the current directory or the
+# debug-prefix-map target directory to be significant when calculating
+# its hash. Without this the cache would be invalidated every time
+# ${PV} or ${PR} change.
+hash_dir = false
+
+# If ccache runs under pseudo it will try to create files in /run/user/0/ccahe-tmp
+temporary_dir = $CCACHE_DIR/tmp