summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2018-12-06 18:55:29 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-14 11:35:55 +0000
commit0c98ff2c31d462ea139ebf1a3e0dbd97088d5466 (patch)
tree34f52ca5fdc645585ee8f4a5ded9dc0273a00271 /meta
parent87413eb34a810f3c267f1185a4f2af211838530f (diff)
downloadpoky-0c98ff2c31d462ea139ebf1a3e0dbd97088d5466.tar.gz
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. (From OE-Core rev: b25271b65262f70d849a4861da216c9be6c54d53) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/ccache.bbclass25
-rw-r--r--meta/conf/bitbake.conf6
-rw-r--r--meta/conf/layer.conf1
-rw-r--r--meta/lib/oe/utils.py3
4 files changed, 26 insertions, 9 deletions
diff --git a/meta/classes/ccache.bbclass b/meta/classes/ccache.bbclass
index 960902065c..59e1022678 100644
--- a/meta/classes/ccache.bbclass
+++ b/meta/classes/ccache.bbclass
@@ -1,4 +1,14 @@
1CCACHE = "${@bb.utils.which(d.getVar('PATH'), 'ccache') and 'ccache '}" 1#
2# Usage:
3# - Enable ccache
4# Add the following line to a conffile such as conf/local.conf:
5# INHERIT += "ccache"
6#
7# - Disable ccache for a recipe
8# Add the following line to the recipe if it can't be built with ccache:
9# CCACHE_DISABLE = '1'
10#
11
2export CCACHE_DIR ?= "${TMPDIR}/ccache/${MULTIMACH_TARGET_SYS}/${PN}" 12export CCACHE_DIR ?= "${TMPDIR}/ccache/${MULTIMACH_TARGET_SYS}/${PN}"
3 13
4# We need to stop ccache considering the current directory or the 14# We need to stop ccache considering the current directory or the
@@ -7,5 +17,14 @@ export CCACHE_DIR ?= "${TMPDIR}/ccache/${MULTIMACH_TARGET_SYS}/${PN}"
7# ${PV} or ${PR} change. 17# ${PV} or ${PR} change.
8export CCACHE_NOHASHDIR ?= "1" 18export CCACHE_NOHASHDIR ?= "1"
9 19
10DEPENDS_append_class-target = " ccache-native" 20python() {
11DEPENDS[vardepvalueexclude] = " ccache-native" 21 """
22 Enable ccache for the recipe
23 """
24 pn = d.getVar('PN')
25 # quilt-native doesn't need ccache since no c files
26 if not (pn in ('ccache-native', 'quilt-native') or
27 bb.utils.to_boolean(d.getVar('CCACHE_DISABLE'))):
28 d.appendVar('DEPENDS', ' ccache-native')
29 d.setVar('CCACHE', 'ccache ')
30}
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 += " \
492HOSTTOOLS += "${@'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 ''}" 492HOSTTOOLS += "${@'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 ''}"
493 493
494# Link to these if present 494# Link to these if present
495HOSTTOOLS_NONFATAL += "aws ccache gcc-ar gpg ld.bfd ld.gold nc pigz sftp socat ssh sudo" 495HOSTTOOLS_NONFATAL += "aws gcc-ar gpg ld.bfd ld.gold nc pigz sftp socat ssh sudo"
496 496
497# Temporary add few more detected in bitbake world 497# Temporary add few more detected in bitbake world
498HOSTTOOLS_NONFATAL += "join nl size yes zcat" 498HOSTTOOLS_NONFATAL += "join nl size yes zcat"
@@ -504,10 +504,6 @@ HOSTTOOLS_NONFATAL += "bzr"
504HOSTTOOLS_NONFATAL += "scp" 504HOSTTOOLS_NONFATAL += "scp"
505 505
506CCACHE ??= "" 506CCACHE ??= ""
507# ccache < 3.1.10 will create CCACHE_DIR on startup even if disabled, and
508# autogen sets HOME=/dev/null so in certain situations builds can fail.
509# Explicitly export CCACHE_DIR until we can assume ccache >3.1.10 on the host.
510export CCACHE_DIR ??= "${@os.getenv('HOME')}/.ccache"
511 507
512TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_TARGET}" 508TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_TARGET}"
513 509
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 += " \
49 *->quilt-native \ 49 *->quilt-native \
50 *->subversion-native \ 50 *->subversion-native \
51 *->git-native \ 51 *->git-native \
52 *->ccache-native \
53 *->icecc-create-env-native \ 52 *->icecc-create-env-native \
54 gcc-cross-${TARGET_ARCH}->linux-libc-headers \ 53 gcc-cross-${TARGET_ARCH}->linux-libc-headers \
55 ppp-dialin->ppp \ 54 ppp-dialin->ppp \
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 29b41151d4..ee6f0e6647 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -363,6 +363,9 @@ def host_gcc_version(d, taskcontextonly=False):
363 return 363 return
364 364
365 compiler = d.getVar("BUILD_CC") 365 compiler = d.getVar("BUILD_CC")
366 # Get rid of ccache since it is not present when parsing.
367 if compiler.startswith('ccache '):
368 compiler = compiler[7:]
366 try: 369 try:
367 env = os.environ.copy() 370 env = os.environ.copy()
368 env["PATH"] = d.getVar("PATH") 371 env["PATH"] = d.getVar("PATH")