summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2018-02-19 16:30:20 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-02-24 10:31:46 +0000
commitdbf9346eaf7b8614b855b4c48ac0e925c9a3f704 (patch)
tree83e883be2ddb410f9200ddf96cf16d4128565d65 /meta/classes
parent1f334a3df0b72c42842738f62496e255f2277524 (diff)
downloadpoky-dbf9346eaf7b8614b855b4c48ac0e925c9a3f704.tar.gz
icecc.bbclass: Fix combining with ccache
Fixes the case where ccache is enabled along with Icecream. In these cases, there is the danger that Icecream will accidentally add the ccache executable to the toolchain, which prevents it from working. In particular, Fedora enables ccache by default via symbolic links in PATH. (From OE-Core rev: 09ba173f56dcd7299a07d4dac3633fe7818f7282) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/icecc.bbclass31
1 files changed, 26 insertions, 5 deletions
diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass
index e8f7eab1bc..2bf6cdb003 100644
--- a/meta/classes/icecc.bbclass
+++ b/meta/classes/icecc.bbclass
@@ -224,13 +224,31 @@ def icecc_get_external_tool(bb, d, tool):
224 target_prefix = d.expand('${TARGET_PREFIX}') 224 target_prefix = d.expand('${TARGET_PREFIX}')
225 return os.path.join(external_toolchain_bindir, '%s%s' % (target_prefix, tool)) 225 return os.path.join(external_toolchain_bindir, '%s%s' % (target_prefix, tool))
226 226
227def icecc_get_tool_link(tool, d):
228 import subprocess
229 return subprocess.check_output("readlink -f %s" % tool, shell=True).decode("utf-8")[:-1]
230
231def icecc_get_path_tool(tool, d):
232 # This is a little ugly, but we want to make sure we add an actual
233 # compiler to the toolchain, not ccache. Some distros (e.g. Fedora)
234 # have ccache enabled by default using symlinks PATH, meaning ccache
235 # would be found first when looking for the compiler.
236 paths = os.getenv("PATH").split(':')
237 while True:
238 p, hist = bb.utils.which(':'.join(paths), tool, history=True)
239 if not p or os.path.basename(icecc_get_tool_link(p, d)) != 'ccache':
240 return p
241 paths = paths[len(hist):]
242
243 return ""
244
227# Don't pollute native signatures with target TUNE_PKGARCH through STAGING_BINDIR_TOOLCHAIN 245# Don't pollute native signatures with target TUNE_PKGARCH through STAGING_BINDIR_TOOLCHAIN
228icecc_get_tool[vardepsexclude] += "STAGING_BINDIR_TOOLCHAIN" 246icecc_get_tool[vardepsexclude] += "STAGING_BINDIR_TOOLCHAIN"
229def icecc_get_tool(bb, d, tool): 247def icecc_get_tool(bb, d, tool):
230 if icecc_is_native(bb, d): 248 if icecc_is_native(bb, d):
231 return bb.utils.which(os.getenv("PATH"), tool) 249 return icecc_get_path_tool(tool, d)
232 elif icecc_is_kernel(bb, d): 250 elif icecc_is_kernel(bb, d):
233 return bb.utils.which(os.getenv("PATH"), get_cross_kernel_cc(bb, d)) 251 return icecc_get_path_tool(get_cross_kernel_cc(bb, d), d)
234 else: 252 else:
235 ice_dir = d.expand('${STAGING_BINDIR_TOOLCHAIN}') 253 ice_dir = d.expand('${STAGING_BINDIR_TOOLCHAIN}')
236 target_sys = d.expand('${TARGET_SYS}') 254 target_sys = d.expand('${TARGET_SYS}')
@@ -249,8 +267,7 @@ def icecc_get_and_check_tool(bb, d, tool):
249 # compiler environment package. 267 # compiler environment package.
250 t = icecc_get_tool(bb, d, tool) 268 t = icecc_get_tool(bb, d, tool)
251 if t: 269 if t:
252 import subprocess 270 link_path = icecc_get_tool_link(tool, d)
253 link_path = subprocess.check_output("readlink -f %s" % t, shell=True).decode("utf-8")[:-1]
254 if link_path == get_icecc(d): 271 if link_path == get_icecc(d):
255 bb.error("%s is a symlink to %s in PATH and this prevents icecc from working" % (t, get_icecc(d))) 272 bb.error("%s is a symlink to %s in PATH and this prevents icecc from working" % (t, get_icecc(d)))
256 return "" 273 return ""
@@ -342,9 +359,13 @@ set_icecc_env() {
342 fi 359 fi
343 fi 360 fi
344 361
362 # Don't let ccache find the icecream compiler links that have been created, otherwise
363 # it can end up invoking icecream recursively.
364 export CCACHE_PATH="$PATH"
365 export CCACHE_DISBALE="1"
366
345 export ICECC_VERSION ICECC_CC ICECC_CXX 367 export ICECC_VERSION ICECC_CC ICECC_CXX
346 export PATH="$ICE_PATH:$PATH" 368 export PATH="$ICE_PATH:$PATH"
347 export CCACHE_PATH="$PATH"
348 369
349 bbnote "Using icecc" 370 bbnote "Using icecc"
350} 371}