From b25271b65262f70d849a4861da216c9be6c54d53 Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Thu, 6 Dec 2018 18:55:29 -0800 Subject: ccache.bbclass: Refactor it to make it more reliable The previous ccache.bbclass has the following problems: - It uses host's ccache for native recipes, but this may not work on some hosts, for example, it nerver works on my Ubuntu 14.04.4, there are always build failures (m4-native failed at do_configure, and others will also be failed if I disable CCACHE for m4-native) - native/nativesdk/cross/crosssdk recipes use host's ccache, but target uses ccache-native, this may confuse user. - The target recipes may use both host's ccache and ccache-native, this may cause unexpected problems and be hard to debug. This is because ccache-native is in SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS, so ccache-native may not be present when rebuild target recipes, and then it would use hosttools/ccache, but the previous ccache files were generated by ccache-native. - Target recipes can't use ccache when no ccache is installed on the host: CCACHE = "${@bb.utils.which(d.getVar('PATH'), 'ccache') and 'ccache '}" After refactored: All types recipes (native, target and others) will use ccache-native except ccache-native itself, host's cache won't be used any more. It is more reliable now, which will work everywhere when ccache-native can be built. And now we need use "CCACHE_DISABLE = '1'" to disable ccache for the recipe rather than "CCACHE = ''" since we set CCACHE in anonymous function, and d.getVar('CCACHE') works after "CCACHE ??=" which is set in bitbake.conf, so we can't check whether CCACHE is set or not in anonymous function since it is always set. Use CCACHE_DISABLE to disable it would be more clear. Signed-off-by: Robert Yang --- meta/conf/bitbake.conf | 6 +----- meta/conf/layer.conf | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'meta/conf') diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index 68700e9e7c..30bb35c2af 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -492,7 +492,7 @@ HOSTTOOLS += " \ HOSTTOOLS += "${@'ip ping ps scp ssh stty' if (bb.utils.contains_any('IMAGE_CLASSES', 'testimage testsdk', True, False, d) or any(x in (d.getVar("BBINCLUDED") or "") for x in ["testimage.bbclass", "testsdk.bbclass"])) else ''}" # Link to these if present -HOSTTOOLS_NONFATAL += "aws ccache gcc-ar gpg ld.bfd ld.gold nc pigz sftp socat ssh sudo" +HOSTTOOLS_NONFATAL += "aws gcc-ar gpg ld.bfd ld.gold nc pigz sftp socat ssh sudo" # Temporary add few more detected in bitbake world HOSTTOOLS_NONFATAL += "join nl size yes zcat" @@ -504,10 +504,6 @@ HOSTTOOLS_NONFATAL += "bzr" HOSTTOOLS_NONFATAL += "scp" CCACHE ??= "" -# ccache < 3.1.10 will create CCACHE_DIR on startup even if disabled, and -# autogen sets HOME=/dev/null so in certain situations builds can fail. -# Explicitly export CCACHE_DIR until we can assume ccache >3.1.10 on the host. -export CCACHE_DIR ??= "${@os.getenv('HOME')}/.ccache" TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_TARGET}" diff --git a/meta/conf/layer.conf b/meta/conf/layer.conf index 7afccdf335..12e3956651 100644 --- a/meta/conf/layer.conf +++ b/meta/conf/layer.conf @@ -49,7 +49,6 @@ SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \ *->quilt-native \ *->subversion-native \ *->git-native \ - *->ccache-native \ *->icecc-create-env-native \ gcc-cross-${TARGET_ARCH}->linux-libc-headers \ ppp-dialin->ppp \ -- cgit 1.2.3-korg