blob: fc82f8de1ad870d893e6d0ad68403353ce9ac002 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# IceCream distributed compiling support
2#
3# Stages directories with symlinks from gcc/g++ to icecc, for both
4# native and cross compilers. Depending on each configure or compile,
5# the directories are added at the head of the PATH list and ICECC_CXX
6# and ICEC_CC are set.
7#
8# For the cross compiler, creates a tar.gz of our toolchain and sets
9# ICECC_VERSION accordingly.
10#
11# The class now handles all 3 different compile 'stages' (i.e native ,cross-kernel and target) creating the
12# necessary environment tar.gz file to be used by the remote machines.
13# It also supports meta-toolchain generation
14#
15# If ICECC_PATH is not set in local.conf then the class will try to locate it using 'bb.utils.which'
16# but nothing is sure ;)
17#
18# If ICECC_ENV_EXEC is set in local.conf, then it should point to the icecc-create-env script provided by the user
19# or the default one provided by icecc-create-env.bb will be used
20# (NOTE that this is a modified version of the script need it and *not the one that comes with icecc*
21#
22# User can specify if specific packages or packages belonging to class should not use icecc to distribute
23# compile jobs to remote machines, but handled locally, by defining ICECC_USER_CLASS_BL and ICECC_USER_PACKAGE_BL
24# with the appropriate values in local.conf. In addition the user can force to enable icecc for packages
25# which set an empty PARALLEL_MAKE variable by defining ICECC_USER_PACKAGE_WL.
26#
27#########################################################################################
28#Error checking is kept to minimum so double check any parameters you pass to the class
29###########################################################################################
30
Brad Bishop316dfdd2018-06-25 12:45:53 -040031BB_HASHBASE_WHITELIST += "ICECC_PARALLEL_MAKE ICECC_DISABLED ICECC_USER_PACKAGE_BL \
32 ICECC_USER_CLASS_BL ICECC_USER_PACKAGE_WL ICECC_PATH ICECC_ENV_EXEC \
33 ICECC_CARET_WORKAROUND ICECC_CFLAGS ICECC_ENV_VERSION \
34 ICECC_DEBUG ICECC_LOGFILE ICECC_REPEAT_RATE ICECC_PREFERRED_HOST \
35 ICECC_CLANG_REMOTE_CPP ICECC_IGNORE_UNVERIFIED ICECC_TEST_SOCKET \
Brad Bishopa5c52ff2018-11-23 10:55:50 +130036 ICECC_ENV_DEBUG ICECC_SYSTEM_PACKAGE_BL ICECC_SYSTEM_CLASS_BL \
Brad Bishop19323692019-04-05 15:28:33 -040037 ICECC_REMOTE_CPP \
Brad Bishop316dfdd2018-06-25 12:45:53 -040038 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039
40ICECC_ENV_EXEC ?= "${STAGING_BINDIR_NATIVE}/icecc-create-env"
41
Brad Bishop977dc1a2019-02-06 16:01:43 -050042HOSTTOOLS_NONFATAL += "icecc patchelf"
43
Brad Bishop316dfdd2018-06-25 12:45:53 -040044# This version can be incremented when changes are made to the environment that
45# invalidate the version on the compile nodes. Changing it will cause a new
46# environment to be created.
47#
48# A useful thing to do for testing Icecream changes locally is to add a
49# subversion in local.conf:
50# ICECC_ENV_VERSION_append = "-my-ver-1"
51ICECC_ENV_VERSION = "2"
52
53# Default to disabling the caret workaround, If set to "1" in local.conf, icecc
54# will locally recompile any files that have warnings, which can adversely
55# affect performance.
56#
57# See: https://github.com/icecc/icecream/issues/190
58export ICECC_CARET_WORKAROUND ??= "0"
59
Brad Bishop96ff1982019-08-19 13:50:42 -040060export ICECC_REMOTE_CPP ??= "0"
Brad Bishop19323692019-04-05 15:28:33 -040061
Brad Bishop316dfdd2018-06-25 12:45:53 -040062ICECC_CFLAGS = ""
63CFLAGS += "${ICECC_CFLAGS}"
64CXXFLAGS += "${ICECC_CFLAGS}"
65
66# Debug flags when generating environments
67ICECC_ENV_DEBUG ??= ""
68
Brad Bishopa5c52ff2018-11-23 10:55:50 +130069# "system" recipe blacklist contains a list of packages that can not distribute
70# compile tasks for one reason or the other. When adding new entry, please
71# document why (how it failed) so that we can re-evaluate it later e.g. when
72# there is new version
73#
74# libgcc-initial - fails with CPP sanity check error if host sysroot contains
75# cross gcc built for another target tune/variant
Brad Bishop79641f22019-09-10 07:20:22 -040076# systemtap - _HelperSDT.c undefs macros and uses the identifiers in macros emitting
77# inline assembly
Brad Bishopa5c52ff2018-11-23 10:55:50 +130078# target-sdk-provides-dummy - ${HOST_PREFIX} is empty which triggers the "NULL
79# prefix" error.
80ICECC_SYSTEM_PACKAGE_BL += "\
81 libgcc-initial \
Brad Bishop79641f22019-09-10 07:20:22 -040082 systemtap \
Brad Bishopa5c52ff2018-11-23 10:55:50 +130083 target-sdk-provides-dummy \
84 "
85
86# "system" classes that should be blacklisted. When adding new entry, please
87# document why (how it failed) so that we can re-evaluate it later
88#
89# image - Image aren't compiling, but the testing framework for images captures
90# PARALLEL_MAKE as part of the test environment. Many tests won't use
91# icecream, but leaving the high level of parallelism can cause them to
92# consume an unnecessary amount of resources.
93ICECC_SYSTEM_CLASS_BL += "\
94 image \
95 "
96
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097def icecc_dep_prepend(d):
98 # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not
99 # we need that built is the responsibility of the patch function / class, not
100 # the application.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400101 if not d.getVar('INHIBIT_DEFAULT_DEPS'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102 return "icecc-create-env-native"
103 return ""
104
105DEPENDS_prepend += "${@icecc_dep_prepend(d)} "
106
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500107get_cross_kernel_cc[vardepsexclude] += "KERNEL_CC"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108def get_cross_kernel_cc(bb,d):
Brad Bishop977dc1a2019-02-06 16:01:43 -0500109 if not icecc_is_kernel(bb, d):
110 return None
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111
112 # evaluate the expression by the shell if necessary
Brad Bishop977dc1a2019-02-06 16:01:43 -0500113 kernel_cc = d.getVar('KERNEL_CC')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114 if '`' in kernel_cc or '$(' in kernel_cc:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600115 import subprocess
116 kernel_cc = subprocess.check_output("echo %s" % kernel_cc, shell=True).decode("utf-8")[:-1]
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118 kernel_cc = kernel_cc.replace('ccache', '').strip()
119 kernel_cc = kernel_cc.split(' ')[0]
120 kernel_cc = kernel_cc.strip()
121 return kernel_cc
122
123def get_icecc(d):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400124 return d.getVar('ICECC_PATH') or bb.utils.which(os.getenv("PATH"), "icecc")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500126def use_icecc(bb,d):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400127 if d.getVar('ICECC_DISABLED') == "1":
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128 # don't even try it, when explicitly disabled
129 return "no"
130
131 # allarch recipes don't use compiler
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500132 if icecc_is_allarch(bb, d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500133 return "no"
134
Brad Bishop316dfdd2018-06-25 12:45:53 -0400135 if icecc_is_cross_canadian(bb, d):
136 return "no"
137
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500138 pn = d.getVar('PN')
Brad Bishop19323692019-04-05 15:28:33 -0400139 bpn = d.getVar('BPN')
140
141 # Blacklist/whitelist checks are made against BPN, because there is a good
142 # chance that if icecc should be skipped for a recipe, it should be skipped
143 # for all the variants of that recipe. PN is still checked in case a user
144 # specified a more specific recipe.
145 check_pn = set([pn, bpn])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500146
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300147 system_class_blacklist = (d.getVar('ICECC_SYSTEM_CLASS_BL') or "").split()
Brad Bishop316dfdd2018-06-25 12:45:53 -0400148 user_class_blacklist = (d.getVar('ICECC_USER_CLASS_BL') or "none").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500149 package_class_blacklist = system_class_blacklist + user_class_blacklist
150
151 for black in package_class_blacklist:
152 if bb.data.inherits_class(black, d):
153 bb.debug(1, "%s: class %s found in blacklist, disable icecc" % (pn, black))
154 return "no"
155
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300156 system_package_blacklist = (d.getVar('ICECC_SYSTEM_PACKAGE_BL') or "").split()
Brad Bishop316dfdd2018-06-25 12:45:53 -0400157 user_package_blacklist = (d.getVar('ICECC_USER_PACKAGE_BL') or "").split()
158 user_package_whitelist = (d.getVar('ICECC_USER_PACKAGE_WL') or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500159 package_blacklist = system_package_blacklist + user_package_blacklist
160
Brad Bishop19323692019-04-05 15:28:33 -0400161 if check_pn & set(package_blacklist):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162 bb.debug(1, "%s: found in blacklist, disable icecc" % pn)
163 return "no"
164
Brad Bishop19323692019-04-05 15:28:33 -0400165 if check_pn & set(user_package_whitelist):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166 bb.debug(1, "%s: found in whitelist, enable icecc" % pn)
167 return "yes"
168
Brad Bishop316dfdd2018-06-25 12:45:53 -0400169 if d.getVar('PARALLEL_MAKE') == "":
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500170 bb.debug(1, "%s: has empty PARALLEL_MAKE, disable icecc" % pn)
171 return "no"
172
173 return "yes"
174
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500175def icecc_is_allarch(bb, d):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800176 return d.getVar("PACKAGE_ARCH") == "all"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500178def icecc_is_kernel(bb, d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500179 return \
180 bb.data.inherits_class("kernel", d);
181
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500182def icecc_is_native(bb, d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500183 return \
184 bb.data.inherits_class("cross", d) or \
185 bb.data.inherits_class("native", d);
186
Brad Bishop316dfdd2018-06-25 12:45:53 -0400187def icecc_is_cross_canadian(bb, d):
188 return bb.data.inherits_class("cross-canadian", d)
189
190def icecc_dir(bb, d):
191 return d.expand('${TMPDIR}/work-shared/ice')
192
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500193# Don't pollute allarch signatures with TARGET_FPU
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500194icecc_version[vardepsexclude] += "TARGET_FPU"
195def icecc_version(bb, d):
196 if use_icecc(bb, d) == "no":
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500197 return ""
198
Brad Bishop316dfdd2018-06-25 12:45:53 -0400199 parallel = d.getVar('ICECC_PARALLEL_MAKE') or ""
200 if not d.getVar('PARALLEL_MAKE') == "" and parallel:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500201 d.setVar("PARALLEL_MAKE", parallel)
202
Brad Bishop316dfdd2018-06-25 12:45:53 -0400203 # Disable showing the caret in the GCC compiler output if the workaround is
204 # disabled
205 if d.getVar('ICECC_CARET_WORKAROUND') == '0':
206 d.setVar('ICECC_CFLAGS', '-fno-diagnostics-show-caret')
207
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500208 if icecc_is_native(bb, d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500209 archive_name = "local-host-env"
210 elif d.expand('${HOST_PREFIX}') == "":
211 bb.fatal(d.expand("${PN}"), " NULL prefix")
212 else:
213 prefix = d.expand('${HOST_PREFIX}' )
214 distro = d.expand('${DISTRO}')
215 target_sys = d.expand('${TARGET_SYS}')
Brad Bishop316dfdd2018-06-25 12:45:53 -0400216 float = d.getVar('TARGET_FPU') or "hard"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500217 archive_name = prefix + distro + "-" + target_sys + "-" + float
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500218 if icecc_is_kernel(bb, d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500219 archive_name += "-kernel"
220
221 import socket
Brad Bishop316dfdd2018-06-25 12:45:53 -0400222 ice_dir = icecc_dir(bb, d)
223 tar_file = os.path.join(ice_dir, "{archive}-{version}-@VERSION@-{hostname}.tar.gz".format(
224 archive=archive_name,
225 version=d.getVar('ICECC_ENV_VERSION'),
226 hostname=socket.gethostname()
227 ))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500228
229 return tar_file
230
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500231def icecc_path(bb,d):
232 if use_icecc(bb, d) == "no":
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500233 # don't create unnecessary directories when icecc is disabled
234 return
235
Brad Bishop977dc1a2019-02-06 16:01:43 -0500236 staging = os.path.join(d.expand('${STAGING_BINDIR}'), "ice")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500237 if icecc_is_kernel(bb, d):
Brad Bishop977dc1a2019-02-06 16:01:43 -0500238 staging += "-kernel"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500239
Brad Bishop977dc1a2019-02-06 16:01:43 -0500240 return staging
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500241
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500242def icecc_get_external_tool(bb, d, tool):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500243 external_toolchain_bindir = d.expand('${EXTERNAL_TOOLCHAIN}${bindir_cross}')
244 target_prefix = d.expand('${TARGET_PREFIX}')
245 return os.path.join(external_toolchain_bindir, '%s%s' % (target_prefix, tool))
246
Brad Bishop316dfdd2018-06-25 12:45:53 -0400247def icecc_get_tool_link(tool, d):
248 import subprocess
Brad Bishop08902b02019-08-20 09:16:51 -0400249 try:
250 return subprocess.check_output("readlink -f %s" % tool, shell=True).decode("utf-8")[:-1]
251 except subprocess.CalledProcessError as e:
252 bb.note("icecc: one of the tools probably disappeared during recipe parsing, cmd readlink -f %s returned %d:\n%s" % (tool, e.returncode, e.output.decode("utf-8")))
253 return tool
Brad Bishop316dfdd2018-06-25 12:45:53 -0400254
255def icecc_get_path_tool(tool, d):
256 # This is a little ugly, but we want to make sure we add an actual
257 # compiler to the toolchain, not ccache. Some distros (e.g. Fedora)
258 # have ccache enabled by default using symlinks PATH, meaning ccache
259 # would be found first when looking for the compiler.
260 paths = os.getenv("PATH").split(':')
261 while True:
262 p, hist = bb.utils.which(':'.join(paths), tool, history=True)
263 if not p or os.path.basename(icecc_get_tool_link(p, d)) != 'ccache':
264 return p
265 paths = paths[len(hist):]
266
267 return ""
268
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500269# Don't pollute native signatures with target TUNE_PKGARCH through STAGING_BINDIR_TOOLCHAIN
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500270icecc_get_tool[vardepsexclude] += "STAGING_BINDIR_TOOLCHAIN"
271def icecc_get_tool(bb, d, tool):
272 if icecc_is_native(bb, d):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400273 return icecc_get_path_tool(tool, d)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500274 elif icecc_is_kernel(bb, d):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400275 return icecc_get_path_tool(get_cross_kernel_cc(bb, d), d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500276 else:
277 ice_dir = d.expand('${STAGING_BINDIR_TOOLCHAIN}')
278 target_sys = d.expand('${TARGET_SYS}')
Brad Bishop316dfdd2018-06-25 12:45:53 -0400279 for p in ice_dir.split(':'):
280 tool_bin = os.path.join(p, "%s-%s" % (target_sys, tool))
281 if os.path.isfile(tool_bin):
282 return tool_bin
283 external_tool_bin = icecc_get_external_tool(bb, d, tool)
284 if os.path.isfile(external_tool_bin):
285 return external_tool_bin
286 return ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500287
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500288def icecc_get_and_check_tool(bb, d, tool):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500289 # Check that g++ or gcc is not a symbolic link to icecc binary in
290 # PATH or icecc-create-env script will silently create an invalid
291 # compiler environment package.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500292 t = icecc_get_tool(bb, d, tool)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600293 if t:
Brad Bishop977dc1a2019-02-06 16:01:43 -0500294 link_path = icecc_get_tool_link(t, d)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600295 if link_path == get_icecc(d):
Brad Bishop977dc1a2019-02-06 16:01:43 -0500296 bb.error("%s is a symlink to %s in PATH and this prevents icecc from working" % (t, link_path))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600297 return ""
298 else:
299 return t
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500300 else:
301 return t
302
303wait_for_file() {
304 local TIME_ELAPSED=0
305 local FILE_TO_TEST=$1
306 local TIMEOUT=$2
307 until [ -f "$FILE_TO_TEST" ]
308 do
309 TIME_ELAPSED=`expr $TIME_ELAPSED + 1`
310 if [ $TIME_ELAPSED -gt $TIMEOUT ]
311 then
312 return 1
313 fi
314 sleep 1
315 done
316}
317
318def set_icecc_env():
319 # dummy python version of set_icecc_env
320 return
321
Brad Bishopc342db32019-05-15 21:57:59 -0400322set_icecc_env[vardepsexclude] += "KERNEL_CC"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500323set_icecc_env() {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500324 if [ "${@use_icecc(bb, d)}" = "no" ]
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500325 then
326 return
327 fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500328 ICECC_VERSION="${@icecc_version(bb, d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500329 if [ "x${ICECC_VERSION}" = "x" ]
330 then
331 bbwarn "Cannot use icecc: could not get ICECC_VERSION"
332 return
333 fi
334
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500335 ICE_PATH="${@icecc_path(bb, d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500336 if [ "x${ICE_PATH}" = "x" ]
337 then
338 bbwarn "Cannot use icecc: could not get ICE_PATH"
339 return
340 fi
341
Brad Bishop977dc1a2019-02-06 16:01:43 -0500342 ICECC_BIN="${@get_icecc(d)}"
343 if [ -z "${ICECC_BIN}" ]; then
344 bbwarn "Cannot use icecc: icecc binary not found"
345 return
346 fi
347 if [ -z "$(which patchelf patchelf-uninative)" ]; then
348 bbwarn "Cannot use icecc: patchelf not found"
349 return
350 fi
351
352 # Create symlinks to icecc in the recipe-sysroot directory
353 mkdir -p ${ICE_PATH}
354 if [ -n "${KERNEL_CC}" ]; then
355 compilers="${@get_cross_kernel_cc(bb,d)}"
356 else
357 compilers="${HOST_PREFIX}gcc ${HOST_PREFIX}g++"
358 fi
359 for compiler in $compilers; do
360 ln -sf ${ICECC_BIN} ${ICE_PATH}/$compiler
361 done
362
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500363 ICECC_CC="${@icecc_get_and_check_tool(bb, d, "gcc")}"
364 ICECC_CXX="${@icecc_get_and_check_tool(bb, d, "g++")}"
365 # cannot use icecc_get_and_check_tool here because it assumes as without target_sys prefix
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500366 ICECC_WHICH_AS="${@bb.utils.which(os.getenv('PATH'), 'as')}"
367 if [ ! -x "${ICECC_CC}" -o ! -x "${ICECC_CXX}" ]
368 then
369 bbwarn "Cannot use icecc: could not get ICECC_CC or ICECC_CXX"
370 return
371 fi
372
373 ICE_VERSION=`$ICECC_CC -dumpversion`
374 ICECC_VERSION=`echo ${ICECC_VERSION} | sed -e "s/@VERSION@/$ICE_VERSION/g"`
375 if [ ! -x "${ICECC_ENV_EXEC}" ]
376 then
377 bbwarn "Cannot use icecc: invalid ICECC_ENV_EXEC"
378 return
379 fi
380
381 ICECC_AS="`${ICECC_CC} -print-prog-name=as`"
382 # for target recipes should return something like:
383 # /OE/tmp-eglibc/sysroots/x86_64-linux/usr/libexec/arm920tt-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.8.2/as
384 # and just "as" for native, if it returns "as" in current directory (for whatever reason) use "as" from PATH
385 if [ "`dirname "${ICECC_AS}"`" = "." ]
386 then
387 ICECC_AS="${ICECC_WHICH_AS}"
388 fi
389
390 if [ ! -f "${ICECC_VERSION}.done" ]
391 then
392 mkdir -p "`dirname "${ICECC_VERSION}"`"
393
394 # the ICECC_VERSION generation step must be locked by a mutex
395 # in order to prevent race conditions
396 if flock -n "${ICECC_VERSION}.lock" \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400397 ${ICECC_ENV_EXEC} ${ICECC_ENV_DEBUG} "${ICECC_CC}" "${ICECC_CXX}" "${ICECC_AS}" "${ICECC_VERSION}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500398 then
399 touch "${ICECC_VERSION}.done"
Brad Bishop19323692019-04-05 15:28:33 -0400400 elif ! wait_for_file "${ICECC_VERSION}.done" 30
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500401 then
402 # locking failed so wait for ${ICECC_VERSION}.done to appear
403 bbwarn "Timeout waiting for ${ICECC_VERSION}.done"
404 return
405 fi
406 fi
407
Brad Bishop316dfdd2018-06-25 12:45:53 -0400408 # Don't let ccache find the icecream compiler links that have been created, otherwise
409 # it can end up invoking icecream recursively.
410 export CCACHE_PATH="$PATH"
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300411 export CCACHE_DISABLE="1"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400412
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500413 export ICECC_VERSION ICECC_CC ICECC_CXX
414 export PATH="$ICE_PATH:$PATH"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500415
Brad Bishop19323692019-04-05 15:28:33 -0400416 bbnote "Using icecc path: $ICE_PATH"
417 bbnote "Using icecc tarball: $ICECC_VERSION"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500418}
419
420do_configure_prepend() {
421 set_icecc_env
422}
423
424do_compile_prepend() {
425 set_icecc_env
426}
427
428do_compile_kernelmodules_prepend() {
429 set_icecc_env
430}
431
432do_install_prepend() {
433 set_icecc_env
434}
Brad Bishop316dfdd2018-06-25 12:45:53 -0400435
436# IceCream is not (currently) supported in the extensible SDK
437ICECC_SDK_HOST_TASK = "nativesdk-icecc-toolchain"
438ICECC_SDK_HOST_TASK_task-populate-sdk-ext = ""
439
440# Don't include IceCream in uninative tarball
441ICECC_SDK_HOST_TASK_pn-uninative-tarball = ""
442
443# Add the toolchain scripts to the SDK
444TOOLCHAIN_HOST_TASK_append = " ${ICECC_SDK_HOST_TASK}"