[oe-commits] [openembedded-core] 35/59: icecc.bbclass: Fix combining with ccache

git at git.openembedded.org git at git.openembedded.org
Sat Feb 24 10:36:54 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master
in repository openembedded-core.

commit 09ba173f56dcd7299a07d4dac3633fe7818f7282
Author: Joshua Watt <jpewhacker at gmail.com>
AuthorDate: Mon Feb 19 16:30:20 2018 -0600

    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.
    
    Signed-off-by: Joshua Watt <JPEWhacker at gmail.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/classes/icecc.bbclass | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass
index e8f7eab..2bf6cdb 100644
--- a/meta/classes/icecc.bbclass
+++ b/meta/classes/icecc.bbclass
@@ -224,13 +224,31 @@ def icecc_get_external_tool(bb, d, tool):
     target_prefix = d.expand('${TARGET_PREFIX}')
     return os.path.join(external_toolchain_bindir, '%s%s' % (target_prefix, tool))
 
+def icecc_get_tool_link(tool, d):
+    import subprocess
+    return subprocess.check_output("readlink -f %s" % tool, shell=True).decode("utf-8")[:-1]
+
+def icecc_get_path_tool(tool, d):
+    # This is a little ugly, but we want to make sure we add an actual
+    # compiler to the toolchain, not ccache. Some distros (e.g. Fedora)
+    # have ccache enabled by default using symlinks PATH, meaning ccache
+    # would be found first when looking for the compiler.
+    paths = os.getenv("PATH").split(':')
+    while True:
+        p, hist = bb.utils.which(':'.join(paths), tool, history=True)
+        if not p or os.path.basename(icecc_get_tool_link(p, d)) != 'ccache':
+            return p
+        paths = paths[len(hist):]
+
+    return ""
+
 # Don't pollute native signatures with target TUNE_PKGARCH through STAGING_BINDIR_TOOLCHAIN
 icecc_get_tool[vardepsexclude] += "STAGING_BINDIR_TOOLCHAIN"
 def icecc_get_tool(bb, d, tool):
     if icecc_is_native(bb, d):
-        return bb.utils.which(os.getenv("PATH"), tool)
+        return icecc_get_path_tool(tool, d)
     elif icecc_is_kernel(bb, d):
-        return bb.utils.which(os.getenv("PATH"), get_cross_kernel_cc(bb, d))
+        return icecc_get_path_tool(get_cross_kernel_cc(bb, d), d)
     else:
         ice_dir = d.expand('${STAGING_BINDIR_TOOLCHAIN}')
         target_sys = d.expand('${TARGET_SYS}')
@@ -249,8 +267,7 @@ def icecc_get_and_check_tool(bb, d, tool):
     # compiler environment package.
     t = icecc_get_tool(bb, d, tool)
     if t:
-        import subprocess
-        link_path = subprocess.check_output("readlink -f %s" % t, shell=True).decode("utf-8")[:-1]
+        link_path = icecc_get_tool_link(tool, d)
         if link_path == get_icecc(d):
             bb.error("%s is a symlink to %s in PATH and this prevents icecc from working" % (t, get_icecc(d)))
             return ""
@@ -342,9 +359,13 @@ set_icecc_env() {
         fi
     fi
 
+    # Don't let ccache find the icecream compiler links that have been created, otherwise
+    # it can end up invoking icecream recursively.
+    export CCACHE_PATH="$PATH"
+    export CCACHE_DISBALE="1"
+
     export ICECC_VERSION ICECC_CC ICECC_CXX
     export PATH="$ICE_PATH:$PATH"
-    export CCACHE_PATH="$PATH"
 
     bbnote "Using icecc"
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list