[OE-core] [PATCH 2/4] ccache.bbclass: Refactor it to make it more reliable
Robert Yang
liezhi.yang at windriver.com
Thu Dec 13 02:47:53 UTC 2018
Hi Martin
On 12/10/18 4:55 PM, Martin Hundebøll wrote:
> Hi Robert,
>
> Just a small nit-pick below..
>
> On 10/12/2018 03.24, Robert Yang wrote:
>> 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 ccahe, 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 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 ccahe 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's dependencies, 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 ccahe 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 <liezhi.yang at windriver.com>
>> ---
>> meta/classes/ccache.bbclass | 25 ++++++++++++++++++++++---
>> meta/conf/bitbake.conf | 21 ++++++++++++++++-----
>> meta/conf/layer.conf | 1 -
>> meta/lib/oe/utils.py | 3 +++
>> meta/recipes-devtools/ccache/ccache.inc | 2 ++
>> 5 files changed, 43 insertions(+), 9 deletions(-)
>>
>
> <snip>
>
>> diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
>> index 8a584d6..9c41705 100644
>> --- a/meta/lib/oe/utils.py
>> +++ b/meta/lib/oe/utils.py
>> @@ -363,6 +363,9 @@ def host_gcc_version(d, taskcontextonly=False):
>> return
>> compiler = d.getVar("BUILD_CC")
>> + # Get rid of ccache since it is not present when parsing.
>> + if compiler.startswith('ccache '):
>> + compiler = compiler[7:]
>
> You can avoid the if-condition and hard-coded 7-value by doing:
>
> # Get rid of ccache since it is no present when parsing.
> compiler = d.getVar("BUILD_CC").lstrip("ccache-")
I'm afraid that this may not work, lstrip("ccache-") strips any characters
of 'ccache-' (c, a, h e -), which seems dangerous, and not what we want.
I've will revert it in V2's PULL.
// Robert
>
> // Martin
>
>> try:
>> env = os.environ.copy()
>> env["PATH"] = d.getVar("PATH")
>> diff --git a/meta/recipes-devtools/ccache/ccache.inc
>> b/meta/recipes-devtools/ccache/ccache.inc
>> index 6566328..259c196 100644
>> --- a/meta/recipes-devtools/ccache/ccache.inc
>> +++ b/meta/recipes-devtools/ccache/ccache.inc
>> @@ -9,6 +9,8 @@ LICENSE = "GPLv3+"
>> DEPENDS = "zlib"
>> +DEPENDS_class-native = "${CCACHE_NATIVE_DEPENDS}"
>> +
>> SRC_URI = "https://download.samba.org/pub/${BPN}/${BP}.tar.xz"
>> inherit autotools
>>
>
More information about the Openembedded-core
mailing list