summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorTobias Henkel <tobias.henkel@bmw-carit.de>2013-11-12 09:34:03 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-11-12 16:00:29 +0000
commit78c6e69bbe1989561353801db4fcf265b94a21fa (patch)
tree474b7ae4a1148c5a5cd07a293eca19973db4207c /meta/classes
parent0dbd5456f9b010cbc2668d708573835a1be28d00 (diff)
downloadpoky-78c6e69bbe1989561353801db4fcf265b94a21fa.tar.gz
icecc: Fix race condition when packaging toolchain
In the current implementation there can be a race condition while creating the toolchain archive causing the build to break. This is fixed by locking the toolchain archiving step using flock. (From OE-Core rev: 8a30be803e91e66688cfc27ca4c21f26fb22eed8) Signed-off-by: Tobias Henkel <tobias.henkel@bmw-carit.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/icecc.bbclass31
1 files changed, 29 insertions, 2 deletions
diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass
index 3255839942..1f53f855fe 100644
--- a/meta/classes/icecc.bbclass
+++ b/meta/classes/icecc.bbclass
@@ -202,6 +202,21 @@ def icc_get_and_check_tool(bb, d, tool):
202 else: 202 else:
203 return t 203 return t
204 204
205wait_for_file() {
206 local TIME_ELAPSED=0
207 local FILE_TO_TEST=$1
208 local TIMEOUT=$2
209 until [ -f "$FILE_TO_TEST" ]
210 do
211 TIME_ELAPSED=`expr $TIME_ELAPSED + 1`
212 if [ $TIME_ELAPSED -gt $TIMEOUT ]
213 then
214 return 1
215 fi
216 sleep 1
217 done
218}
219
205def set_icecc_env(): 220def set_icecc_env():
206 # dummy python version of set_icecc_env 221 # dummy python version of set_icecc_env
207 return 222 return
@@ -247,10 +262,22 @@ set_icecc_env() {
247 ICECC_AS="`which as`" 262 ICECC_AS="`which as`"
248 fi 263 fi
249 264
250 if [ ! -r "${ICECC_VERSION}" ] 265 if [ ! -f "${ICECC_VERSION}.done" ]
251 then 266 then
252 mkdir -p "`dirname "${ICECC_VERSION}"`" 267 mkdir -p "`dirname "${ICECC_VERSION}"`"
253 ${ICECC_ENV_EXEC} "${ICECC_CC}" "${ICECC_CXX}" "${ICECC_AS}" "${ICECC_VERSION}" 268
269 # the ICECC_VERSION generation step must be locked by a mutex
270 # in order to prevent race conditions
271 if flock -n "${ICECC_VERSION}.lock" \
272 ${ICECC_ENV_EXEC} "${ICECC_CC}" "${ICECC_CXX}" "${ICECC_AS}" "${ICECC_VERSION}"
273 then
274 touch "${ICECC_VERSION}.done"
275 elif [ ! wait_for_file "${ICECC_VERSION}.done" 30 ]
276 then
277 # locking failed so wait for ${ICECC_VERSION}.done to appear
278 bbwarn "Timeout waiting for ${ICECC_VERSION}.done"
279 return
280 fi
254 fi 281 fi
255 282
256 export ICECC_VERSION ICECC_CC ICECC_CXX 283 export ICECC_VERSION ICECC_CC ICECC_CXX