diff options
| -rw-r--r-- | meta/classes/icecc.bbclass | 31 |
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 | ||
| 227 | def 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 | |||
| 231 | def 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 |
| 228 | icecc_get_tool[vardepsexclude] += "STAGING_BINDIR_TOOLCHAIN" | 246 | icecc_get_tool[vardepsexclude] += "STAGING_BINDIR_TOOLCHAIN" |
| 229 | def icecc_get_tool(bb, d, tool): | 247 | def 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 | } |
